From ef0643e9be8185b03eeefffe9ef4e1890ae5a1a2 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sun, 6 Dec 2020 02:17:51 +0100 Subject: [PATCH] remove test dependency on DateTime changing api --- ...ngradeUnionTypeParamDeclarationRectorTest.php | 5 ++++- .../FixturePhp74/arrow_function.php.inc | 16 ++++++---------- .../Source/FullName.php | 10 ++++++++++ .../Source/SameNameMethod.php | 13 +++++++++++++ 4 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/Source/FullName.php create mode 100644 rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/Source/SameNameMethod.php diff --git a/rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeUnionTypeParamDeclarationRector/DowngradeUnionTypeParamDeclarationRectorTest.php b/rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeUnionTypeParamDeclarationRector/DowngradeUnionTypeParamDeclarationRectorTest.php index e886777eb473..38f7cf361fb3 100644 --- a/rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeUnionTypeParamDeclarationRector/DowngradeUnionTypeParamDeclarationRectorTest.php +++ b/rules/downgrade-php80/tests/Rector/FunctionLike/DowngradeUnionTypeParamDeclarationRector/DowngradeUnionTypeParamDeclarationRectorTest.php @@ -10,6 +10,9 @@ use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; +/** + * @requires PHP >= 8.0 + */ final class DowngradeUnionTypeParamDeclarationRectorTest extends AbstractRectorTestCase { /** @@ -32,6 +35,6 @@ protected function getRectorClass(): string protected function getPhpVersion(): int { - return PhpVersionFeature::UNION_TYPES - 1; + return PhpVersionFeature::UNION_TYPES; } } diff --git a/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/FixturePhp74/arrow_function.php.inc b/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/FixturePhp74/arrow_function.php.inc index 6c87a85ed415..deffdafd1920 100644 --- a/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/FixturePhp74/arrow_function.php.inc +++ b/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/FixturePhp74/arrow_function.php.inc @@ -2,15 +2,13 @@ namespace Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\FixturePhp74; -use DateTime; +use Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\Source\SameNameMethod; class ArrowFunction { - public function run() + public function run(SameNameMethod $sameNameMethod) { - $datetime = new DateTime(); - - $fn1 = fn($x) => $x + $stamp = $datetime->getTimezone(); + $fn1 = fn($x) => $x + $stamp = $sameNameMethod->getName(); } } @@ -20,15 +18,13 @@ class ArrowFunction namespace Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\FixturePhp74; -use DateTime; +use Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\Source\SameNameMethod; class ArrowFunction { - public function run() + public function run(SameNameMethod $sameNameMethod) { - $datetime = new DateTime(); - - $fn1 = fn($x) => $x + $dateTimeZone = $datetime->getTimezone(); + $fn1 = fn($x) => $x + $fullName = $sameNameMethod->getName(); } } diff --git a/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/Source/FullName.php b/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/Source/FullName.php new file mode 100644 index 000000000000..3d0b1a06dc2c --- /dev/null +++ b/rules/naming/tests/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector/Source/FullName.php @@ -0,0 +1,10 @@ +