From 35c9d4fbcb7f42a4e50d25fede960ad822b39e09 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 27 May 2024 19:22:04 +0900 Subject: [PATCH] apply modernized Rector config --- rector.php | 58 +++++++++---------- .../PublicClassMethodParamTypesCollector.php | 8 +-- .../MethodCallArgTypesCollector.php | 6 +- .../MethodCallableCollector.php | 5 +- src/NodeFinder/ClassMethodNodeFinder.php | 4 +- src/NodeFinder/MethodCallNodeFinder.php | 8 +-- src/NodeFinder/ReturnNodeFinder.php | 4 +- src/Printer/CollectorMetadataPrinter.php | 4 +- src/Printer/NodeComparator.php | 4 +- src/Rules/ForbiddenParamTypeRemovalRule.php | 4 +- .../NarrowPrivateClassMethodParamTypeRule.php | 11 ++-- .../NarrowPublicClassMethodParamTypeRule.php | 4 +- src/Rules/NoMixedMethodCallerRule.php | 6 +- src/Rules/NoMixedPropertyFetcherRule.php | 4 +- .../NoReturnFalseInNonBoolClassMethodRule.php | 6 +- ...uireSpecificReturnTypeOverAbstractRule.php | 6 +- src/ValueObject/MethodCallReference.php | 6 +- .../Fixture/RemoveParentType.php | 2 +- .../Fixture/SkipNoType.php | 2 +- .../Fixture/SkipPhpDocType.php | 2 +- .../Fixture/SkipPresentType.php | 2 +- .../Source/SomeRectorInterface.php | 2 +- .../DifferentClassSameMethodCallName.php | 4 +- .../Fixture/DoubleShot.php | 11 ++-- .../Fixture/Fixture.php | 6 +- .../Fixture/SkipAbstractBase.php | 8 +-- .../Fixture/SkipAlreadyCorrectType.php | 6 +- .../Fixture/SkipCorrectUnionType.php | 10 ++-- ...pDuplicatedCallOfSameMethodWithComment.php | 13 ++--- .../Fixture/SkipGenericType.php | 8 +-- .../Fixture/SkipMayOverrideArg.php | 6 +- .../Fixture/SkipMixed.php | 9 ++- .../Fixture/SkipMultipleUsed.php | 8 +-- .../Fixture/SkipNoArgs.php | 4 +- .../Fixture/SkipNotFromThis.php | 5 +- .../Fixture/SkipNotPrivate.php | 2 +- .../Fixture/SkipOptedOut.php | 7 ++- .../Fixture/SkipParentNotIf.php | 2 +- .../Fixture/SkipRecursive.php | 4 +- .../Source/AnotherClassWithRun.php | 2 +- .../FirstClassCallables/CallVariadics.php | 4 +- .../FirstClassCallables/SomeCalledMethod.php | 3 - .../Fixture/PublicDoubleShot.php | 3 - .../Fixture/SkipApiMarked.php | 8 --- .../Fixture/SkipClassStringPassed.php | 3 - .../Fixture/SkipEqualUnionType.php | 19 ------ .../Fixture/SkipExpectedClassType.php | 5 -- .../Fixture/SkipMixedAndString.php | 3 - .../Fixture/SkipNonPublicClassMethod.php | 6 +- .../Fixture/SkipNullableCompare.php | 5 -- .../Fixture/SkipProperlyFilledParamType.php | 3 - .../Fixture/SkipThisPassedExactType.php | 5 -- .../SkipUsedInternallyForSecondType.php | 4 +- .../Fixture/ThisPassedFromInterface.php | 5 -- .../ExpectedClassString/FirstTypedCaller.php | 2 +- .../ExpectedClassString/SecondTypedCaller.php | 2 +- .../FirstClassTypedCaller.php | 6 +- .../SecondClassTypedCaller.php | 6 +- .../CallByThisFromInterface.php | 4 +- .../Source/ExpectedType/FirstTypedCaller.php | 2 +- .../OnlyFirstTypeCalledOutside.php | 2 +- .../Source/ExpectedType/SecondTypedCaller.php | 2 +- .../ExpectedUnion/CallUnionArrayType.php | 4 +- .../Source/FirstCaller.php | 2 +- .../Source/MixedAndString/FirstCaller.php | 2 +- .../Source/MixedAndString/SecondCaller.php | 2 +- .../Source/MixedAndString/ThirdCaller.php | 2 +- .../Source/SecondCaller.php | 2 +- .../Fixture/ArrayAccessOnNestedObject.php | 4 +- .../Fixture/ArrayAccessOnObject.php | 4 +- .../Fixture/SkipIterator.php | 3 +- .../Fixture/SkipXml.php | 2 +- .../Fixture/SkipXmlElementForeach.php | 5 +- .../Fixture/IssetOnObject.php | 8 +-- .../Fixture/SkipIssetOnArray.php | 4 +- .../SkipIssetOnArrayNestedOnObject.php | 8 +-- .../Fixture/MagicMethodName.php | 2 +- .../Fixture/SkipKnownCallerType.php | 2 +- .../Fixture/SkipMockObject.php | 2 +- .../Fixture/UnknownCallerType.php | 2 +- .../Source/KnownType.php | 3 - .../Fixture/DynamicName.php | 2 +- .../Fixture/SkipDynamicNameWithKnownType.php | 6 -- .../Fixture/SkipKnownFetcherType.php | 6 -- .../Fixture/UnknownPropertyFetcher.php | 2 +- .../Fixture/ReturnFalseOnly.php | 2 +- .../Fixture/SkipReturnBool.php | 6 +- 87 files changed, 183 insertions(+), 279 deletions(-) diff --git a/rector.php b/rector.php index e68c64ff..4f8a599a 100644 --- a/rector.php +++ b/rector.php @@ -3,39 +3,35 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\Set\ValueObject\LevelSetList; -use Rector\Set\ValueObject\SetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - PHPUnitSetList::PHPUNIT_100, - SetList::CODE_QUALITY, - SetList::DEAD_CODE, - LevelSetList::UP_TO_PHP_81, - SetList::CODING_STYLE, - SetList::TYPE_DECLARATION, - SetList::NAMING, - SetList::PRIVATIZATION, - SetList::EARLY_RETURN, - PHPUnitSetList::PHPUNIT_CODE_QUALITY, - ]); - - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPhpSets() + ->withPreparedSets( + codeQuality: true, + deadCode: true, + codingStyle: true, + typeDeclarations: true, + privatization: true, + naming: true, + earlyReturn: true + ) + ->withPaths([ __DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests', - ]); - - $rectorConfig->importNames(); - - $rectorConfig->skip([ - '*/Source/*', - '*/Fixture/*', - ]); + ]) + ->withRootFiles() + ->withImportNames(removeUnusedImports: true); - $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [ - 'Symfony\Component\Console\*', - 'Rector\Contract\Rector\ConfigurableRectorInterface', - ]); -}; +// +// +// $rectorConfig->skip([ +// '*/Source/*', +// '*/Fixture/*', +// ]); +// +// $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [ +// 'Symfony\Component\Console\*', +// 'Rector\Contract\Rector\ConfigurableRectorInterface', +// ]); +//}; diff --git a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php index bfd6cbfc..6cc4e4e8 100644 --- a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php +++ b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php @@ -16,12 +16,12 @@ /** * @implements Collector */ -final class PublicClassMethodParamTypesCollector implements Collector +final readonly class PublicClassMethodParamTypesCollector implements Collector { public function __construct( - private readonly ApiDocStmtAnalyzer $apiDocStmtAnalyzer, - private readonly PublicClassMethodMatcher $publicClassMethodMatcher, - private readonly CollectorMetadataPrinter $collectorMetadataPrinter + private ApiDocStmtAnalyzer $apiDocStmtAnalyzer, + private PublicClassMethodMatcher $publicClassMethodMatcher, + private CollectorMetadataPrinter $collectorMetadataPrinter ) { } diff --git a/src/Collector/MethodCall/MethodCallArgTypesCollector.php b/src/Collector/MethodCall/MethodCallArgTypesCollector.php index d5a7d12c..d334337d 100644 --- a/src/Collector/MethodCall/MethodCallArgTypesCollector.php +++ b/src/Collector/MethodCall/MethodCallArgTypesCollector.php @@ -15,11 +15,11 @@ /** * @implements Collector|null> */ -final class MethodCallArgTypesCollector implements Collector +final readonly class MethodCallArgTypesCollector implements Collector { public function __construct( - private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - private readonly CollectorMetadataPrinter $collectorMetadataPrinter, + private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, + private CollectorMetadataPrinter $collectorMetadataPrinter, ) { } diff --git a/src/Collector/MethodCallableNode/MethodCallableCollector.php b/src/Collector/MethodCallableNode/MethodCallableCollector.php index 667324be..6d00cdd6 100644 --- a/src/Collector/MethodCallableNode/MethodCallableCollector.php +++ b/src/Collector/MethodCallableNode/MethodCallableCollector.php @@ -5,7 +5,6 @@ namespace Rector\TypePerfect\Collector\MethodCallableNode; use PhpParser\Node; -use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Collectors\Collector; use PHPStan\Node\MethodCallableNode; @@ -19,10 +18,10 @@ * * @see https://github.com/phpstan/phpstan-src/blob/511c1e435fb43b8eb0ac310e6aa3230147963790/src/Analyser/NodeScopeResolver.php#L1936 */ -final class MethodCallableCollector implements Collector +final readonly class MethodCallableCollector implements Collector { public function __construct( - private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, + private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, ) { } diff --git a/src/NodeFinder/ClassMethodNodeFinder.php b/src/NodeFinder/ClassMethodNodeFinder.php index d1b19459..6f45c4cb 100644 --- a/src/NodeFinder/ClassMethodNodeFinder.php +++ b/src/NodeFinder/ClassMethodNodeFinder.php @@ -12,10 +12,10 @@ use PHPStan\Reflection\ClassReflection; use Rector\TypePerfect\Reflection\ReflectionParser; -final class ClassMethodNodeFinder +final readonly class ClassMethodNodeFinder { public function __construct( - private readonly ReflectionParser $reflectionParser, + private ReflectionParser $reflectionParser, ) { } diff --git a/src/NodeFinder/MethodCallNodeFinder.php b/src/NodeFinder/MethodCallNodeFinder.php index 23fd9c68..040c1c51 100644 --- a/src/NodeFinder/MethodCallNodeFinder.php +++ b/src/NodeFinder/MethodCallNodeFinder.php @@ -14,13 +14,13 @@ use Rector\TypePerfect\Reflection\ReflectionParser; use Webmozart\Assert\Assert; -final class MethodCallNodeFinder +final readonly class MethodCallNodeFinder { - private readonly NodeFinder $nodeFinder; + private NodeFinder $nodeFinder; public function __construct( - private readonly ReflectionParser $reflectionParser, - private readonly NodeComparator $nodeComparator, + private ReflectionParser $reflectionParser, + private NodeComparator $nodeComparator, ) { $this->nodeFinder = new NodeFinder(); } diff --git a/src/NodeFinder/ReturnNodeFinder.php b/src/NodeFinder/ReturnNodeFinder.php index 88594551..f888858c 100644 --- a/src/NodeFinder/ReturnNodeFinder.php +++ b/src/NodeFinder/ReturnNodeFinder.php @@ -12,10 +12,10 @@ use PhpParser\NodeTraverser; use Rector\TypePerfect\NodeTraverser\SimpleCallableNodeTraverser; -final class ReturnNodeFinder +final readonly class ReturnNodeFinder { public function __construct( - private readonly SimpleCallableNodeTraverser $simpleCallableNodeTraverser + private SimpleCallableNodeTraverser $simpleCallableNodeTraverser ) { } diff --git a/src/Printer/CollectorMetadataPrinter.php b/src/Printer/CollectorMetadataPrinter.php index 5dab9d65..38915f8c 100644 --- a/src/Printer/CollectorMetadataPrinter.php +++ b/src/Printer/CollectorMetadataPrinter.php @@ -26,9 +26,9 @@ use PHPStan\Type\VerbosityLevel; use Rector\TypePerfect\Enum\Types\ResolvedTypes; -final class CollectorMetadataPrinter +final readonly class CollectorMetadataPrinter { - private readonly Standard $printerStandard; + private Standard $printerStandard; public function __construct() { diff --git a/src/Printer/NodeComparator.php b/src/Printer/NodeComparator.php index f5cbabd5..c8cbc7fe 100644 --- a/src/Printer/NodeComparator.php +++ b/src/Printer/NodeComparator.php @@ -7,10 +7,10 @@ use PhpParser\Node; use PhpParser\PrettyPrinter\Standard; -final class NodeComparator +final readonly class NodeComparator { public function __construct( - private readonly Standard $standard + private Standard $standard ) { } diff --git a/src/Rules/ForbiddenParamTypeRemovalRule.php b/src/Rules/ForbiddenParamTypeRemovalRule.php index 5f31a286..ff939ec5 100644 --- a/src/Rules/ForbiddenParamTypeRemovalRule.php +++ b/src/Rules/ForbiddenParamTypeRemovalRule.php @@ -17,7 +17,7 @@ * @see \Rector\TypePerfect\Tests\Rules\ForbiddenParamTypeRemovalRule\ForbiddenParamTypeRemovalRuleTest * @implements Rule */ -final class ForbiddenParamTypeRemovalRule implements Rule +final readonly class ForbiddenParamTypeRemovalRule implements Rule { /** * @var string @@ -25,7 +25,7 @@ final class ForbiddenParamTypeRemovalRule implements Rule public const ERROR_MESSAGE = 'Removing parent param type is forbidden'; public function __construct( - private readonly MethodNodeAnalyser $methodNodeAnalyser + private MethodNodeAnalyser $methodNodeAnalyser ) { } diff --git a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php index 1f9d2c94..6f7a7e77 100644 --- a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php @@ -21,7 +21,6 @@ use PHPStan\Type\IntersectionType; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; -use PHPStan\Type\Type; use PHPStan\Type\UnionType; use PHPStan\Type\VerbosityLevel; use Rector\TypePerfect\Configuration; @@ -32,7 +31,7 @@ * @see \Rector\TypePerfect\Tests\Rules\CheckTypehintCallerTypeRule\CheckTypehintCallerTypeRuleTest * @implements Rule */ -final class NarrowPrivateClassMethodParamTypeRule implements Rule +final readonly class NarrowPrivateClassMethodParamTypeRule implements Rule { /** * @var string @@ -40,9 +39,9 @@ final class NarrowPrivateClassMethodParamTypeRule implements Rule public const ERROR_MESSAGE = 'Parameter %d should use "%s" type as the only type passed to this method'; public function __construct( - private readonly Configuration $configuration, - private readonly MethodCallNodeFinder $methodCallNodeFinder, - private readonly ClassMethodNodeFinder $classMethodNodeFinder + private Configuration $configuration, + private MethodCallNodeFinder $methodCallNodeFinder, + private ClassMethodNodeFinder $classMethodNodeFinder ) { } @@ -116,7 +115,7 @@ private function validateArgVsParamTypes(array $args, MethodCall $methodCall, Sc } $paramRuleError = $this->validateParam($param, $position, $arg->value, $scope); - if ($paramRuleError === null) { + if (! $paramRuleError instanceof RuleError) { continue; } diff --git a/src/Rules/NarrowPublicClassMethodParamTypeRule.php b/src/Rules/NarrowPublicClassMethodParamTypeRule.php index 34b88972..c80d00cc 100644 --- a/src/Rules/NarrowPublicClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPublicClassMethodParamTypeRule.php @@ -22,7 +22,7 @@ * * @implements Rule */ -final class NarrowPublicClassMethodParamTypeRule implements Rule +final readonly class NarrowPublicClassMethodParamTypeRule implements Rule { /** * @var string @@ -30,7 +30,7 @@ final class NarrowPublicClassMethodParamTypeRule implements Rule public const ERROR_MESSAGE = 'Parameters should have "%s" types as the only types passed to this method'; public function __construct( - private readonly Configuration $configuration + private Configuration $configuration ) { } diff --git a/src/Rules/NoMixedMethodCallerRule.php b/src/Rules/NoMixedMethodCallerRule.php index f235a00a..8e16fde2 100644 --- a/src/Rules/NoMixedMethodCallerRule.php +++ b/src/Rules/NoMixedMethodCallerRule.php @@ -17,7 +17,7 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedMethodCallerRule\NoMixedMethodCallerRuleTest * @implements Rule */ -final class NoMixedMethodCallerRule implements Rule +final readonly class NoMixedMethodCallerRule implements Rule { /** * @var string @@ -25,8 +25,8 @@ final class NoMixedMethodCallerRule implements Rule public const ERROR_MESSAGE = 'Mixed variable in a `%s->...()` can skip important errors. Make sure the type is known'; public function __construct( - private readonly Standard $printerStandard, - private readonly Configuration $configuration, + private Standard $printerStandard, + private Configuration $configuration, ) { } diff --git a/src/Rules/NoMixedPropertyFetcherRule.php b/src/Rules/NoMixedPropertyFetcherRule.php index 8d3301db..5c8c23e2 100644 --- a/src/Rules/NoMixedPropertyFetcherRule.php +++ b/src/Rules/NoMixedPropertyFetcherRule.php @@ -15,7 +15,7 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\NoMixedPropertyFetcherRuleTest * @implements Rule */ -final class NoMixedPropertyFetcherRule implements Rule +final readonly class NoMixedPropertyFetcherRule implements Rule { /** * @var string @@ -23,7 +23,7 @@ final class NoMixedPropertyFetcherRule implements Rule public const ERROR_MESSAGE = 'Mixed property fetch in a "%s->..." can skip important errors. Make sure the type is known'; public function __construct( - private readonly Standard $standard, + private Standard $standard, ) { } diff --git a/src/Rules/NoReturnFalseInNonBoolClassMethodRule.php b/src/Rules/NoReturnFalseInNonBoolClassMethodRule.php index 1e8660c3..ef8db8ff 100644 --- a/src/Rules/NoReturnFalseInNonBoolClassMethodRule.php +++ b/src/Rules/NoReturnFalseInNonBoolClassMethodRule.php @@ -17,7 +17,7 @@ /** * @implements Rule */ -final class NoReturnFalseInNonBoolClassMethodRule implements Rule +final readonly class NoReturnFalseInNonBoolClassMethodRule implements Rule { /** * @api @@ -25,10 +25,10 @@ final class NoReturnFalseInNonBoolClassMethodRule implements Rule */ public const ERROR_MESSAGE = 'Returning false in non return bool class method. Use null with type|null instead or add bool return type'; - private readonly NodeFinder $nodeFinder; + private NodeFinder $nodeFinder; public function __construct( - private readonly Configuration $configuration, + private Configuration $configuration, ) { $this->nodeFinder = new NodeFinder(); } diff --git a/src/Rules/RequireSpecificReturnTypeOverAbstractRule.php b/src/Rules/RequireSpecificReturnTypeOverAbstractRule.php index 2a2fc7d9..c6e2db85 100644 --- a/src/Rules/RequireSpecificReturnTypeOverAbstractRule.php +++ b/src/Rules/RequireSpecificReturnTypeOverAbstractRule.php @@ -22,7 +22,7 @@ * * @implements Rule */ -final class RequireSpecificReturnTypeOverAbstractRule implements Rule +final readonly class RequireSpecificReturnTypeOverAbstractRule implements Rule { /** * @var string @@ -30,8 +30,8 @@ final class RequireSpecificReturnTypeOverAbstractRule implements Rule public const ERROR_MESSAGE = 'Provide more specific return type "%s" over abstract one'; public function __construct( - private readonly ReturnNodeFinder $returnNodeFinder, - private readonly MethodNodeAnalyser $methodNodeAnalyser, + private ReturnNodeFinder $returnNodeFinder, + private MethodNodeAnalyser $methodNodeAnalyser, ) { } diff --git a/src/ValueObject/MethodCallReference.php b/src/ValueObject/MethodCallReference.php index bb454c16..9224546b 100644 --- a/src/ValueObject/MethodCallReference.php +++ b/src/ValueObject/MethodCallReference.php @@ -4,11 +4,11 @@ namespace Rector\TypePerfect\ValueObject; -final class MethodCallReference +final readonly class MethodCallReference { public function __construct( - private readonly string $class, - private readonly string $method + private string $class, + private string $method ) { } diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/RemoveParentType.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/RemoveParentType.php index ebb25795..4d8b0e60 100644 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/RemoveParentType.php +++ b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/RemoveParentType.php @@ -8,7 +8,7 @@ final class RemoveParentType implements SomeRectorInterface { - public function refactor($node) + public function refactor($node): void { } } diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipNoType.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipNoType.php index 036cd261..9ce69672 100644 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipNoType.php +++ b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipNoType.php @@ -8,7 +8,7 @@ final class SkipNoType implements NoTypeInterface { - public function noType($node) + public function noType($node): void { } } diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPhpDocType.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPhpDocType.php index e1d2f52a..6e8c4f5e 100644 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPhpDocType.php +++ b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPhpDocType.php @@ -11,7 +11,7 @@ final class SkipPhpDocType extends PhpDocType /** * @param string|null $node */ - public function justPhpDocType($node = null) + public function justPhpDocType($node = null): void { } } diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPresentType.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPresentType.php index 3193a2c1..a43beb30 100644 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPresentType.php +++ b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/SkipPresentType.php @@ -9,7 +9,7 @@ final class SkipPresentType implements SomeRectorInterface { - public function refactor(SomeNode $node) + public function refactor(SomeNode $someNode): void { } } diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Source/SomeRectorInterface.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Source/SomeRectorInterface.php index 5584a4a8..a3663adf 100644 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Source/SomeRectorInterface.php +++ b/tests/Rules/ForbiddenParamTypeRemovalRule/Source/SomeRectorInterface.php @@ -6,5 +6,5 @@ interface SomeRectorInterface { - public function refactor(SomeNode $node); + public function refactor(SomeNode $someNode); } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php index 31c25875..940448a1 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php @@ -14,7 +14,7 @@ class DifferentClassSameMethodCallName /** * @param SomeStaticCall|MethodCall $node */ - public function process(AnotherClassWithRun $anotherClassWithRun) + public function process(AnotherClassWithRun $anotherClassWithRun): void { $anotherClassWithRun->run($anotherClassWithRun); } @@ -22,7 +22,7 @@ public function process(AnotherClassWithRun $anotherClassWithRun) /** * @param SomeStaticCall|MethodCall $node */ - private function run(Node $node) + private function run(Node $node): void { if ($node->name instanceof MethodCall) { $this->run($node->name); diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php index a9a8d499..9886b682 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php @@ -4,15 +4,16 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; -use PhpParser\Node; - +use PhpParser\Node\Arg; +use PhpParser\Node\Param; class DoubleShot { - public function run(Node\Arg $arg, Node\Param $param) + public function run(Arg $arg, Param $param): void { - $this->isCheck($arg, $param); + $this->isCheck(); } - private function isCheck(\PhpParser\Node $arg, \PhpParser\Node $param) + + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php index 68bd53cc..0c818476 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php @@ -9,14 +9,14 @@ class Fixture { - public function run(Node $node) + public function run(Node $node): void { if ($node instanceof MethodCall) { - $this->isCheck($node); + $this->isCheck(); } } - private function isCheck(Node $node) + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php index ecafcfb7..00ad0b59 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php @@ -2,15 +2,15 @@ namespace SkipAbstractBase; -use Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Source\ConceptBase; use Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Source\ConceptImpl1; class MyService { - public function run(ConceptImpl1 $arg) + public function run(ConceptImpl1 $conceptImpl1): void { - $this->isCheck($arg); + $this->isCheck(); } - private function isCheck(ConceptBase $arg) + + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php index f74f3dd6..39903474 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php @@ -9,14 +9,14 @@ class SkipAlreadyCorrectType { - public function run(Node $node) + public function run(Node $node): void { if ($node instanceof MethodCall) { - $this->isCheck($node); + $this->isCheck(); } } - private function isCheck(MethodCall $node) + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php index 9480df8a..aa887228 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php @@ -4,28 +4,26 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; +use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Stmt\Return_; final class SkipCorrectUnionType { - public function run(\PhpParser\Node $node) + public function run(Node $node): array { if (! $node instanceof Assign && ! $node instanceof Return_) { return []; } - if (! $this->isIncludeOnceOrRequireOnce($node)) { + if (! $this->isIncludeOnceOrRequireOnce()) { return []; } return []; } - /** - * @param Assign|Return_ $node - */ - private function isIncludeOnceOrRequireOnce(\PhpParser\Node $node) + private function isIncludeOnceOrRequireOnce(): bool { return true; } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php index 632fc7de..a852c63d 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php @@ -4,23 +4,20 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; -use PHPStan\Node\FileNode; -use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; - final class SkipDuplicatedCallOfSameMethodWithComment2 { - public function firstMethod() + public function firstMethod(): void { - $this->printFile(new FileWithoutNamespace([])); + $this->printFile(); } - private function printFile(\PhpParser\Node $node) + private function printFile(): void { } - public function secondMethod() + public function secondMethod(): void { // some comment - $this->printFile(new FileNode([])); + $this->printFile(); } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php index e62b5097..a58c4e5b 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php @@ -14,18 +14,16 @@ class SkipGenericType { /** * @param T $node - * @return void */ - public function run(Node $node) + public function run(Node $node): void { - $this->getsAGeneric($node); + $this->getsAGeneric(); } /** - * @param T $node * @return void */ - private function getsAGeneric(Node $node) + private function getsAGeneric() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php index b2658cd3..293364a3 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php @@ -9,19 +9,19 @@ class SkipMayOverrideArg { - public function run(Node $node) + public function run(Node $node): void { if ($node instanceof MethodCall) { // on this part, $node may be overriden $node = $this->mayOverrideNode(); - $this->isCheck($node); + $this->isCheck(); } } - private function isCheck(Node $node) + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php index 66a104e1..ed2f9d92 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php @@ -4,15 +4,14 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; -use PhpParser\Node; - class SkipMixed { - public function run($arg) + public function run($arg): void { - $this->isCheck($arg); + $this->isCheck(); } - private function isCheck(\PhpParser\Node $arg) + + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php index 1919ec98..69d7baa7 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php @@ -10,18 +10,18 @@ class SkipMultipleUsed { - public function run(Node $node) + public function run(Node $node): void { if ($node instanceof MethodCall) { - $this->isCheck($node); + $this->isCheck(); } if ($node instanceof PropertyFetch) { - $this->isCheck($node); + $this->isCheck(); } } - private function isCheck(Node $node) + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php index 90094439..f6e62bfc 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php @@ -4,11 +4,9 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; -use PhpParser\Node; - final class SkipNoArgs { - public function run() + public function run(): void { $this->execute(); } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php index 65436953..a0e39ede 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php @@ -4,11 +4,12 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; +use DateTime; final class SkipNotFromThis { - public function run() + public function run(): void { - $obj = new \DateTime('now'); + $obj = new DateTime('now'); $obj->format('Y-m-d'); } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php index a16c0ad1..8cb6bd76 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php @@ -9,7 +9,7 @@ class SkipNotPrivate { - public function run(Node $node) + public function run(Node $node): void { if ($node instanceof MethodCall) { $this->isCheckNotPrivate($node); diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php index a74a81b1..ffb74948 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php @@ -4,20 +4,21 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture; +use PHPStan\Type\Type; use PHPStan\Type\MixedType; class SkipOptedOut { - public function run(\PHPStan\Type\Type $type) + public function run(Type $type): void { if ($type instanceof MixedType) { return; } - $this->isCheck($type); + $this->isCheck(); } - private function isCheck(\PHPStan\Type\Type $type) + private function isCheck() { } } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php index 04a51b74..cc8b7c23 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php @@ -8,7 +8,7 @@ final class SkipParentNotIf { - public function run(Node $node) + public function run(Node $node): void { $this->execute($node); } diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php index b0984640..7ebbdc60 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php @@ -13,7 +13,7 @@ class SkipRecursive /** * @param SomeStaticCall|MethodCall $node */ - public function processNode(Node $node) + public function processNode(Node $node): void { $this->run($node); } @@ -21,7 +21,7 @@ public function processNode(Node $node) /** * @param SomeStaticCall|MethodCall $node */ - private function run(Node $node) + private function run(Node $node): void { if ($node->name instanceof MethodCall) { $this->run($node->name); diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php index 0b3ba332..4c214f84 100644 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php +++ b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php @@ -8,7 +8,7 @@ final class AnotherClassWithRun { - public function run(Node $node) + public function run(Node $node): Node { return $node; } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/CallVariadics.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/CallVariadics.php index 4d01cddc..c9762cc0 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/CallVariadics.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/CallVariadics.php @@ -6,9 +6,9 @@ final class CallVariadics { - public function callMe(SomeCalledMethod $someCalledMethod) + public function callMe(SomeCalledMethod $someCalledMethod): void { - $closure = $someCalledMethod->callMe(...); + $someCalledMethod->callMe(...); $someCalledMethod->callMe(1000); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php index 3b1da8cc..aeacb1c0 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php @@ -6,7 +6,4 @@ final class SomeCalledMethod { - public function callMe($number) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php index b156afb1..7ee91062 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php @@ -6,7 +6,4 @@ final class PublicDoubleShot { - public function callMeTwice($number) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipApiMarked.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipApiMarked.php index 65aa7c94..ecbfc657 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipApiMarked.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipApiMarked.php @@ -4,14 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use PhpParser\Node; - final class SkipApiMarked { - /** - * @api - */ - public function callNode(Node $node) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php index 3efc7162..c085d495 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php @@ -6,7 +6,4 @@ final class SkipClassStringPassed { - public function resolve(string $className) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php index 7c6cb87e..e6aef9e1 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php @@ -4,16 +4,11 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; final class SkipEqualUnionType { - public function run(MethodCall|StaticCall $obj) - { - } - public function runTernary(StaticCall|MethodCall $obj) { return $obj instanceof StaticCall @@ -27,18 +22,4 @@ public function runTernaryFlipped(StaticCall|MethodCall $obj) ? $obj->var : $obj->class; } - - /** - * @param Node[]|Node $node - */ - public function runArrayTyped(array | Node $node) - { - } - - /** - * @param array|Node $node - */ - public function runArrayTyped2(array | Node $node) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php index 1c722337..f052474c 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php @@ -4,11 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Source\PassMeAsType; - final class SkipExpectedClassType { - public function callMeWithClassType(PassMeAsType $passMeAsType) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipMixedAndString.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipMixedAndString.php index b87acbf2..644921ab 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipMixedAndString.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipMixedAndString.php @@ -6,7 +6,4 @@ final class SkipMixedAndString { - public function resolve($value) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNonPublicClassMethod.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNonPublicClassMethod.php index 9d7873ff..50355d57 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNonPublicClassMethod.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNonPublicClassMethod.php @@ -6,12 +6,12 @@ final class SkipNonPublicClassMethod { - public function personInTree() + public function personInTree(): void { - $this->callMe(1000); + $this->callMe(); } - private function callMe($number) + private function callMe(): void { } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php index 70f5b1a7..001254ca 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php @@ -4,11 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use PhpParser\Node; - final class SkipNullableCompare { - public function callNode(?Node $node) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipProperlyFilledParamType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipProperlyFilledParamType.php index a0079d97..150d986d 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipProperlyFilledParamType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipProperlyFilledParamType.php @@ -6,7 +6,4 @@ final class SkipProperlyFilledParamType { - public function callMeTwice(int $number) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php index c7670e11..9c74d046 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php @@ -4,11 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Source\ExpectedThisType\CallByThis; - final class SkipThisPassedExactType { - public function run(CallByThis $obj) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipUsedInternallyForSecondType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipUsedInternallyForSecondType.php index 910391e3..6bd2b189 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipUsedInternallyForSecondType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipUsedInternallyForSecondType.php @@ -9,11 +9,11 @@ final class SkipUsedInternallyForSecondType { - public function run(stdClass|DateTime $obj) + public function run(stdClass|DateTime $obj): void { } - public function execute() + public function execute(): void { $this->run(new DateTime('now')); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php index df4f8ebc..13b98779 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php @@ -4,11 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -use Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Source\SomeInterface; - final class ThisPassedFromInterface { - public function run(SomeInterface $obj) - { - } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php index 35c8ce08..9bfce6c7 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php @@ -9,7 +9,7 @@ final class FirstTypedCaller { - public function run(ClassReflection $classReflection) + public function run(ClassReflection $classReflection): void { $skipClassStringPassed = new SkipClassStringPassed(); $skipClassStringPassed->resolve($classReflection->getName()); diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php index 4d4815ab..57a16f3a 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php @@ -9,7 +9,7 @@ final class SecondTypedCaller { - public function run(ClassReflection $classReflection) + public function run(ClassReflection $classReflection): void { $skipClassStringPassed = new SkipClassStringPassed(); $skipClassStringPassed->resolve($classReflection->getName()); diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php index 8ad53ce6..5ae7ec32 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php @@ -9,9 +9,9 @@ final class FirstClassTypedCaller { - public function goForIt(SkipExpectedClassType $skipExpectedClassType) + public function goForIt(SkipExpectedClassType $skipExpectedClassType): void { - $knownType = new PassMeAsType(); - $skipExpectedClassType->callMeWithClassType($knownType); + $passMeAsType = new PassMeAsType(); + $skipExpectedClassType->callMeWithClassType($passMeAsType); } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php index 222edca0..fd281caf 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php @@ -9,9 +9,9 @@ final class SecondClassTypedCaller { - public function goForIt(SkipExpectedClassType $skipExpectedClassType) + public function goForIt(SkipExpectedClassType $skipExpectedClassType): void { - $knownType = new PassMeAsType(); - $skipExpectedClassType->callMeWithClassType($knownType); + $passMeAsType = new PassMeAsType(); + $skipExpectedClassType->callMeWithClassType($passMeAsType); } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php index eb90be0c..8a28eabb 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php @@ -9,8 +9,8 @@ final class CallByThisFromInterface implements SomeInterface { - public function run(ThisPassedFromInterface $thisPassedFromInterface): void + public function run(ThisPassedFromInterface $thisPassedFrom): void { - $thisPassedFromInterface->run($this); + $thisPassedFrom->run($this); } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php index 9eacb9d4..e248722b 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php @@ -8,7 +8,7 @@ final class FirstTypedCaller { - public function goForIt(SkipProperlyFilledParamType $skipProperlyFilledParamType) + public function goForIt(SkipProperlyFilledParamType $skipProperlyFilledParamType): void { $skipProperlyFilledParamType->callMeTwice(100); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php index a3e116a3..2964437f 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php @@ -9,7 +9,7 @@ final class OnlyFirstTypeCalledOutside { - public function run(SkipUsedInternallyForSecondType $skipUsedInternallyForSecondType) + public function run(SkipUsedInternallyForSecondType $skipUsedInternallyForSecondType): void { $skipUsedInternallyForSecondType->run(new stdClass()); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php index cc0e2dfe..9a2e29b6 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php @@ -8,7 +8,7 @@ final class SecondTypedCaller { - public function goForIt(SkipProperlyFilledParamType $skipProperlyFilledParamType) + public function goForIt(SkipProperlyFilledParamType $skipProperlyFilledParamType): void { $skipProperlyFilledParamType->callMeTwice(100); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php index 813720b1..0476fa92 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php @@ -12,7 +12,7 @@ final class CallUnionTypeArrayType public function run(SkipEqualUnionType $skipEqualUnionType, Node $node): void { /** @var Node[]|Node $node */ - $node = rand(0, 1) + $node = random_int(0, 1) !== 0 ? $node : [$node]; @@ -22,7 +22,7 @@ public function run(SkipEqualUnionType $skipEqualUnionType, Node $node): void public function run2(SkipEqualUnionType $skipEqualUnionType, Node $node): void { /** @var Node[]|Node $node */ - $node = rand(0, 1) + $node = random_int(0, 1) !== 0 ? $node : [$node]; diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php index 81565e00..70559a7a 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php @@ -8,7 +8,7 @@ final class FirstCaller { - public function goForIt(PublicDoubleShot $publicDoubleShot) + public function goForIt(PublicDoubleShot $publicDoubleShot): void { $publicDoubleShot->callMeTwice(100); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php index abf52f56..70fa8670 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php @@ -8,7 +8,7 @@ final class FirstCaller { - public function run(SkipMixedAndString $skipMixedAndString) + public function run(SkipMixedAndString $skipMixedAndString): void { $skipMixedAndString->resolve('string'); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php index c087c8d7..adc86362 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php @@ -8,7 +8,7 @@ final class SecondCaller { - public function run(SkipMixedAndString $skipMixedAndString, $mixedValue) + public function run(SkipMixedAndString $skipMixedAndString, $mixedValue): void { $skipMixedAndString->resolve($mixedValue); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php index 532bda8b..336a51a6 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php @@ -8,7 +8,7 @@ final class SecondCaller { - public function run(SkipMixedAndString $skipMixedAndString) + public function run(SkipMixedAndString $skipMixedAndString): void { $skipMixedAndString->resolve(1000); } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SecondCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SecondCaller.php index 577fa7dc..f45a43e5 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SecondCaller.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SecondCaller.php @@ -8,7 +8,7 @@ final class SecondCaller { - public function goForIt(PublicDoubleShot $publicDoubleShot) + public function goForIt(PublicDoubleShot $publicDoubleShot): void { $publicDoubleShot->callMeTwice(100); } diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php index 7145d2fa..de25b1b2 100644 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php +++ b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php @@ -10,7 +10,7 @@ final class ArrayAccessOnNestedObject { public function run() { - $someClassWithArrayAcces = new ChildOfSomeClassWithArrayAccess(); - return $someClassWithArrayAcces['key']; + $childOfSomeClassWithArrayAccess = new ChildOfSomeClassWithArrayAccess(); + return $childOfSomeClassWithArrayAccess['key']; } } diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnObject.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnObject.php index 62cf5c58..a9cfa2a5 100644 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnObject.php +++ b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnObject.php @@ -10,7 +10,7 @@ final class ArrayAccessOnObject { public function run() { - $someClassWithArrayAcces = new SomeClassWithArrayAccess(); - return $someClassWithArrayAcces['key']; + $someClassWithArrayAccess = new SomeClassWithArrayAccess(); + return $someClassWithArrayAccess['key']; } } diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipIterator.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipIterator.php index 8e349448..3d9b9576 100644 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipIterator.php +++ b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipIterator.php @@ -4,11 +4,12 @@ namespace Rector\TypePerfect\Tests\Rules\NoArrayAccessOnObjectRule\Fixture; +use Iterator; final class SkipIterator { public function run() { - $iterator = new class extends \Iterator {}; + $iterator = new class extends Iterator {}; return $iterator[0]; } diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXml.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXml.php index b6e85c75..d6a6649a 100644 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXml.php +++ b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXml.php @@ -8,7 +8,7 @@ final class SkipXml { - public function run(SimpleXMLElement $values) + public function run(SimpleXMLElement $values): ?SimpleXMLElement { return $values['key']; } diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXmlElementForeach.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXmlElementForeach.php index d93668bf..989842a4 100644 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXmlElementForeach.php +++ b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXmlElementForeach.php @@ -8,10 +8,11 @@ final class SkipXmlElementForeach { - public function run(SimpleXMLElement $simpleXMLElement) + public function run(SimpleXMLElement $simpleXMLElement): ?bool { - foreach ($simpleXMLElement->children() as $name => $childElement) { + foreach ($simpleXMLElement->children() as $childElement) { return isset($childElement['some']); } + return null; } } diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php b/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php index 7eab7594..09062ffb 100644 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php +++ b/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php @@ -8,14 +8,12 @@ final class IssetOnObject { - public function run() + public function run(): ?stdClass { - if (mt_rand(0, 100)) { + if (mt_rand(0, 100) !== 0) { $object = new stdClass(); } - if (isset($object)) { - return $object; - } + return $object ?? null; } } diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArray.php b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArray.php index dd5e83ca..7cdc8c48 100644 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArray.php +++ b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArray.php @@ -8,8 +8,6 @@ final class SkipIssetOnArray { public function run(array $values) { - if (isset($values[9])) { - return $values[9]; - } + return $values[9] ?? null; } } diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArrayNestedOnObject.php b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArrayNestedOnObject.php index 8204a8a0..a45aed04 100644 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArrayNestedOnObject.php +++ b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArrayNestedOnObject.php @@ -4,14 +4,14 @@ namespace Rector\TypePerfect\Tests\Rules\NoIssetOnObjectRule\Fixture; +use PhpParser\Node\Arg; +use PhpParser\Node\VariadicPlaceholder; use PhpParser\Node\Expr\MethodCall; final class SkipIssetOnArrayNestedOnObject { - public function run(MethodCall $methodCall) + public function run(MethodCall $methodCall): Arg|VariadicPlaceholder|null { - if (isset($methodCall->args[9])) { - return $methodCall->args[9]; - } + return $methodCall->args[9] ?? null; } } diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php index 24634dca..13c90619 100644 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php +++ b/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php @@ -6,7 +6,7 @@ final class MagicMethodName { - public function run($someType, $magic) + public function run($someType, $magic): void { $someType->$magic(); } diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php index 297d2526..31d72a08 100644 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php +++ b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php @@ -8,7 +8,7 @@ final class SkipKnownCallerType { - public function run(KnownType $knownType) + public function run(KnownType $knownType): void { $knownType->call(); } diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php index 58168a73..ec5a064c 100644 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php +++ b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php @@ -8,7 +8,7 @@ final class SkipMockObject extends TestCase { - public function test() + public function test(): void { $mock = $this->createMock(MagicMethodName::class); diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php index 5a01e193..9ef0d76a 100644 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php +++ b/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php @@ -6,7 +6,7 @@ final class UnknownCallerType { - public function run($mixedType) + public function run($mixedType): void { $mixedType->call(); } diff --git a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php b/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php index 75536c75..6699a093 100644 --- a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php +++ b/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php @@ -6,7 +6,4 @@ final class KnownType { - public function call() - { - } } diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/DynamicName.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/DynamicName.php index 2e460975..1964a071 100644 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/DynamicName.php +++ b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/DynamicName.php @@ -6,7 +6,7 @@ final class DynamicName { - public function run($unknownType) + public function run($unknownType): void { $unknownType->{$name}; } diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php index c3812a18..390adcd7 100644 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php +++ b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php @@ -4,12 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\Fixture; -use Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\Source\KnownType; - final class SkipDynamicNameWithKnownType { - public function runOnType(KnownType $knownType) - { - $knownType->{$name}; - } } diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php index 48ec8acc..70ca0593 100644 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php +++ b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php @@ -4,12 +4,6 @@ namespace Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\Fixture; -use Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\Source\KnownType; - final class SkipKnownFetcherType { - public function run(KnownType $knownType) - { - $knownType->name; - } } diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php index ef906f07..b9ebf8e6 100644 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php +++ b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php @@ -6,7 +6,7 @@ final class UnknownPropertyFetcher { - public function run($unknownType) + public function run($unknownType): void { $unknownType->name; } diff --git a/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/ReturnFalseOnly.php b/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/ReturnFalseOnly.php index 734de54a..10fab8b4 100644 --- a/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/ReturnFalseOnly.php +++ b/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/ReturnFalseOnly.php @@ -6,7 +6,7 @@ final class ReturnFalseOnly { - public function run() + public function run(): int|false { if (mt_rand(1, 0)) { return 1000; diff --git a/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/SkipReturnBool.php b/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/SkipReturnBool.php index 0e98c9d0..aa5aa098 100644 --- a/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/SkipReturnBool.php +++ b/tests/Rules/NoReturnFalseInNonBoolClassMethodRule/Fixture/SkipReturnBool.php @@ -8,10 +8,6 @@ final class SkipReturnBool { public function run(): bool { - if (mt_rand(1, 0)) { - return true; - } - - return false; + return (bool) mt_rand(1, 0); } }