Skip to content

CS: class/function braces on new line #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Config;

class BaseTestCase extends TestCase {
class BaseTestCase extends TestCase
{
const STANDARD_NAME = 'VariableAnalysis';

public function prepareLocalFileForSniffs($fixtureFile) {
public function prepareLocalFileForSniffs($fixtureFile)
{
$sniffFile = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php';

$config = new Config();
Expand All @@ -27,21 +29,25 @@ public function prepareLocalFileForSniffs($fixtureFile) {
return new LocalFile($fixtureFile, $ruleset, $config);
}

public function getLineNumbersFromMessages(array $messages) {
public function getLineNumbersFromMessages(array $messages)
{
$lines = array_keys($messages);
sort($lines);
return $lines;
}

public function getWarningLineNumbersFromFile(LocalFile $phpcsFile) {
public function getWarningLineNumbersFromFile(LocalFile $phpcsFile)
{
return $this->getLineNumbersFromMessages($phpcsFile->getWarnings());
}

public function getErrorLineNumbersFromFile(LocalFile $phpcsFile) {
public function getErrorLineNumbersFromFile(LocalFile $phpcsFile)
{
return $this->getLineNumbersFromMessages($phpcsFile->getErrors());
}

public function getFixture($fixtureFilename) {
public function getFixture($fixtureFilename)
{
return realpath(__DIR__ . '/VariableAnalysisSniff/fixtures/' . $fixtureFilename);
}
}
9 changes: 6 additions & 3 deletions Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class ArrayAssignmentShortcutTest extends BaseTestCase {
public function testArrayAssignmentReportsCorrectLines() {
class ArrayAssignmentShortcutTest extends BaseTestCase
{
public function testArrayAssignmentReportsCorrectLines()
{
$fixtureFile = $this->getFixture('ArrayAssignmentShortcutFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand All @@ -19,7 +21,8 @@ public function testArrayAssignmentReportsCorrectLines() {
$this->assertSame($expectedWarnings, $lines);
}

public function testArrayAssignmentHasCorrectSniffCodes() {
public function testArrayAssignmentHasCorrectSniffCodes()
{
$fixtureFile = $this->getFixture('ArrayAssignmentShortcutFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand Down
9 changes: 6 additions & 3 deletions Tests/VariableAnalysisSniff/ArrowFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class ArrowFunctionTest extends BaseTestCase {
public function testArrowFunctions() {
class ArrowFunctionTest extends BaseTestCase
{
public function testArrowFunctions()
{
$fixtureFile = $this->getFixture('ArrowFunctionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand All @@ -30,7 +32,8 @@ public function testArrowFunctions() {
$this->assertSame($expectedWarnings, $lines);
}

public function testArrowFunctionsWithoutUnusedBeforeUsed() {
public function testArrowFunctionsWithoutUnusedBeforeUsed()
{
$fixtureFile = $this->getFixture('ArrowFunctionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down
9 changes: 6 additions & 3 deletions Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class ClosingPhpTagsTest extends BaseTestCase {
public function testVariableWarningsWhenClosingTagsAreUsed() {
class ClosingPhpTagsTest extends BaseTestCase
{
public function testVariableWarningsWhenClosingTagsAreUsed()
{
$fixtureFile = $this->getFixture('ClosingPhpTagsFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand All @@ -18,7 +20,8 @@ public function testVariableWarningsWhenClosingTagsAreUsed() {
$this->assertSame($expectedWarnings, $lines);
}

public function testVariableWarningsHaveCorrectSniffCodesWhenClosingTagsAreUsed() {
public function testVariableWarningsHaveCorrectSniffCodesWhenClosingTagsAreUsed()
{
$fixtureFile = $this->getFixture('ClosingPhpTagsFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand Down
12 changes: 8 additions & 4 deletions Tests/VariableAnalysisSniff/GlobalScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class GlobalScopeTest extends BaseTestCase {
public function testGlobalScopeWarnings() {
class GlobalScopeTest extends BaseTestCase
{
public function testGlobalScopeWarnings()
{
$fixtureFile = $this->getFixture('GlobalScopeFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand All @@ -23,7 +25,8 @@ public function testGlobalScopeWarnings() {
$this->assertSame($expectedErrors, $lines);
}

public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope() {
public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope()
{
$fixtureFile = $this->getFixture('GlobalScopeFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand All @@ -41,7 +44,8 @@ public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope()
$this->assertSame($expectedErrors, $lines);
}

public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() {
public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope()
{
$fixtureFile = $this->getFixture('GlobalScopeFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down
15 changes: 10 additions & 5 deletions Tests/VariableAnalysisSniff/IfConditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class IfConditionTest extends BaseTestCase {
public function testIfConditionWarnings() {
class IfConditionTest extends BaseTestCase
{
public function testIfConditionWarnings()
{
$fixtureFile = $this->getFixture('FunctionWithIfConditionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down Expand Up @@ -36,7 +38,8 @@ public function testIfConditionWarnings() {
$this->assertSame($expectedWarnings, $lines);
}

public function testIfConditionWarningsWithValidUndefinedVariableNames() {
public function testIfConditionWarningsWithValidUndefinedVariableNames()
{
$fixtureFile = $this->getFixture('FunctionWithIfConditionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down Expand Up @@ -67,7 +70,8 @@ public function testIfConditionWarningsWithValidUndefinedVariableNames() {
$this->assertSame($expectedWarnings, $lines);
}

public function testInlineIfConditionWarnings() {
public function testInlineIfConditionWarnings()
{
$fixtureFile = $this->getFixture('FunctionWithInlineIfConditionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down Expand Up @@ -99,7 +103,8 @@ public function testInlineIfConditionWarnings() {
$this->assertSame($expectedWarnings, $lines);
}

public function testInlineIfConditionWarningsWithValidUndefinedVariableNames() {
public function testInlineIfConditionWarningsWithValidUndefinedVariableNames()
{
$fixtureFile = $this->getFixture('FunctionWithInlineIfConditionFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down
6 changes: 4 additions & 2 deletions Tests/VariableAnalysisSniff/IssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class IssetTest extends BaseTestCase {
public function testIssetVariableUse() {
class IssetTest extends BaseTestCase
{
public function testIssetVariableUse()
{
$fixtureFile = $this->getFixture('IssetFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand Down
9 changes: 6 additions & 3 deletions Tests/VariableAnalysisSniff/UnsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class UnsetTest extends BaseTestCase {
public function testUnsetReportsUndefinedVariables() {
class UnsetTest extends BaseTestCase
{
public function testUnsetReportsUndefinedVariables()
{
$fixtureFile = $this->getFixture('UnsetFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand All @@ -17,7 +19,8 @@ public function testUnsetReportsUndefinedVariables() {
$this->assertSame($expectedWarnings, $lines);
}

public function testUnsetHasCorrectSniffCodes() {
public function testUnsetHasCorrectSniffCodes()
{
$fixtureFile = $this->getFixture('UnsetFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand Down
12 changes: 8 additions & 4 deletions Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use VariableAnalysis\Tests\BaseTestCase;

class UnusedFollowedByRequire extends BaseTestCase {
public function testUnusedFollowedByRequireWarnsByDefault() {
class UnusedFollowedByRequire extends BaseTestCase
{
public function testUnusedFollowedByRequireWarnsByDefault()
{
$fixtureFile = $this->getFixture('UnusedFollowedByRequireFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->process();
Expand All @@ -26,7 +28,8 @@ public function testUnusedFollowedByRequireWarnsByDefault() {
$this->assertSame($expectedWarnings, $lines);
}

public function testUnusedFollowedByRequireDoesNotWarnWhenSet() {
public function testUnusedFollowedByRequireDoesNotWarnWhenSet()
{
$fixtureFile = $this->getFixture('UnusedFollowedByRequireFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand All @@ -45,7 +48,8 @@ public function testUnusedFollowedByRequireDoesNotWarnWhenSet() {
$this->assertSame($expectedWarnings, $lines);
}

public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet() {
public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet()
{
$fixtureFile = $this->getFixture('FunctionWithoutParamFixture.php');
$phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile);
$phpcsFile->ruleset->setSniffProperty(
Expand Down
Loading