diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index bec95c44..00000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 diff --git a/build/target-repository/.github/workflows/standalone_install.yaml b/.github/workflows/standalone_install.yaml similarity index 100% rename from build/target-repository/.github/workflows/standalone_install.yaml rename to .github/workflows/standalone_install.yaml diff --git a/build/rector-downgrade-php-72.php b/build/rector-downgrade-php-72.php deleted file mode 100644 index 667b7f0c..00000000 --- a/build/rector-downgrade-php-72.php +++ /dev/null @@ -1,12 +0,0 @@ -sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); - - $rectorConfig->skip(['*/tests/*']); -}; diff --git a/build/target-repository/.github/FUNDING.yml b/build/target-repository/.github/FUNDING.yml deleted file mode 100644 index f797866a..00000000 --- a/build/target-repository/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms -github: tomasvotruba -custom: https://www.paypal.me/rectorphp diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json deleted file mode 100644 index 0c1df372..00000000 --- a/build/target-repository/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "rector/type-perfect", - "type": "phpstan-extension", - "description": "Next level type declaration checks", - "license": "MIT", - "require": { - "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.11", - "webmozart/assert": "^1.11" - }, - "autoload": { - "psr-4": { - "Rector\\TypePerfect\\": "src" - } - }, - "extra": { - "phpstan": { - "includes": [ - "config/extension.neon" - ] - } - } -} diff --git a/composer.json b/composer.json index 1c2c2f8b..0c1df372 100644 --- a/composer.json +++ b/composer.json @@ -4,48 +4,20 @@ "description": "Next level type declaration checks", "license": "MIT", "require": { - "php": "^8.2", + "php": "^7.2|^8.0", "phpstan/phpstan": "^1.11", "webmozart/assert": "^1.11" }, - "require-dev": { - "nikic/php-parser": "^4.19", - "symplify/phpstan-extensions": "^11.4", - "symplify/rule-doc-generator": "^12.1", - "phpunit/phpunit": "^10.5", - "rector/rector": "^1.1", - "symplify/easy-coding-standard": "^12.1", - "phpstan/extension-installer": "^1.3", - "tomasvotruba/class-leak": "^0.2", - "tracy/tracy": "^2.10" - }, "autoload": { "psr-4": { "Rector\\TypePerfect\\": "src" } }, - "autoload-dev": { - "psr-4": { - "Rector\\TypePerfect\\Tests\\": "tests" - } - }, "extra": { "phpstan": { "includes": [ "config/extension.neon" ] } - }, - "config": { - "platform-check": false, - "allow-plugins": { - "phpstan/extension-installer": true - } - }, - "scripts": { - "check-cs": "vendor/bin/ecs check --ansi", - "fix-cs": "vendor/bin/ecs check --fix --ansi", - "phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify", - "rector": "vendor/bin/rector process --dry-run --ansi" } } diff --git a/ecs.php b/ecs.php deleted file mode 100644 index 7a5dab64..00000000 --- a/ecs.php +++ /dev/null @@ -1,18 +0,0 @@ -withPaths([ - __DIR__ . '/config', - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withRootFiles() - ->withPreparedSets(psr12: true, common: true) - ->withSkip([ - '*/Source/*', - '*/Fixture/*', - ]); diff --git a/full-tool-build.sh b/full-tool-build.sh deleted file mode 100644 index 47c552dd..00000000 --- a/full-tool-build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -# add patches -composer install --ansi - -# but skip dev dependencies -composer update --no-dev --ansi - -# remove tests and useless files, to make downgraded, scoped and deployed codebase as small as possible -rm -rf tests - -# downgrade with rector -mkdir rector-local -composer require rector/rector --working-dir rector-local -rector-local/vendor/bin/rector process src --config build/rector-downgrade-php-72.php --ansi diff --git a/build/target-repository/phpstan-for-tests.neon b/phpstan-for-tests.neon similarity index 100% rename from build/target-repository/phpstan-for-tests.neon rename to phpstan-for-tests.neon diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 8d75e428..00000000 --- a/phpstan.neon +++ /dev/null @@ -1,22 +0,0 @@ -includes: - - config/extension.neon - -parameters: - level: 8 - - paths: - - src - - config - - tests - - excludePaths: - # tests - - "*/Source/*" - - "*/Fixture/*" - - ignoreErrors: - - '#Method (.*?)::getCollectors\(\) return type with generic interface PHPStan\\Collectors\\Collector does not specify its types\: TNodeType, TValue#' - - # overly detailed generics - - '#Rector\\TypePerfect\\Tests\\Rules\\(.*?) generic (class|interface)#' - - '#Method Rector\\TypePerfect\\Tests\\Rules\\(.*?)testRule\(\) has parameter \$expectedErrorsWithLines with no value type specified in iterable type array#' diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index c8ec4d76..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - tests - - diff --git a/rector.php b/rector.php deleted file mode 100644 index 238b7781..00000000 --- a/rector.php +++ /dev/null @@ -1,28 +0,0 @@ -withPhpSets() - ->withRootFiles() - ->withPreparedSets( - codeQuality: true, - deadCode: true, - codingStyle: true, - typeDeclarations: true, - privatization: true, - naming: true, - earlyReturn: true - ) - ->withPaths([ - __DIR__ . '/config', - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withImportNames(removeUnusedImports: true) - ->withSkip([ - '*/Source/*', - '*/Fixture/*', - ]); diff --git a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php index 39f47742..2177a990 100644 --- a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php +++ b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php @@ -16,13 +16,28 @@ /** * @implements Collector */ -final readonly class PublicClassMethodParamTypesCollector implements Collector +final class PublicClassMethodParamTypesCollector implements Collector { - public function __construct( - private ApiDocStmtAnalyzer $apiDocStmtAnalyzer, - private PublicClassMethodMatcher $publicClassMethodMatcher, - private CollectorMetadataPrinter $collectorMetadataPrinter - ) { + /** + * @readonly + * @var \Rector\TypePerfect\PhpDoc\ApiDocStmtAnalyzer + */ + private $apiDocStmtAnalyzer; + /** + * @readonly + * @var \Rector\TypePerfect\Matcher\Collector\PublicClassMethodMatcher + */ + private $publicClassMethodMatcher; + /** + * @readonly + * @var \Rector\TypePerfect\Printer\CollectorMetadataPrinter + */ + private $collectorMetadataPrinter; + public function __construct(ApiDocStmtAnalyzer $apiDocStmtAnalyzer, PublicClassMethodMatcher $publicClassMethodMatcher, CollectorMetadataPrinter $collectorMetadataPrinter) + { + $this->apiDocStmtAnalyzer = $apiDocStmtAnalyzer; + $this->publicClassMethodMatcher = $publicClassMethodMatcher; + $this->collectorMetadataPrinter = $collectorMetadataPrinter; } public function getNodeType(): string diff --git a/src/Collector/MethodCall/MethodCallArgTypesCollector.php b/src/Collector/MethodCall/MethodCallArgTypesCollector.php index b410bc70..f5309808 100644 --- a/src/Collector/MethodCall/MethodCallArgTypesCollector.php +++ b/src/Collector/MethodCall/MethodCallArgTypesCollector.php @@ -17,14 +17,23 @@ /** * @implements Collector|null> */ -final readonly class MethodCallArgTypesCollector implements Collector +final class MethodCallArgTypesCollector implements Collector { - public function __construct( - private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - private CollectorMetadataPrinter $collectorMetadataPrinter, - ) { + /** + * @readonly + * @var \Rector\TypePerfect\Matcher\ClassMethodCallReferenceResolver + */ + private $classMethodCallReferenceResolver; + /** + * @readonly + * @var \Rector\TypePerfect\Printer\CollectorMetadataPrinter + */ + private $collectorMetadataPrinter; + public function __construct(ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, CollectorMetadataPrinter $collectorMetadataPrinter) + { + $this->classMethodCallReferenceResolver = $classMethodCallReferenceResolver; + $this->collectorMetadataPrinter = $collectorMetadataPrinter; } - public function getNodeType(): string { return MethodCall::class; diff --git a/src/Collector/MethodCallableNode/MethodCallableCollector.php b/src/Collector/MethodCallableNode/MethodCallableCollector.php index 6d00cdd6..437d8d88 100644 --- a/src/Collector/MethodCallableNode/MethodCallableCollector.php +++ b/src/Collector/MethodCallableNode/MethodCallableCollector.php @@ -18,13 +18,17 @@ * * @see https://github.com/phpstan/phpstan-src/blob/511c1e435fb43b8eb0ac310e6aa3230147963790/src/Analyser/NodeScopeResolver.php#L1936 */ -final readonly class MethodCallableCollector implements Collector +final class MethodCallableCollector implements Collector { - public function __construct( - private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - ) { + /** + * @readonly + * @var \Rector\TypePerfect\Matcher\ClassMethodCallReferenceResolver + */ + private $classMethodCallReferenceResolver; + public function __construct(ClassMethodCallReferenceResolver $classMethodCallReferenceResolver) + { + $this->classMethodCallReferenceResolver = $classMethodCallReferenceResolver; } - public function getNodeType(): string { return MethodCallableNode::class; diff --git a/src/Configuration.php b/src/Configuration.php index 99170575..07e655c0 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -6,12 +6,17 @@ final class Configuration { + /** + * @var array + */ + private $parameters; /** * @param array $parameters */ public function __construct( - private array $parameters + array $parameters ) { + $this->parameters = $parameters; // enabed by default in tests if (defined('PHPUNIT_COMPOSER_INSTALL')) { $this->parameters['narrow_param'] = true; diff --git a/src/Matcher/ClassMethodCallReferenceResolver.php b/src/Matcher/ClassMethodCallReferenceResolver.php index 747be901..22d93c58 100644 --- a/src/Matcher/ClassMethodCallReferenceResolver.php +++ b/src/Matcher/ClassMethodCallReferenceResolver.php @@ -15,7 +15,10 @@ final class ClassMethodCallReferenceResolver { - public function resolve(MethodCall|MethodCallableNode $methodCallOrMethodCallable, Scope $scope, bool $allowThisType): ?MethodCallReference + /** + * @param \PhpParser\Node\Expr\MethodCall|\PHPStan\Node\MethodCallableNode $methodCallOrMethodCallable + */ + public function resolve($methodCallOrMethodCallable, Scope $scope, bool $allowThisType): ?MethodCallReference { if ($methodCallOrMethodCallable instanceof MethodCallableNode) { $methodName = $methodCallOrMethodCallable->getName(); diff --git a/src/Matcher/Collector/PublicClassMethodMatcher.php b/src/Matcher/Collector/PublicClassMethodMatcher.php index 07261a03..a6a99009 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -71,6 +71,6 @@ public function shouldSkipClassMethod(ClassMethod $classMethod): bool $doc = $classMethod->getDocComment(); // skip symfony action - return $doc instanceof Doc && str_contains($doc->getText(), '@Route'); + return $doc instanceof Doc && strpos($doc->getText(), '@Route') !== false; } } diff --git a/src/NodeFinder/ClassMethodNodeFinder.php b/src/NodeFinder/ClassMethodNodeFinder.php index 6f45c4cb..f553a989 100644 --- a/src/NodeFinder/ClassMethodNodeFinder.php +++ b/src/NodeFinder/ClassMethodNodeFinder.php @@ -12,13 +12,17 @@ use PHPStan\Reflection\ClassReflection; use Rector\TypePerfect\Reflection\ReflectionParser; -final readonly class ClassMethodNodeFinder +final class ClassMethodNodeFinder { - public function __construct( - private ReflectionParser $reflectionParser, - ) { + /** + * @readonly + * @var \Rector\TypePerfect\Reflection\ReflectionParser + */ + private $reflectionParser; + public function __construct(ReflectionParser $reflectionParser) + { + $this->reflectionParser = $reflectionParser; } - public function findByMethodCall(MethodCall $methodCall, Scope $scope): ?ClassMethod { $classReflection = $scope->getClassReflection(); diff --git a/src/NodeFinder/MethodCallNodeFinder.php b/src/NodeFinder/MethodCallNodeFinder.php index 040c1c51..aa2cec91 100644 --- a/src/NodeFinder/MethodCallNodeFinder.php +++ b/src/NodeFinder/MethodCallNodeFinder.php @@ -14,14 +14,28 @@ use Rector\TypePerfect\Reflection\ReflectionParser; use Webmozart\Assert\Assert; -final readonly class MethodCallNodeFinder +final class MethodCallNodeFinder { - private NodeFinder $nodeFinder; + /** + * @readonly + * @var \Rector\TypePerfect\Reflection\ReflectionParser + */ + private $reflectionParser; + /** + * @readonly + * @var \Rector\TypePerfect\Printer\NodeComparator + */ + private $nodeComparator; + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; - public function __construct( - private ReflectionParser $reflectionParser, - private NodeComparator $nodeComparator, - ) { + public function __construct(ReflectionParser $reflectionParser, NodeComparator $nodeComparator) + { + $this->reflectionParser = $reflectionParser; + $this->nodeComparator = $nodeComparator; $this->nodeFinder = new NodeFinder(); } diff --git a/src/NodeFinder/ReturnNodeFinder.php b/src/NodeFinder/ReturnNodeFinder.php index 471a01fe..8fd6734f 100644 --- a/src/NodeFinder/ReturnNodeFinder.php +++ b/src/NodeFinder/ReturnNodeFinder.php @@ -12,9 +12,9 @@ use PhpParser\NodeTraverser; use Rector\TypePerfect\NodeVisitor\CallableNodeVisitor; -final readonly class ReturnNodeFinder +final class ReturnNodeFinder { - public function findOnlyReturnsExpr(ClassMethod $classMethod): Expr|null + public function findOnlyReturnsExpr(ClassMethod $classMethod): ?\PhpParser\Node\Expr { $returns = $this->findReturnsWithValues($classMethod); if (count($returns) !== 1) { diff --git a/src/NodeVisitor/CallableNodeVisitor.php b/src/NodeVisitor/CallableNodeVisitor.php index e0bb5699..ebb44582 100644 --- a/src/NodeVisitor/CallableNodeVisitor.php +++ b/src/NodeVisitor/CallableNodeVisitor.php @@ -25,7 +25,10 @@ public function __construct(callable $callable) $this->callable = $callable; } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PhpParser\Node|null + */ + public function enterNode(Node $node) { $originalNode = $node; $callable = $this->callable; diff --git a/src/PhpDoc/ApiDocStmtAnalyzer.php b/src/PhpDoc/ApiDocStmtAnalyzer.php index c6b2307c..2093629c 100644 --- a/src/PhpDoc/ApiDocStmtAnalyzer.php +++ b/src/PhpDoc/ApiDocStmtAnalyzer.php @@ -22,7 +22,7 @@ public function hasApiDoc(ClassMethod $classMethod, ClassReflection $classReflec return false; } - return str_contains($docComment->getText(), '@api'); + return strpos($docComment->getText(), '@api') !== false; } private function hasClassReflectionApiDoc(ClassReflection $classReflection): bool @@ -32,6 +32,6 @@ private function hasClassReflectionApiDoc(ClassReflection $classReflection): boo } $resolvedPhpDocBlock = $classReflection->getResolvedPhpDoc(); - return str_contains($resolvedPhpDocBlock->getPhpDocString(), '@api'); + return strpos($resolvedPhpDocBlock->getPhpDocString(), '@api') !== false; } } diff --git a/src/Printer/CollectorMetadataPrinter.php b/src/Printer/CollectorMetadataPrinter.php index c46d0b92..d9395d40 100644 --- a/src/Printer/CollectorMetadataPrinter.php +++ b/src/Printer/CollectorMetadataPrinter.php @@ -32,9 +32,13 @@ use PHPStan\Type\VerbosityLevel; use Rector\TypePerfect\Enum\Types\ResolvedTypes; -final readonly class CollectorMetadataPrinter +final class CollectorMetadataPrinter { - private Standard $printerStandard; + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $printerStandard; public function __construct() { @@ -122,7 +126,11 @@ private function transformSelfToClassName(Node $node, ?string $className): Node return new FullyQualified($className); } - private function resolveSortedTypes(UnionType|NodeIntersectionType $paramType, ?string $className): UnionType|NodeIntersectionType + /** + * @param \PhpParser\Node\UnionType|NodeIntersectionType $paramType + * @return \PhpParser\Node\UnionType|NodeIntersectionType + */ + private function resolveSortedTypes($paramType, ?string $className) { $typeNames = []; diff --git a/src/Printer/NodeComparator.php b/src/Printer/NodeComparator.php index c8cbc7fe..ebe0d6fa 100644 --- a/src/Printer/NodeComparator.php +++ b/src/Printer/NodeComparator.php @@ -7,11 +7,16 @@ use PhpParser\Node; use PhpParser\PrettyPrinter\Standard; -final readonly class NodeComparator +final class NodeComparator { - public function __construct( - private Standard $standard - ) { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $standard; + public function __construct(Standard $standard) + { + $this->standard = $standard; } public function areNodesEqual(Node $firstNode, Node $secondNode): bool diff --git a/src/Reflection/ReflectionParser.php b/src/Reflection/ReflectionParser.php index 2419be1e..c8260c77 100644 --- a/src/Reflection/ReflectionParser.php +++ b/src/Reflection/ReflectionParser.php @@ -19,9 +19,13 @@ final class ReflectionParser /** * @var array */ - private array $classesByFilename = []; + private $classesByFilename = []; - private readonly Parser $parser; + /** + * @readonly + * @var \PhpParser\Parser + */ + private $parser; public function __construct() { @@ -39,7 +43,7 @@ public function parseClassReflection(ClassReflection $classReflection): ?ClassLi return $this->parseFilenameToClass($fileName); } - private function parseFilenameToClass(string $fileName): ClassLike|null + private function parseFilenameToClass(string $fileName): ?\PhpParser\Node\Stmt\ClassLike { if (isset($this->classesByFilename[$fileName])) { return $this->classesByFilename[$fileName]; @@ -58,7 +62,7 @@ private function parseFilenameToClass(string $fileName): ClassLike|null $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor(new NameResolver()); $nodeTraverser->traverse($stmts); - } catch (Throwable) { + } catch (Throwable $exception) { // not reachable return null; } diff --git a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php index db058ba8..e5f841b3 100644 --- a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php @@ -31,18 +31,33 @@ * @see \Rector\TypePerfect\Tests\Rules\CheckTypehintCallerTypeRule\CheckTypehintCallerTypeRuleTest * @implements Rule */ -final readonly class NarrowPrivateClassMethodParamTypeRule implements Rule +final class NarrowPrivateClassMethodParamTypeRule implements Rule { + /** + * @readonly + * @var \Rector\TypePerfect\Configuration + */ + private $configuration; + /** + * @readonly + * @var \Rector\TypePerfect\NodeFinder\MethodCallNodeFinder + */ + private $methodCallNodeFinder; + /** + * @readonly + * @var \Rector\TypePerfect\NodeFinder\ClassMethodNodeFinder + */ + private $classMethodNodeFinder; /** * @var string */ public const ERROR_MESSAGE = 'Parameter %d should use "%s" type as the only type passed to this method'; - public function __construct( - private Configuration $configuration, - private MethodCallNodeFinder $methodCallNodeFinder, - private ClassMethodNodeFinder $classMethodNodeFinder - ) { + public function __construct(Configuration $configuration, MethodCallNodeFinder $methodCallNodeFinder, ClassMethodNodeFinder $classMethodNodeFinder) + { + $this->configuration = $configuration; + $this->methodCallNodeFinder = $methodCallNodeFinder; + $this->classMethodNodeFinder = $classMethodNodeFinder; } /** diff --git a/src/Rules/NarrowPublicClassMethodParamTypeRule.php b/src/Rules/NarrowPublicClassMethodParamTypeRule.php index a9fe50ef..ef4d60f7 100644 --- a/src/Rules/NarrowPublicClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPublicClassMethodParamTypeRule.php @@ -21,16 +21,21 @@ * * @implements Rule */ -final readonly class NarrowPublicClassMethodParamTypeRule implements Rule +final class NarrowPublicClassMethodParamTypeRule implements Rule { + /** + * @readonly + * @var \Rector\TypePerfect\Configuration + */ + private $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Parameters should have "%s" types as the only types passed to this method'; - public function __construct( - private Configuration $configuration - ) { + public function __construct(Configuration $configuration) + { + $this->configuration = $configuration; } /** diff --git a/src/Rules/NarrowReturnObjectTypeRule.php b/src/Rules/NarrowReturnObjectTypeRule.php index 30563304..0b813d69 100644 --- a/src/Rules/NarrowReturnObjectTypeRule.php +++ b/src/Rules/NarrowReturnObjectTypeRule.php @@ -22,17 +22,27 @@ * * @implements Rule */ -final readonly class NarrowReturnObjectTypeRule implements Rule +final class NarrowReturnObjectTypeRule implements Rule { + /** + * @readonly + * @var \Rector\TypePerfect\NodeFinder\ReturnNodeFinder + */ + private $returnNodeFinder; + /** + * @readonly + * @var \Rector\TypePerfect\Reflection\MethodNodeAnalyser + */ + private $methodNodeAnalyser; /** * @var string */ public const ERROR_MESSAGE = 'Provide more specific return type "%s" over abstract one'; - public function __construct( - private ReturnNodeFinder $returnNodeFinder, - private MethodNodeAnalyser $methodNodeAnalyser, - ) { + public function __construct(ReturnNodeFinder $returnNodeFinder, MethodNodeAnalyser $methodNodeAnalyser) + { + $this->returnNodeFinder = $returnNodeFinder; + $this->methodNodeAnalyser = $methodNodeAnalyser; } /** diff --git a/src/Rules/NoMixedMethodCallerRule.php b/src/Rules/NoMixedMethodCallerRule.php index f5878682..a86f4862 100644 --- a/src/Rules/NoMixedMethodCallerRule.php +++ b/src/Rules/NoMixedMethodCallerRule.php @@ -17,17 +17,27 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedMethodCallerRule\NoMixedMethodCallerRuleTest * @implements Rule */ -final readonly class NoMixedMethodCallerRule implements Rule +final class NoMixedMethodCallerRule implements Rule { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $printerStandard; + /** + * @readonly + * @var \Rector\TypePerfect\Configuration + */ + private $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Mixed variable in a `%s->...()` can skip important errors. Make sure the type is known'; - public function __construct( - private Standard $printerStandard, - private Configuration $configuration, - ) { + public function __construct(Standard $printerStandard, Configuration $configuration) + { + $this->printerStandard = $printerStandard; + $this->configuration = $configuration; } /** diff --git a/src/Rules/NoMixedPropertyFetcherRule.php b/src/Rules/NoMixedPropertyFetcherRule.php index 5c8c23e2..aa1ac0d8 100644 --- a/src/Rules/NoMixedPropertyFetcherRule.php +++ b/src/Rules/NoMixedPropertyFetcherRule.php @@ -15,16 +15,21 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\NoMixedPropertyFetcherRuleTest * @implements Rule */ -final readonly class NoMixedPropertyFetcherRule implements Rule +final class NoMixedPropertyFetcherRule implements Rule { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $standard; /** * @var string */ public const ERROR_MESSAGE = 'Mixed property fetch in a "%s->..." can skip important errors. Make sure the type is known'; - public function __construct( - private Standard $standard, - ) { + public function __construct(Standard $standard) + { + $this->standard = $standard; } /** diff --git a/src/Rules/NoParamTypeRemovalRule.php b/src/Rules/NoParamTypeRemovalRule.php index 1bb14ad9..bc0151d5 100644 --- a/src/Rules/NoParamTypeRemovalRule.php +++ b/src/Rules/NoParamTypeRemovalRule.php @@ -17,16 +17,21 @@ * @see \Rector\TypePerfect\Tests\Rules\ForbiddenParamTypeRemovalRule\ForbiddenParamTypeRemovalRuleTest * @implements Rule */ -final readonly class NoParamTypeRemovalRule implements Rule +final class NoParamTypeRemovalRule implements Rule { + /** + * @readonly + * @var \Rector\TypePerfect\Reflection\MethodNodeAnalyser + */ + private $methodNodeAnalyser; /** * @var string */ public const ERROR_MESSAGE = 'Removing parent param type is forbidden'; - public function __construct( - private MethodNodeAnalyser $methodNodeAnalyser - ) { + public function __construct(MethodNodeAnalyser $methodNodeAnalyser) + { + $this->methodNodeAnalyser = $methodNodeAnalyser; } /** diff --git a/src/Rules/ReturnNullOverFalseRule.php b/src/Rules/ReturnNullOverFalseRule.php index 79770ad1..8c9b9dee 100644 --- a/src/Rules/ReturnNullOverFalseRule.php +++ b/src/Rules/ReturnNullOverFalseRule.php @@ -17,19 +17,28 @@ /** * @implements Rule */ -final readonly class ReturnNullOverFalseRule implements Rule +final class ReturnNullOverFalseRule implements Rule { + /** + * @readonly + * @var \Rector\TypePerfect\Configuration + */ + private $configuration; /** * @api * @var string */ public const ERROR_MESSAGE = 'Returning false in non return bool class method. Use null with type|null instead or add bool return type'; - private NodeFinder $nodeFinder; + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; - public function __construct( - private Configuration $configuration, - ) { + public function __construct(Configuration $configuration) + { + $this->configuration = $configuration; $this->nodeFinder = new NodeFinder(); } diff --git a/src/ValueObject/MethodCallReference.php b/src/ValueObject/MethodCallReference.php index 9224546b..d3a38a77 100644 --- a/src/ValueObject/MethodCallReference.php +++ b/src/ValueObject/MethodCallReference.php @@ -4,12 +4,22 @@ namespace Rector\TypePerfect\ValueObject; -final readonly class MethodCallReference +final class MethodCallReference { - public function __construct( - private string $class, - private string $method - ) { + /** + * @readonly + * @var string + */ + private $class; + /** + * @readonly + * @var string + */ + private $method; + public function __construct(string $class, string $method) + { + $this->class = $class; + $this->method = $method; } public function getClass(): string diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php deleted file mode 100644 index 31c25875..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php +++ /dev/null @@ -1,31 +0,0 @@ -run($anotherClassWithRun); - } - - /** - * @param SomeStaticCall|MethodCall $node - */ - private function run(Node $node) - { - 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 deleted file mode 100644 index a9a8d499..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php +++ /dev/null @@ -1,18 +0,0 @@ -isCheck($arg, $param); - } - private function isCheck(\PhpParser\Node $arg, \PhpParser\Node $param) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php deleted file mode 100644 index 68bd53cc..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php deleted file mode 100644 index ecafcfb7..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php +++ /dev/null @@ -1,16 +0,0 @@ -isCheck($arg); - } - private function isCheck(ConceptBase $arg) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php deleted file mode 100644 index f74f3dd6..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(MethodCall $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php deleted file mode 100644 index 9480df8a..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php +++ /dev/null @@ -1,32 +0,0 @@ -isIncludeOnceOrRequireOnce($node)) { - return []; - } - - return []; - } - - /** - * @param Assign|Return_ $node - */ - private function isIncludeOnceOrRequireOnce(\PhpParser\Node $node) - { - return true; - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php deleted file mode 100644 index 632fc7de..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php +++ /dev/null @@ -1,26 +0,0 @@ -printFile(new FileWithoutNamespace([])); - } - - private function printFile(\PhpParser\Node $node) - { - } - - public function secondMethod() - { - // some comment - $this->printFile(new FileNode([])); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php deleted file mode 100644 index e62b5097..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php +++ /dev/null @@ -1,31 +0,0 @@ -getsAGeneric($node); - } - - /** - * @param T $node - * @return void - */ - private function getsAGeneric(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php deleted file mode 100644 index b2658cd3..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php +++ /dev/null @@ -1,27 +0,0 @@ -mayOverrideNode(); - - $this->isCheck($node); - - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php deleted file mode 100644 index 66a104e1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php +++ /dev/null @@ -1,18 +0,0 @@ -isCheck($arg); - } - private function isCheck(\PhpParser\Node $arg) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php deleted file mode 100644 index 1919ec98..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php +++ /dev/null @@ -1,27 +0,0 @@ -isCheck($node); - } - - if ($node instanceof PropertyFetch) { - $this->isCheck($node); - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php deleted file mode 100644 index 90094439..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php +++ /dev/null @@ -1,15 +0,0 @@ -execute(); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php deleted file mode 100644 index 65436953..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php +++ /dev/null @@ -1,14 +0,0 @@ -format('Y-m-d'); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php deleted file mode 100644 index a16c0ad1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheckNotPrivate($node); - } - } - - public function isCheckNotPrivate(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php deleted file mode 100644 index a74a81b1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php +++ /dev/null @@ -1,23 +0,0 @@ -isCheck($type); - } - - private function isCheck(\PHPStan\Type\Type $type) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php deleted file mode 100644 index 04a51b74..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php +++ /dev/null @@ -1,15 +0,0 @@ -execute($node); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php deleted file mode 100644 index b0984640..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php +++ /dev/null @@ -1,30 +0,0 @@ -run($node); - } - - /** - * @param SomeStaticCall|MethodCall $node - */ - private function run(Node $node) - { - if ($node->name instanceof MethodCall) { - $this->run($node->name); - } - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php deleted file mode 100644 index d8a0a3f1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php +++ /dev/null @@ -1,67 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php', []]; - - yield [__DIR__ . '/Fixture/SkipCorrectUnionType.php', []]; - yield [__DIR__ . '/Fixture/SkipRecursive.php', []]; - yield [__DIR__ . '/Fixture/SkipMixed.php', []]; - yield [__DIR__ . '/Fixture/SkipOptedOut.php', []]; - yield [__DIR__ . '/Fixture/SkipNotFromThis.php', []]; - - yield [__DIR__ . '/Fixture/SkipParentNotIf.php', []]; - yield [__DIR__ . '/Fixture/SkipNoArgs.php', []]; - yield [__DIR__ . '/Fixture/SkipAlreadyCorrectType.php', []]; - yield [__DIR__ . '/Fixture/SkipMayOverrideArg.php', []]; - yield [__DIR__ . '/Fixture/SkipMultipleUsed.php', []]; - yield [__DIR__ . '/Fixture/SkipNotPrivate.php', []]; - - $errorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 1, MethodCall::class); - yield [__DIR__ . '/Fixture/Fixture.php', [[$errorMessage, 19]]]; - yield [__DIR__ . '/Fixture/DifferentClassSameMethodCallName.php', [[$errorMessage, 25]]]; - - $argErrorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 1, Arg::class); - $paramErrorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 2, Param::class); - yield [__DIR__ . '/Fixture/DoubleShot.php', [[$argErrorMessage, 15], [$paramErrorMessage, 15]]]; - yield [__DIR__ . '/Fixture/SkipGenericType.php', []]; - yield [__DIR__ . '/Fixture/SkipAbstractBase.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowPrivateClassMethodParamTypeRule::class); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php deleted file mode 100644 index 0b3ba332..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php +++ /dev/null @@ -1,15 +0,0 @@ -callMe(...); - - $someCalledMethod->callMe(1000); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php deleted file mode 100644 index 3b1da8cc..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php +++ /dev/null @@ -1,12 +0,0 @@ -takesUnionWithDifferentDefaultValue(1); - - $o = new HandleDefaultValue(); - $o->takesUnionWithSameTypeDefaultValue(1); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php deleted file mode 100644 index b156afb1..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php +++ /dev/null @@ -1,12 +0,0 @@ -class - : $obj->var; - } - - public function runTernaryFlipped(StaticCall|MethodCall $obj) - { - return $obj instanceof MethodCall - ? $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 deleted file mode 100644 index 1c722337..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php +++ /dev/null @@ -1,14 +0,0 @@ -callMe(1000); - } - - private function callMe($number) - { - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php deleted file mode 100644 index 70f5b1a7..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php +++ /dev/null @@ -1,14 +0,0 @@ -takesSelf(new SkipSelf()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php deleted file mode 100644 index c7670e11..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php +++ /dev/null @@ -1,14 +0,0 @@ -run(new DateTime('now')); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php deleted file mode 100644 index df4f8ebc..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [[__DIR__ . '/Fixture/SkipNonPublicClassMethod.php'], []]; - - // skip first class callables as anything can be passed there - yield [[ - __DIR__ . '/Fixture/FirstClassCallables/CallVariadics.php', - __DIR__ . '/Fixture/FirstClassCallables/SomeCalledMethod.php', - ], []]; - - // skip expected scalar type - yield [[ - __DIR__ . '/Fixture/SkipProperlyFilledParamType.php', - __DIR__ . '/Source/ExpectedType/FirstTypedCaller.php', - __DIR__ . '/Source/ExpectedType/SecondTypedCaller.php', - ], []]; - - // skip expected object type - yield [[ - __DIR__ . '/Fixture/SkipExpectedClassType.php', - __DIR__ . '/Source/ExpectedClassType/FirstClassTypedCaller.php', - __DIR__ . '/Source/ExpectedClassType/SecondClassTypedCaller.php', - ], []]; - - // skip class-string - yield [[ - __DIR__ . '/Fixture/SkipClassStringPassed.php', - __DIR__ . '/Source/ExpectedClassString/FirstTypedCaller.php', - __DIR__ . '/Source/ExpectedClassString/SecondTypedCaller.php', - ], []]; - - // skip everything in case of values is mixed - yield [[ - __DIR__ . '/Fixture/SkipMixedAndString.php', - __DIR__ . '/Source/MixedAndString/FirstCaller.php', - __DIR__ . '/Source/MixedAndString/SecondCaller.php', - ], []]; - - // skip int + string values - yield [[ - __DIR__ . '/Fixture/SkipMixedAndString.php', - __DIR__ . '/Source/MixedAndString/FirstCaller.php', - __DIR__ . '/Source/MixedAndString/ThirdCaller.php', - ], []]; - - // skip nullable compare - yield [[ - __DIR__ . '/Fixture/SkipNullableCompare.php', - __DIR__ . '/Source/NullableParam/FirstNullable.php', - __DIR__ . '/Source/NullableParam/SecondNullable.php', - ], []]; - - // skip api - yield [[ - __DIR__ . '/Fixture/SkipApiMarked.php', - __DIR__ . '/Source/ExpectedNodeApi/CallWithProperty.php', - ], []]; - - // skip equal union type - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionType.php', - ], []]; - - // skip equal union type flipped - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeFlipped.php', - ], []]; - - // skip equal union type ternary if else - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php', - ], []]; - - // skip equal union type ternary if else flipped - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php', - ], []]; - - // skip equal union type array typed - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionArrayType.php', - ], []]; - - // skip this passed exact type - yield [[ - __DIR__ . '/Fixture/SkipThisPassedExactType.php', - __DIR__ . '/Source/ExpectedThisType/CallByThis.php', - ], []]; - - // skip used internally for second type - yield [[ - __DIR__ . '/Fixture/SkipUsedInternallyForSecondType.php', - __DIR__ . '/Source/ExpectedType/OnlyFirstTypeCalledOutside.php', - ], []]; - - $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); - yield [[ - __DIR__ . '/Fixture/PublicDoubleShot.php', - __DIR__ . '/Source/FirstCaller.php', - __DIR__ . '/Source/SecondCaller.php', - ], [[$argErrorMessage, 9]]]; - - // this passed from interface - $argErrorMessage = sprintf( - NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, - CallByThisFromInterface::class - ); - yield [[ - __DIR__ . '/Fixture/ThisPassedFromInterface.php', - __DIR__ . '/Source/ExpectedThisType/CallByThisFromInterface.php', - ], [[$argErrorMessage, 11]]]; - - yield [[ - __DIR__ . '/Fixture/SkipSelf.php', - ], []]; - - $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); - yield [[ - __DIR__ . '/Fixture/HandleDefaultValue.php' - ], [[$argErrorMessage, 15]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowPublicClassMethodParamTypeRule::class); - } - - /** - * Warning, just spent hour looking for why the test does not run :D This should be implicit part of the parent - * class. - * - * @return Collector[] - */ - protected function getCollectors(): array - { - return self::getContainer()->getServicesByTag('phpstan.collector'); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php deleted file mode 100644 index 35c8ce08..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php deleted file mode 100644 index 4d4815ab..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php deleted file mode 100644 index 8ad53ce6..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php deleted file mode 100644 index 222edca0..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php deleted file mode 100644 index 44abed42..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php +++ /dev/null @@ -1,17 +0,0 @@ -callNode($property); - } - -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php deleted file mode 100644 index e78ad816..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php +++ /dev/null @@ -1,15 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php deleted file mode 100644 index eb90be0c..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php deleted file mode 100644 index 9eacb9d4..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php deleted file mode 100644 index a3e116a3..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php +++ /dev/null @@ -1,16 +0,0 @@ -run(new stdClass()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php deleted file mode 100644 index cc0e2dfe..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php deleted file mode 100644 index 813720b1..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php +++ /dev/null @@ -1,31 +0,0 @@ -runArrayTyped($node); - } - - public function run2(SkipEqualUnionType $skipEqualUnionType, Node $node): void - { - /** @var Node[]|Node $node */ - $node = rand(0, 1) - ? $node - : [$node]; - - $skipEqualUnionType->runArrayTyped2($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php deleted file mode 100644 index b3b11a0f..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php deleted file mode 100644 index a65c98bb..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php deleted file mode 100644 index 5643966a..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernary($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php deleted file mode 100644 index 2ac613fa..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernaryFlipped($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php deleted file mode 100644 index 81565e00..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php deleted file mode 100644 index abf52f56..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve('string'); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php deleted file mode 100644 index c087c8d7..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve($mixedValue); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php deleted file mode 100644 index 532bda8b..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve(1000); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php deleted file mode 100644 index b6668616..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php deleted file mode 100644 index 2ace4328..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php deleted file mode 100644 index ee1a0d09..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php +++ /dev/null @@ -1,10 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php deleted file mode 100644 index ee3221b0..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipSpecificReturnType.php', []]; - yield [__DIR__ . '/Fixture/SkipSomeContract.php', []]; - - $errorMessage = sprintf(NarrowReturnObjectTypeRule::ERROR_MESSAGE, SpecificControl::class); - yield [__DIR__ . '/Fixture/SomeAbstractReturnType.php', [[$errorMessage, 12]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowReturnObjectTypeRule::class); - } -} diff --git a/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php b/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php deleted file mode 100644 index 8b600f03..00000000 --- a/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php +++ /dev/null @@ -1,9 +0,0 @@ -children() as $name => $childElement) { - return isset($childElement['some']); - } - } -} diff --git a/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php b/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php deleted file mode 100644 index 8977e63c..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/ArrayAccessOnObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]]; - yield [__DIR__ . '/Fixture/ArrayAccessOnNestedObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]]; - - yield [__DIR__ . '/Fixture/SkipIterator.php', []]; - yield [__DIR__ . '/Fixture/SkipOnArray.php', []]; - yield [__DIR__ . '/Fixture/SkipSplFixedArray.php', []]; - yield [__DIR__ . '/Fixture/SkipXml.php', []]; - yield [__DIR__ . '/Fixture/SkipXmlElementForeach.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoArrayAccessOnObjectRule::class); - } -} diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php b/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php deleted file mode 100644 index a04d76d4..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php +++ /dev/null @@ -1,9 +0,0 @@ -args[9])) { - return $methodCall->args[9]; - } - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php b/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php deleted file mode 100644 index 61ed68f9..00000000 --- a/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php +++ /dev/null @@ -1,44 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/IssetOnObject.php', [[NoIssetOnObjectRule::ERROR_MESSAGE, 17]]]; - - yield [__DIR__ . '/Fixture/SkipIssetOnArray.php', []]; - yield [__DIR__ . '/Fixture/SkipIssetOnArrayNestedOnObject.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoIssetOnObjectRule::class); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php deleted file mode 100644 index 24634dca..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php +++ /dev/null @@ -1,13 +0,0 @@ -$magic(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php deleted file mode 100644 index 297d2526..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php +++ /dev/null @@ -1,15 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php deleted file mode 100644 index 58168a73..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php +++ /dev/null @@ -1,19 +0,0 @@ -createMock(MagicMethodName::class); - - $mock - ->method('run') - ->willReturn(true); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php deleted file mode 100644 index ecf6e76e..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php +++ /dev/null @@ -1,21 +0,0 @@ -createMock(SomeFinalClass::class); - - $someClassMock->expects($this->once()) - ->method('some') - ->with($this->any()) - ->willReturn(1000); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php deleted file mode 100644 index 5a01e193..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php +++ /dev/null @@ -1,13 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php b/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php deleted file mode 100644 index 1e8d2749..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php +++ /dev/null @@ -1,46 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipKnownCallerType.php', []]; - yield [__DIR__ . '/Fixture/SkipMockObject.php', []]; - yield [__DIR__ . '/Fixture/SkipPHPUnitMock.php', []]; - - $errorMessage = sprintf(NoMixedMethodCallerRule::ERROR_MESSAGE, '$someType'); - yield [__DIR__ . '/Fixture/MagicMethodName.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(NoMixedMethodCallerRule::ERROR_MESSAGE, '$mixedType'); - yield [__DIR__ . '/Fixture/UnknownCallerType.php', [[$errorMessage, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedMethodCallerRule::class); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php b/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php deleted file mode 100644 index 75536c75..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php +++ /dev/null @@ -1,12 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php deleted file mode 100644 index c3812a18..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php +++ /dev/null @@ -1,15 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php deleted file mode 100644 index 48ec8acc..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php +++ /dev/null @@ -1,15 +0,0 @@ -name; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php deleted file mode 100644 index ef906f07..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php b/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php deleted file mode 100644 index 215f5028..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php +++ /dev/null @@ -1,45 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipDynamicNameWithKnownType.php', []]; - yield [__DIR__ . '/Fixture/SkipKnownFetcherType.php', []]; - - $message = sprintf(NoMixedPropertyFetcherRule::ERROR_MESSAGE, '$unknownType'); - yield [__DIR__ . '/Fixture/DynamicName.php', [[$message, 11]]]; - - $message = sprintf(NoMixedPropertyFetcherRule::ERROR_MESSAGE, '$unknownType'); - yield [__DIR__ . '/Fixture/UnknownPropertyFetcher.php', [[$message, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedPropertyFetcherRule::class); - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php b/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php deleted file mode 100644 index 2655c864..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipPhpDocType.php', []]; - yield [__DIR__ . '/Fixture/SkipPresentType.php', []]; - yield [__DIR__ . '/Fixture/SkipNoType.php', []]; - - yield [__DIR__ . '/Fixture/SkipIndirectRemoval.php', []]; - - yield [__DIR__ . '/Fixture/RemoveParentType.php', [[NoParamTypeRemovalRule::ERROR_MESSAGE, 11]]]; - - yield [__DIR__ . '/Fixture/SkipNoParent.php', []]; - yield [__DIR__ . '/Fixture/SkipNotHasParentMethod.php', []]; - yield [__DIR__ . '/Fixture/SkipHasSameParameterWithParentMethod.php', []]; - yield [__DIR__ . '/Fixture/SkipHasSameParameterWithInterfaceMethod.php', []]; - - yield [ - __DIR__ . '/Fixture/HasDifferentParameterWithParentMethod.php', - [[NoParamTypeRemovalRule::ERROR_MESSAGE, 9]], - ]; - yield [ - __DIR__ . '/Fixture/HasDifferentParameterWithInterfaceMethod.php', - [[NoParamTypeRemovalRule::ERROR_MESSAGE, 9], [ - NoParamTypeRemovalRule::ERROR_MESSAGE, - 13, - ]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoParamTypeRemovalRule::class); - } -} diff --git a/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php b/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php deleted file mode 100644 index 333fbd22..00000000 --- a/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/ReturnFalseOnly.php', - [[ReturnNullOverFalseRule::ERROR_MESSAGE, 9]], - ]; - - yield [__DIR__ . '/Fixture/SkipReturnBool.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ReturnNullOverFalseRule::class); - } -} diff --git a/tests/SomeClass.php.inc b/tests/SomeClass.php.inc deleted file mode 100644 index 17ce8504..00000000 --- a/tests/SomeClass.php.inc +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/tests/config/included_services.neon b/tests/config/included_services.neon deleted file mode 100644 index 6291a434..00000000 --- a/tests/config/included_services.neon +++ /dev/null @@ -1,2 +0,0 @@ -includes: - - ../../config/services.neon