Skip to content
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

DX: cleanup - remove special treatment for PHP <5.6 #3903

Merged
merged 1 commit into from Jul 12, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/Fixer/ClassNotation/SelfAccessorFixer.php
Expand Up @@ -114,12 +114,8 @@ private function replaceNameOccurrences(Tokens $tokens, $name, $startIndex, $end

$token = $tokens[$i];

if (
// skip anonymous classes
($token->isGivenKind(T_CLASS) && $tokensAnalyzer->isAnonymousClass($i)) ||
// skip lambda functions (PHP < 5.4 compatibility)
($token->isGivenKind(T_FUNCTION) && $tokensAnalyzer->isLambda($i))
) {
// skip anonymous classes
if ($token->isGivenKind(T_CLASS) && $tokensAnalyzer->isAnonymousClass($i)) {
$i = $tokens->getNextTokenOfKind($i, ['{']);
$i = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $i);

Expand Down
2 changes: 1 addition & 1 deletion src/Utils.php
Expand Up @@ -177,7 +177,7 @@ static function (FixerInterface $fixer) {
return $fixer->getPriority();
},
static function ($a, $b) {
return Utils::cmpInt($b, $a);
return self::cmpInt($b, $a);
}
);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/Console/Command/SelfUpdateCommandTest.php
Expand Up @@ -97,8 +97,6 @@ public function provideCommandNameCases()
* @param string $expectedDisplay
*
* @dataProvider provideExecuteCases
*
* @requires PHP 5.4
*/
public function testExecute(
$latestVersion,
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ClassNotation/SelfAccessorFixerTest.php
Expand Up @@ -83,7 +83,7 @@ public function provideFixCases()
'<?php class Foo { function bar() { new Foo\Baz(); } }',
],
[
// PHP < 5.4 compatibility: "self" is not available in closures
'<?php class Foo { function bar() { function ($a = self::BAZ) { new self(); }; } }',
'<?php class Foo { function bar() { function ($a = Foo::BAZ) { new Foo(); }; } }',
],
[
Expand Down
2 changes: 0 additions & 2 deletions tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php
Expand Up @@ -510,7 +510,6 @@ public function provideFixClassConstCases()
class foo
{
public const A = 1, B =2, C =3;
// As of PHP 5.6.0
public const TWO = ONE * 2;
public const THREE = ONE + self::TWO;
public const SENTENCE = "The value of THREE is ".self::THREE;
Expand All @@ -520,7 +519,6 @@ class foo
class foo
{
const A = 1, B =2, C =3;
// As of PHP 5.6.0
const TWO = ONE * 2;
const THREE = ONE + self::TWO;
const SENTENCE = "The value of THREE is ".self::THREE;
Expand Down
45 changes: 4 additions & 41 deletions tests/Fixer/ControlStructure/YodaStyleFixerTest.php
Expand Up @@ -585,6 +585,10 @@ function foo() {
'<?php $a = -/* bar */1 === reset($foo);',
'<?php $a = reset($foo) === -/* bar */1;',
],
[
'<?php $a **= 4 === $b ? 2 : 3;',
'<?php $a **= $b === 4 ? 2 : 3;',
],
];
}

Expand Down Expand Up @@ -691,47 +695,6 @@ public function testDefinition()
$this->assertInstanceOf(\PhpCsFixer\FixerDefinition\FixerDefinitionInterface::class, $this->fixer->getDefinition());
}

/**
* @param string $expected
* @param string $input
*
* @dataProvider providePHP56Cases
* @requires PHP 5.6
*/
public function testFixPHP56($expected, $input)
{
$this->fixer->configure(['equal' => true, 'identical' => true]);
$this->doTest($expected, $input);
}

/**
* Test with the inverse config.
*
* @param string $expected
* @param string $input
*
* @dataProvider providePHP56Cases
* @requires PHP 5.6
*/
public function testFixPHP56Inverse($expected, $input)
{
$this->fixer->configure(['equal' => false, 'identical' => false]);
$this->doTest($input, $expected);
}

/**
* @return array<string, string[]>
*/
public function providePHP56Cases()
{
return [
'5.6 Simple non-Yoda conditions that need to be fixed' => [
'<?php $a **= 4 === $b ? 2 : 3;',
'<?php $a **= $b === 4 ? 2 : 3;',
],
];
}

/**
* @param string $expected
* @param null|string $input
Expand Down
18 changes: 0 additions & 18 deletions tests/Fixer/Import/NoLeadingImportSlashFixerTest.php
Expand Up @@ -177,24 +177,6 @@ class Bar {
}
',
],
];
}

/**
* @param string $expected
* @param null|string $input
*
* @dataProvider provideFix56Cases
* @requires PHP 5.6
*/
public function testFix56($expected, $input = null)
{
$this->doTest($expected, $input);
}

public function provideFix56Cases()
{
return [
[
'<?php
use function a\b;
Expand Down
18 changes: 0 additions & 18 deletions tests/Fixer/Strict/StrictParamFixerTest.php
Expand Up @@ -128,24 +128,6 @@ public function provideFixCases()
'<?php
mb_detect_encoding($foo);',
],
];
}

/**
* @param string $expected
* @param null|string $input
*
* @dataProvider provideFix56Cases
* @requires PHP 5.6
*/
public function testFix56($expected, $input = null)
{
$this->doTest($expected, $input);
}

public function provideFix56Cases()
{
return [
[
'<?php
use function in_array;
Expand Down
2 changes: 0 additions & 2 deletions tests/Test/AbstractIntegrationTestCase.php
Expand Up @@ -48,8 +48,6 @@
* {"indent": " ", "lineEnding": "\n"}
* --SETTINGS--*
* {"key": "value"} # optional extension point for custom IntegrationTestCase class
* --REQUIREMENTS--*
* {"php": 50600**}
* --EXPECT--
* Expected code after fixing
* --INPUT--*
Expand Down
2 changes: 0 additions & 2 deletions tests/Tokenizer/TokensAnalyzerTest.php
Expand Up @@ -1039,7 +1039,6 @@ public function provideIsArrayCases()
2,
],
[
// short array PHP 5.4 single line
'<?php
["a" => 2];
',
Expand All @@ -1054,7 +1053,6 @@ public function provideIsArrayCases()
2, true,
],
[
// short array PHP 5.4 multi line
'<?php
[
"a" => 4
Expand Down