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 34d0c266..00000000 --- a/build/rector-downgrade-php-72.php +++ /dev/null @@ -1,23 +0,0 @@ -parallel(); - - $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); - - $rectorConfig->ruleWithConfiguration(RemoveInterfacesRector::class, [ - DocumentedRuleInterface::class, - ConfigurableRuleInterface::class, - ]); - - $rectorConfig->skip(['*/Tests/*', '*/tests/*', __DIR__ . '/../../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 d7e0856e..00000000 --- a/build/target-repository/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "symplify/phpstan-rules", - "type": "phpstan-extension", - "description": "Set of Symplify rules for PHPStan", - "license": "MIT", - "require": { - "php": "^7.2|^8.0", - "nette/utils": "^3.2.9 || ^4.0", - "phpstan/phpstan": "^1.10.30", - "webmozart/assert": "^1.11" - }, - "autoload": { - "psr-4": { - "Symplify\\PHPStanRules\\": "src" - } - }, - "extra": { - "phpstan": { - "includes": [ - "config/services/services.neon" - ] - } - } -} diff --git a/build/target-repository/phpstan-for-tests.neon b/build/target-repository/phpstan-for-tests.neon deleted file mode 100644 index 0d1b2a61..00000000 --- a/build/target-repository/phpstan-for-tests.neon +++ /dev/null @@ -1,9 +0,0 @@ -# this config is only for tests, it verifies all the rules are runnable -includes: - - vendor/symplify/phpstan-rules/config/symplify-rules.neon - -parameters: - level: 4 - - ignoreErrors: - - '#Class method "getName\(\)" is never used#' diff --git a/build/target-repository/tests/SomeClass.php.inc b/build/target-repository/tests/SomeClass.php.inc deleted file mode 100644 index 17ce8504..00000000 --- a/build/target-repository/tests/SomeClass.php.inc +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/composer.json b/composer.json index a795ef2c..d7e0856e 100644 --- a/composer.json +++ b/composer.json @@ -4,60 +4,21 @@ "description": "Set of Symplify rules for PHPStan", "license": "MIT", "require": { - "php": ">=8.1", + "php": "^7.2|^8.0", "nette/utils": "^3.2.9 || ^4.0", - "webmozart/assert": "^1.11", - "phpstan/phpstan": "^1.11", - "symplify/rule-doc-generator-contracts": "^11.1.26" - }, - "require-dev": { - "nikic/php-parser": "^4.19", - "symplify/phpstan-extensions": "^11.4", - "symplify/rule-doc-generator": "^12.0", - "phpunit/phpunit": "^10.5", - "symfony/framework-bundle": "6.1.*", - "rector/rector": "^1.1", - "symplify/easy-coding-standard": "^12.1", - "phpstan/extension-installer": "^1.3", - "tomasvotruba/class-leak": "^0.2" + "phpstan/phpstan": "^1.10.30", + "webmozart/assert": "^1.11" }, "autoload": { "psr-4": { "Symplify\\PHPStanRules\\": "src" } }, - "autoload-dev": { - "psr-4": { - "Symplify\\PHPStanRules\\Tests\\": "tests" - }, - "classmap": [ - "stubs" - ], - "files": [ - "tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/Fixture/SomePhpFeatureRector.php", - "vendor/rector/rector/src/Contract/Rector/RectorInterface.php", - "vendor/rector/rector/src/Contract/Rector/ConfigurableRectorInterface.php", - "vendor/rector/rector/vendor/rector/rector-downgrade-php/src/Set/ValueObject/DowngradeSetList.php" - ] - }, "extra": { "phpstan": { "includes": [ "config/services/services.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", - "docs": "vendor/bin/rule-doc-generator generate src --output-file docs/rules_overview.md --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 a2b95d50..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 bin src vendor --config build/rector-downgrade-php-72.php --ansi diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index b50a6406..00000000 --- a/phpstan.neon +++ /dev/null @@ -1,54 +0,0 @@ -includes: - - config/services/services.neon - - config/naming-rules.neon - -parameters: - level: 8 - - paths: - - src - - config - - tests - - # reportUnmatchedIgnoredErrors: false - - excludePaths: - # parallel - - packages/*-phpstan-printer/tests/*ToPhpCompiler/Fixture* - - # tests - - '*/tests/**/Source/*' - - */stubs/* - - */Fixture/* - - ignoreErrors: - - - message: '#Generator expects value type array\|string>, array>\|string> given#' - paths: - - tests/Rules - - - - message: '#Generator expects value type array\|string>, array>\|string> given#' - paths: - - tests/Rules - - # needless generics - - '#Class Symplify\\PHPStanRules\\(.*?)Rule implements generic interface PHPStan\\Rules\\Rule but does not specify its types\: TNodeType#' - - '#Method (.*?)::getCollectors\(\) return type with generic interface PHPStan\\Collectors\\Collector does not specify its types\: TNodeType, TValue#' - - - '#Parameter \#1 \$values of method Symplify\\PHPStanRules\\Rules\\Enum\\RequireUniqueEnumConstantRule\:\:filterDuplicatedValues\(\) expects array, array given#' - - - '#Class PHP_CodeSniffer\\Sniffs\\Sniff not found#' - - - '#Method Symplify\\PHPStanRules\\Reflection\\ReflectionParser\:\:parseNativeClassReflection\(\) has parameter \$reflectionClass with generic class ReflectionClass but does not specify its types\: T#' - - - '#Method Symplify\\PHPStanRules\\NodeFinder\\TypeAwareNodeFinder\:\:findFirstInstanceOf\(\) should return \(TNode of PhpParser\\Node\)\|null but returns PhpParser\\Node\|null#' - - - '#Method Symplify\\PHPStanRules\\NodeFinder\\MethodCallNodeFinder\:\:findUsages\(\) should return array but returns array#' - - # overly detailed - - '#Class Symplify\\PHPStanRules\\(.*?) extends generic class PHPStan\\Testing\\RuleTestCase but does not specify its types\: TRule#' - - '#Method Symplify\\PHPStanRules\\(.*?)\:\:getRule\(\) return type with generic interface PHPStan\\Rules\\Rule does not specify its types\: TNodeType#' - - # part of public contract - - '#Method Symplify\\PHPStanRules\\Tests\\Rules\\PHPUnit\\(.*?)\\(.*?)Test\:\:testRule\(\) has parameter \$expectedErrorMessagesWithLines with no value type specified in iterable type array#' diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index a94c8d42..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - tests - tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/ - - diff --git a/rector.php b/rector.php deleted file mode 100644 index e68c64ff..00000000 --- a/rector.php +++ /dev/null @@ -1,41 +0,0 @@ -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([ - __DIR__ . '/config', - __DIR__ . '/src', - __DIR__ . '/tests', - ]); - - $rectorConfig->importNames(); - - $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 7201ad25..62fc59bd 100644 --- a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php +++ b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php @@ -18,11 +18,26 @@ */ final class PublicClassMethodParamTypesCollector implements Collector { - public function __construct( - private readonly ApiDocStmtAnalyzer $apiDocStmtAnalyzer, - private readonly PublicClassMethodMatcher $publicClassMethodMatcher, - private readonly CollectorMetadataPrinter $collectorMetadataPrinter - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\PhpDoc\ApiDocStmtAnalyzer + */ + private $apiDocStmtAnalyzer; + /** + * @readonly + * @var \Symplify\PHPStanRules\Matcher\Collector\PublicClassMethodMatcher + */ + private $publicClassMethodMatcher; + /** + * @readonly + * @var \Symplify\PHPStanRules\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 7371d461..9524533c 100644 --- a/src/Collector/MethodCall/MethodCallArgTypesCollector.php +++ b/src/Collector/MethodCall/MethodCallArgTypesCollector.php @@ -17,12 +17,21 @@ */ final class MethodCallArgTypesCollector implements Collector { - public function __construct( - private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - private readonly CollectorMetadataPrinter $collectorMetadataPrinter, - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\Matcher\ClassMethodCallReferenceResolver + */ + private $classMethodCallReferenceResolver; + /** + * @readonly + * @var \Symplify\PHPStanRules\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 e8f33b82..b75dfb07 100644 --- a/src/Collector/MethodCallableNode/MethodCallableCollector.php +++ b/src/Collector/MethodCallableNode/MethodCallableCollector.php @@ -21,11 +21,15 @@ */ final class MethodCallableCollector implements Collector { - public function __construct( - private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\Matcher\ClassMethodCallReferenceResolver + */ + private $classMethodCallReferenceResolver; + public function __construct(ClassMethodCallReferenceResolver $classMethodCallReferenceResolver) + { + $this->classMethodCallReferenceResolver = $classMethodCallReferenceResolver; } - public function getNodeType(): string { return MethodCallableNode::class; diff --git a/src/Composer/ClassNamespaceMatcher.php b/src/Composer/ClassNamespaceMatcher.php index d2279aac..5423aa7d 100644 --- a/src/Composer/ClassNamespaceMatcher.php +++ b/src/Composer/ClassNamespaceMatcher.php @@ -10,9 +10,14 @@ final class ClassNamespaceMatcher { - public function __construct( - private readonly DirectoryChecker $directoryChecker - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\Location\DirectoryChecker + */ + private $directoryChecker; + public function __construct(DirectoryChecker $directoryChecker) + { + $this->directoryChecker = $directoryChecker; } /** @@ -54,7 +59,7 @@ public function matchPossibleDirectoriesForClass( * @param string|string[] $items * @return string[] */ - private function standardizeToArray(string | array $items): array + private function standardizeToArray($items): array { if (! is_array($items)) { return [$items]; diff --git a/src/Contract/PhpDocParser/PhpDocNodeVisitorInterface.php b/src/Contract/PhpDocParser/PhpDocNodeVisitorInterface.php index 3081f405..3e68fbfa 100644 --- a/src/Contract/PhpDocParser/PhpDocNodeVisitorInterface.php +++ b/src/Contract/PhpDocParser/PhpDocNodeVisitorInterface.php @@ -13,12 +13,15 @@ interface PhpDocNodeVisitorInterface { public function beforeTraverse(Node $node): void; - public function enterNode(Node $node): int|Node|null; + /** + * @return int|\PHPStan\PhpDocParser\Ast\Node|null + */ + public function enterNode(Node $node); /** * @return null|int|\PhpParser\Node|Node[] Replacement node (or special return) */ - public function leaveNode(Node $node): int|\PhpParser\Node|array|null; + public function leaveNode(Node $node); public function afterTraverse(Node $node): void; } diff --git a/src/Location/DirectoryChecker.php b/src/Location/DirectoryChecker.php index 9fda237b..910d26f2 100644 --- a/src/Location/DirectoryChecker.php +++ b/src/Location/DirectoryChecker.php @@ -13,7 +13,7 @@ public function isInDirectoryNamed(Scope $scope, string $directoryName): bool $normalized = $this->normalizePath($directoryName); $directoryName = rtrim($normalized, '\/'); - return \str_contains($scope->getFile(), DIRECTORY_SEPARATOR . $directoryName . DIRECTORY_SEPARATOR); + return strpos($scope->getFile(), DIRECTORY_SEPARATOR . $directoryName . DIRECTORY_SEPARATOR) !== false; } private function normalizePath(string $directoryName): string diff --git a/src/Matcher/ClassMethodCallReferenceResolver.php b/src/Matcher/ClassMethodCallReferenceResolver.php index d231aadf..1319c375 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 50b6ec3d..97944388 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -73,6 +73,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/Naming/ClassToSuffixResolver.php b/src/Naming/ClassToSuffixResolver.php index f235f5d9..bc4c39a2 100644 --- a/src/Naming/ClassToSuffixResolver.php +++ b/src/Naming/ClassToSuffixResolver.php @@ -13,7 +13,7 @@ final class ClassToSuffixResolver { public function resolveFromClass(string $parentClass): string { - $expectedSuffix = \str_contains($parentClass, '\\') ? (string) Strings::after( + $expectedSuffix = strpos($parentClass, '\\') !== false ? (string) Strings::after( $parentClass, '\\', -1 @@ -31,15 +31,15 @@ public function resolveFromClass(string $parentClass): string private function removeAbstractInterfacePrefixSuffix(string $parentType): string { - if (\str_ends_with($parentType, 'Interface')) { + if (substr_compare($parentType, 'Interface', -strlen('Interface')) === 0) { $parentType = Strings::substring($parentType, 0, -strlen('Interface')); } - if (\str_ends_with($parentType, 'Abstract')) { + if (substr_compare($parentType, 'Abstract', -strlen('Abstract')) === 0) { $parentType = Strings::substring($parentType, 0, -strlen('Abstract')); } - if (\str_starts_with($parentType, 'Abstract')) { + if (strncmp($parentType, 'Abstract', strlen('Abstract')) === 0) { return Strings::substring($parentType, strlen('Abstract')); } diff --git a/src/NodeAnalyzer/AttributeFinder.php b/src/NodeAnalyzer/AttributeFinder.php index ed0ebebf..a35793d6 100644 --- a/src/NodeAnalyzer/AttributeFinder.php +++ b/src/NodeAnalyzer/AttributeFinder.php @@ -13,15 +13,19 @@ final class AttributeFinder { - public function hasAttribute(ClassLike | ClassMethod | Property | Param $node, string $desiredAttributeClass): bool + /** + * @param \PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node + */ + public function hasAttribute($node, string $desiredAttributeClass): bool { return (bool) $this->findAttribute($node, $desiredAttributeClass); } /** * @return Attribute[] + * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node */ - private function findAttributes(ClassMethod | Property | ClassLike | Param $node): array + private function findAttributes($node): array { $attributes = []; @@ -32,8 +36,11 @@ private function findAttributes(ClassMethod | Property | ClassLike | Param $node return $attributes; } + /** + * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node + */ private function findAttribute( - ClassMethod | Property | ClassLike | Param $node, + $node, string $desiredAttributeClass ): ?Attribute { $attributes = $this->findAttributes($node); diff --git a/src/NodeAnalyzer/EnumAnalyzer.php b/src/NodeAnalyzer/EnumAnalyzer.php index b5f8f94f..87196124 100644 --- a/src/NodeAnalyzer/EnumAnalyzer.php +++ b/src/NodeAnalyzer/EnumAnalyzer.php @@ -14,9 +14,14 @@ final class EnumAnalyzer { - public function __construct( - private readonly BarePhpDocParser $barePhpDocParser - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\PhpDoc\BarePhpDocParser + */ + private $barePhpDocParser; + public function __construct(BarePhpDocParser $barePhpDocParser) + { + $this->barePhpDocParser = $barePhpDocParser; } public function detect(Scope $scope, ClassLike $classLike): bool @@ -39,7 +44,7 @@ public function detect(Scope $scope, ClassLike $classLike): bool } // is in /Enum/ namespace - return str_contains($classReflection->getName(), '\\Enum\\'); + return strpos($classReflection->getName(), '\\Enum\\') !== false; } private function hasEnumAnnotation(Class_ $class): bool diff --git a/src/NodeFinder/ClassMethodNodeFinder.php b/src/NodeFinder/ClassMethodNodeFinder.php index bd1e8b65..f8f63d86 100644 --- a/src/NodeFinder/ClassMethodNodeFinder.php +++ b/src/NodeFinder/ClassMethodNodeFinder.php @@ -14,11 +14,15 @@ final class ClassMethodNodeFinder { - public function __construct( - private readonly ReflectionParser $reflectionParser, - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\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 77832c77..2085f92e 100644 --- a/src/NodeFinder/MethodCallNodeFinder.php +++ b/src/NodeFinder/MethodCallNodeFinder.php @@ -15,13 +15,27 @@ final class MethodCallNodeFinder { - public function __construct( - private readonly ReflectionParser $reflectionParser, - private readonly NodeFinder $nodeFinder, - private readonly NodeComparator $nodeComparator, - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\Reflection\ReflectionParser + */ + private $reflectionParser; + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; + /** + * @readonly + * @var \Symplify\PHPStanRules\Printer\NodeComparator + */ + private $nodeComparator; + public function __construct(ReflectionParser $reflectionParser, NodeFinder $nodeFinder, NodeComparator $nodeComparator) + { + $this->reflectionParser = $reflectionParser; + $this->nodeFinder = $nodeFinder; + $this->nodeComparator = $nodeComparator; } - /** * @return MethodCall[] */ diff --git a/src/NodeFinder/ReturnNodeFinder.php b/src/NodeFinder/ReturnNodeFinder.php index becdd1ec..ca0b03f2 100644 --- a/src/NodeFinder/ReturnNodeFinder.php +++ b/src/NodeFinder/ReturnNodeFinder.php @@ -14,12 +14,17 @@ final class ReturnNodeFinder { - public function __construct( - private readonly SimpleCallableNodeTraverser $simpleCallableNodeTraverser - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeTraverser\SimpleCallableNodeTraverser + */ + private $simpleCallableNodeTraverser; + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + { + $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } - 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/NodeFinder/TypeAwareNodeFinder.php b/src/NodeFinder/TypeAwareNodeFinder.php index a90d7a44..47ecf92b 100644 --- a/src/NodeFinder/TypeAwareNodeFinder.php +++ b/src/NodeFinder/TypeAwareNodeFinder.php @@ -12,19 +12,24 @@ */ final class TypeAwareNodeFinder { - public function __construct( - private readonly NodeFinder $nodeFinder - ) { + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; + public function __construct(NodeFinder $nodeFinder) + { + $this->nodeFinder = $nodeFinder; } /** * @template TNode as Node * - * @param Node[]|Node $nodes + * @param mixed[]|\PhpParser\Node $nodes * @param class-string $type * @return TNode|null */ - public function findFirstInstanceOf(array|Node $nodes, string $type): ?Node + public function findFirstInstanceOf($nodes, string $type): ?Node { return $this->nodeFinder->findFirstInstanceOf($nodes, $type); } diff --git a/src/NodeTraverser/SimpleCallableNodeTraverser.php b/src/NodeTraverser/SimpleCallableNodeTraverser.php index 7bc87b63..e2a050c9 100644 --- a/src/NodeTraverser/SimpleCallableNodeTraverser.php +++ b/src/NodeTraverser/SimpleCallableNodeTraverser.php @@ -15,9 +15,9 @@ final class SimpleCallableNodeTraverser { /** * @param callable(Node $node): (int|Node|null) $callable - * @param Node|Node[]|null $nodes + * @param \PhpParser\Node|mixed[]|null $nodes */ - public function traverseNodesWithCallable(Node | array | null $nodes, callable $callable): void + public function traverseNodesWithCallable($nodes, callable $callable): void { if ($nodes === null) { return; diff --git a/src/NodeVisitor/CallableNodeVisitor.php b/src/NodeVisitor/CallableNodeVisitor.php index 99c77419..86545660 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; diff --git a/src/NodeVisitor/FlatConcatFindingNodeVisitor.php b/src/NodeVisitor/FlatConcatFindingNodeVisitor.php index 3271c703..2a9474b6 100644 --- a/src/NodeVisitor/FlatConcatFindingNodeVisitor.php +++ b/src/NodeVisitor/FlatConcatFindingNodeVisitor.php @@ -12,14 +12,19 @@ final class FlatConcatFindingNodeVisitor extends NodeVisitorAbstract { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\FileCheckingFuncCallAnalyzer + */ + private $fileCheckingFuncCallAnalyzer; /** * @var Concat[] */ - private array $foundNodes = []; + private $foundNodes = []; - public function __construct( - private readonly FileCheckingFuncCallAnalyzer $fileCheckingFuncCallAnalyzer - ) { + public function __construct(FileCheckingFuncCallAnalyzer $fileCheckingFuncCallAnalyzer) + { + $this->fileCheckingFuncCallAnalyzer = $fileCheckingFuncCallAnalyzer; } /** @@ -31,7 +36,10 @@ public function beforeTraverse(array $nodes): ?array return null; } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PhpParser\Node|null + */ + public function enterNode(Node $node) { if ($this->fileCheckingFuncCallAnalyzer->isFileExistCheck($node)) { return NodeTraverser::DONT_TRAVERSE_CHILDREN; diff --git a/src/NodeVisitor/HasScopedReturnNodeVisitor.php b/src/NodeVisitor/HasScopedReturnNodeVisitor.php index 58fc19d4..4a3de962 100644 --- a/src/NodeVisitor/HasScopedReturnNodeVisitor.php +++ b/src/NodeVisitor/HasScopedReturnNodeVisitor.php @@ -13,12 +13,19 @@ final class HasScopedReturnNodeVisitor extends NodeVisitorAbstract { - public function __construct( - private bool $hasReturn = false - ) { + /** + * @var bool + */ + private $hasReturn = false; + public function __construct(bool $hasReturn = false) + { + $this->hasReturn = $hasReturn; } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PhpParser\Node|null + */ + public function enterNode(Node $node) { if ($node instanceof Closure) { return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; diff --git a/src/ObjectCalisthenics/Rules/NoShortNameRule.php b/src/ObjectCalisthenics/Rules/NoShortNameRule.php index 7c83cda3..cfa7490c 100644 --- a/src/ObjectCalisthenics/Rules/NoShortNameRule.php +++ b/src/ObjectCalisthenics/Rules/NoShortNameRule.php @@ -24,22 +24,30 @@ * * @see \Symplify\PHPStanRules\Tests\ObjectCalisthenics\Rules\NoShortNameRule\NoShortNameRuleTest */ -final class NoShortNameRule extends AbstractSymplifyRule implements ConfigurableRuleInterface +final class NoShortNameRule extends AbstractSymplifyRule { + /** + * @readonly + * @var int + */ + private $minNameLength; + /** + * @var string[] + * @readonly + */ + private $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd']; /** * @var string */ public const ERROR_MESSAGE = 'Do not name "%s", shorter than %d chars'; - /** * @param string[] $allowedShortNames */ - public function __construct( - private readonly int $minNameLength, - private readonly array $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd'] - ) { + public function __construct(int $minNameLength, array $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd']) + { + $this->minNameLength = $minNameLength; + $this->allowedShortNames = $allowedShortNames; } - /** * @return array> */ @@ -55,7 +63,6 @@ public function getNodeTypes(): array Param::class, ]; } - /** * @param ClassLike|Function_|ClassMethod|Const_|PropertyProperty|Variable|Param $node * @return array @@ -82,7 +89,6 @@ public function process(Node $node, Scope $scope): array $errorMessage = sprintf(self::ERROR_MESSAGE, $name, $this->minNameLength); return [$errorMessage]; } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition(self::ERROR_MESSAGE, [ @@ -105,7 +111,6 @@ function isClass() ), ]); } - /** * @return string[] */ @@ -123,7 +128,6 @@ private function processVariable(Variable $variable): array $errorMessage = sprintf(self::ERROR_MESSAGE, $variableName, $this->minNameLength); return [$errorMessage]; } - private function isNameValid(string $name): bool { if (Strings::length($name) >= $this->minNameLength) { diff --git a/src/ParentClassMethodNodeResolver.php b/src/ParentClassMethodNodeResolver.php index 16bbf4d4..5a7898e5 100644 --- a/src/ParentClassMethodNodeResolver.php +++ b/src/ParentClassMethodNodeResolver.php @@ -12,10 +12,20 @@ final class ParentClassMethodNodeResolver { - public function __construct( - private readonly ReflectionParser $reflectionParser, - private readonly ReflectionProvider $reflectionProvider - ) { + /** + * @readonly + * @var \Symplify\PHPStanRules\Reflection\ReflectionParser + */ + private $reflectionParser; + /** + * @readonly + * @var \PHPStan\Reflection\ReflectionProvider + */ + private $reflectionProvider; + public function __construct(ReflectionParser $reflectionParser, ReflectionProvider $reflectionProvider) + { + $this->reflectionParser = $reflectionParser; + $this->reflectionProvider = $reflectionProvider; } public function resolveParentClassMethod(Scope $scope, string $methodName): ?ClassMethod @@ -48,7 +58,9 @@ private function getParentClassReflections(Scope $scope): array // all parent classes and interfaces return array_filter( $mainClassReflection->getAncestors(), - static fn (ClassReflection $classReflection): bool => $classReflection !== $mainClassReflection + static function (ClassReflection $classReflection) use ($mainClassReflection) : bool { + return $classReflection !== $mainClassReflection; + } ); } } diff --git a/src/PhpDoc/ApiDocStmtAnalyzer.php b/src/PhpDoc/ApiDocStmtAnalyzer.php index baac14ee..572ba433 100644 --- a/src/PhpDoc/ApiDocStmtAnalyzer.php +++ b/src/PhpDoc/ApiDocStmtAnalyzer.php @@ -15,7 +15,7 @@ public function isApiDoc(ClassMethod $classMethod, ClassReflection $classReflect { if ($classReflection->getResolvedPhpDoc() instanceof ResolvedPhpDocBlock) { $resolvedPhpDoc = $classReflection->getResolvedPhpDoc(); - if (str_contains($resolvedPhpDoc->getPhpDocString(), '@api')) { + if (strpos($resolvedPhpDoc->getPhpDocString(), '@api') !== false) { return true; } } @@ -25,6 +25,6 @@ public function isApiDoc(ClassMethod $classMethod, ClassReflection $classReflect return false; } - return str_contains($docComment->getText(), '@api'); + return strpos($docComment->getText(), '@api') !== false; } } diff --git a/src/PhpDoc/BarePhpDocParser.php b/src/PhpDoc/BarePhpDocParser.php index 0617eecf..0678bfef 100644 --- a/src/PhpDoc/BarePhpDocParser.php +++ b/src/PhpDoc/BarePhpDocParser.php @@ -14,10 +14,20 @@ final class BarePhpDocParser { - public function __construct( - private readonly PhpDocParser $phpDocParser, - private readonly Lexer $lexer - ) { + /** + * @readonly + * @var \PHPStan\PhpDocParser\Parser\PhpDocParser + */ + private $phpDocParser; + /** + * @readonly + * @var \PHPStan\PhpDocParser\Lexer\Lexer + */ + private $lexer; + public function __construct(PhpDocParser $phpDocParser, Lexer $lexer) + { + $this->phpDocParser = $phpDocParser; + $this->lexer = $lexer; } /** diff --git a/src/PhpDoc/PhpDocResolver.php b/src/PhpDoc/PhpDocResolver.php index fd892cb7..f1c47ae8 100644 --- a/src/PhpDoc/PhpDocResolver.php +++ b/src/PhpDoc/PhpDocResolver.php @@ -12,9 +12,14 @@ final class PhpDocResolver { - public function __construct( - private readonly FileTypeMapper $fileTypeMapper - ) { + /** + * @readonly + * @var \PHPStan\Type\FileTypeMapper + */ + private $fileTypeMapper; + public function __construct(FileTypeMapper $fileTypeMapper) + { + $this->fileTypeMapper = $fileTypeMapper; } public function resolve(Scope $scope, ClassReflection $classReflection, Doc $doc): ResolvedPhpDocBlock diff --git a/src/PhpDocParser/PhpDocNodeTraverser.php b/src/PhpDocParser/PhpDocNodeTraverser.php index eab2d3f4..9eba9e07 100644 --- a/src/PhpDocParser/PhpDocNodeTraverser.php +++ b/src/PhpDocParser/PhpDocNodeTraverser.php @@ -65,12 +65,12 @@ final class PhpDocNodeTraverser /** * @var bool Whether traversal should be stopped */ - private bool $stopTraversal = false; + private $stopTraversal = false; /** * @var PhpDocNodeVisitorInterface[] */ - private array $phpDocNodeVisitors = []; + private $phpDocNodeVisitors = []; public function addPhpDocNodeVisitor(PhpDocNodeVisitorInterface $phpDocNodeVisitor): void { diff --git a/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php b/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php index 773eea4e..c4a251ce 100644 --- a/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php +++ b/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php @@ -16,7 +16,10 @@ public function beforeTraverse(Node $node): void { } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PHPStan\PhpDocParser\Ast\Node|null + */ + public function enterNode(Node $node) { return null; } @@ -24,7 +27,7 @@ public function enterNode(Node $node): int|Node|null /** * @return null|int|\PhpParser\Node|Node[] Replacement node (or special return) */ - public function leaveNode(Node $node): int|\PhpParser\Node|array|null + public function leaveNode(Node $node) { return null; } diff --git a/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php b/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php index 3f6789dd..10294cc5 100644 --- a/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php +++ b/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php @@ -8,6 +8,11 @@ final class CallablePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { + /** + * @readonly + * @var string|null + */ + private $docContent; /** * @var callable(Node, string|null): (int|null|Node) */ @@ -18,12 +23,16 @@ final class CallablePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor */ public function __construct( callable $callable, - private readonly ?string $docContent + ?string $docContent ) { + $this->docContent = $docContent; $this->callable = $callable; } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PHPStan\PhpDocParser\Ast\Node|null + */ + public function enterNode(Node $node) { $callable = $this->callable; return $callable($node, $this->docContent); diff --git a/src/Printer/CollectorMetadataPrinter.php b/src/Printer/CollectorMetadataPrinter.php index 60748ac6..48d868b0 100644 --- a/src/Printer/CollectorMetadataPrinter.php +++ b/src/Printer/CollectorMetadataPrinter.php @@ -28,7 +28,11 @@ final class CollectorMetadataPrinter { - private readonly Standard $printerStandard; + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $printerStandard; public function __construct() { diff --git a/src/Printer/NodeComparator.php b/src/Printer/NodeComparator.php index 3493e1ca..59d33f4e 100644 --- a/src/Printer/NodeComparator.php +++ b/src/Printer/NodeComparator.php @@ -10,9 +10,14 @@ final class NodeComparator { - public function __construct( - private readonly 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 6aa8b217..bebbd7cd 100644 --- a/src/Reflection/ReflectionParser.php +++ b/src/Reflection/ReflectionParser.php @@ -25,21 +25,34 @@ */ final class ReflectionParser { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeFinder\TypeAwareNodeFinder + */ + private $typeAwareNodeFinder; /** * @var array */ - private array $classesByFilename = []; + private $classesByFilename = []; - private readonly Parser $parser; + /** + * @readonly + * @var \PhpParser\Parser + */ + private $parser; public function __construct( - private readonly TypeAwareNodeFinder $typeAwareNodeFinder + TypeAwareNodeFinder $typeAwareNodeFinder ) { + $this->typeAwareNodeFinder = $typeAwareNodeFinder; $parserFactory = new ParserFactory(); $this->parser = $parserFactory->create(ParserFactory::PREFER_PHP7); } - public function parseMethodReflection(ReflectionMethod|MethodReflection $reflectionMethod): ?ClassMethod + /** + * @param \ReflectionMethod|\PHPStan\Reflection\MethodReflection $reflectionMethod + */ + public function parseMethodReflection($reflectionMethod): ?ClassMethod { $classLike = $this->parseNativeClassReflection($reflectionMethod->getDeclaringClass()); if (! $classLike instanceof ClassLike) { @@ -69,7 +82,10 @@ public function parseClassReflection(ClassReflection $classReflection): ?ClassLi return $this->parseFilenameToClass($fileName); } - private function parseNativeClassReflection(ReflectionClass|ClassReflection $reflectionClass): ?ClassLike + /** + * @param \ReflectionClass|\PHPStan\Reflection\ClassReflection $reflectionClass + */ + private function parseNativeClassReflection($reflectionClass): ?ClassLike { $fileName = $reflectionClass->getFileName(); if ($fileName === false) { @@ -83,7 +99,7 @@ private function parseNativeClassReflection(ReflectionClass|ClassReflection $ref 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]; @@ -99,7 +115,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/AbstractSymplifyRule.php b/src/Rules/AbstractSymplifyRule.php index 35ef5530..906fcd59 100644 --- a/src/Rules/AbstractSymplifyRule.php +++ b/src/Rules/AbstractSymplifyRule.php @@ -14,7 +14,7 @@ /** * @implements Rule */ -abstract class AbstractSymplifyRule implements Rule, ManyNodeRuleInterface, DocumentedRuleInterface +abstract class AbstractSymplifyRule implements Rule, ManyNodeRuleInterface { /** * @return class-string diff --git a/src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php b/src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php index 7b6b3582..b496d20f 100644 --- a/src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php +++ b/src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php @@ -18,7 +18,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\AnnotateRegexClassConstWithRegexLinkRule\AnnotateRegexClassConstWithRegexLinkRuleTest */ -final class AnnotateRegexClassConstWithRegexLinkRule implements Rule, DocumentedRuleInterface +final class AnnotateRegexClassConstWithRegexLinkRule implements Rule { /** * @var string @@ -126,11 +126,11 @@ private function hasDocBlockWithRegexLink(ClassConst $classConst): bool } $docCommentText = $docComment->getText(); - return \str_contains($docCommentText, '@see https://regex101.com/r'); + return strpos($docCommentText, '@see https://regex101.com/r') !== false; } private function isRegexPatternConstantName(string $constantName): bool { - return \str_ends_with($constantName, '_REGEX'); + return substr_compare($constantName, '_REGEX', -strlen('_REGEX')) === 0; } } diff --git a/src/Rules/CheckClassNamespaceFollowPsr4Rule.php b/src/Rules/CheckClassNamespaceFollowPsr4Rule.php index f09e453e..965598c2 100644 --- a/src/Rules/CheckClassNamespaceFollowPsr4Rule.php +++ b/src/Rules/CheckClassNamespaceFollowPsr4Rule.php @@ -19,8 +19,18 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\CheckClassNamespaceFollowPsr4Rule\CheckClassNamespaceFollowPsr4RuleTest */ -final class CheckClassNamespaceFollowPsr4Rule implements Rule, DocumentedRuleInterface +final class CheckClassNamespaceFollowPsr4Rule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\Composer\Psr4PathValidator + */ + private $psr4PathValidator; + /** + * @readonly + * @var \Symplify\PHPStanRules\Composer\ClassNamespaceMatcher + */ + private $classNamespaceMatcher; /** * @var string */ @@ -29,13 +39,15 @@ final class CheckClassNamespaceFollowPsr4Rule implements Rule, DocumentedRuleInt /** * @var array */ - private array $autoloadPsr4Paths = []; + private $autoloadPsr4Paths = []; public function __construct( ComposerAutoloadResolver $composerAutoloadResolver, - private readonly Psr4PathValidator $psr4PathValidator, - private readonly ClassNamespaceMatcher $classNamespaceMatcher + Psr4PathValidator $psr4PathValidator, + ClassNamespaceMatcher $classNamespaceMatcher ) { + $this->psr4PathValidator = $psr4PathValidator; + $this->classNamespaceMatcher = $classNamespaceMatcher; $this->autoloadPsr4Paths = $composerAutoloadResolver->getPsr4Autoload(); } diff --git a/src/Rules/CheckRequiredInterfaceInContractNamespaceRule.php b/src/Rules/CheckRequiredInterfaceInContractNamespaceRule.php index eb3ec08c..1f4fddc1 100644 --- a/src/Rules/CheckRequiredInterfaceInContractNamespaceRule.php +++ b/src/Rules/CheckRequiredInterfaceInContractNamespaceRule.php @@ -17,7 +17,7 @@ * @see \Symplify\PHPStanRules\Tests\Rules\CheckRequiredInterfaceInContractNamespaceRule\CheckRequiredInterfaceInContractNamespaceRuleTest * @implements Rule */ -final class CheckRequiredInterfaceInContractNamespaceRule implements Rule, DocumentedRuleInterface +final class CheckRequiredInterfaceInContractNamespaceRule implements Rule { /** * @var string diff --git a/src/Rules/CheckTypehintCallerTypeRule.php b/src/Rules/CheckTypehintCallerTypeRule.php index d428c8ff..704654e4 100644 --- a/src/Rules/CheckTypehintCallerTypeRule.php +++ b/src/Rules/CheckTypehintCallerTypeRule.php @@ -33,17 +33,27 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\CheckTypehintCallerTypeRule\CheckTypehintCallerTypeRuleTest */ -final class CheckTypehintCallerTypeRule implements Rule, DocumentedRuleInterface +final class CheckTypehintCallerTypeRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeFinder\MethodCallNodeFinder + */ + private $methodCallNodeFinder; + /** + * @readonly + * @var \Symplify\PHPStanRules\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 readonly MethodCallNodeFinder $methodCallNodeFinder, - private readonly ClassMethodNodeFinder $classMethodNodeFinder - ) { + public function __construct(MethodCallNodeFinder $methodCallNodeFinder, ClassMethodNodeFinder $classMethodNodeFinder) + { + $this->methodCallNodeFinder = $methodCallNodeFinder; + $this->classMethodNodeFinder = $classMethodNodeFinder; } /** diff --git a/src/Rules/ClassNameRespectsParentSuffixRule.php b/src/Rules/ClassNameRespectsParentSuffixRule.php index 298a07da..5bc52062 100644 --- a/src/Rules/ClassNameRespectsParentSuffixRule.php +++ b/src/Rules/ClassNameRespectsParentSuffixRule.php @@ -25,8 +25,13 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\ClassNameRespectsParentSuffixRule\ClassNameRespectsParentSuffixRuleTest */ -final class ClassNameRespectsParentSuffixRule implements Rule, DocumentedRuleInterface, ConfigurableRuleInterface +final class ClassNameRespectsParentSuffixRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\Naming\ClassToSuffixResolver + */ + private $classToSuffixResolver; /** * @var string */ @@ -50,15 +55,14 @@ final class ClassNameRespectsParentSuffixRule implements Rule, DocumentedRuleInt /** * @var string[] */ - private array $parentClasses = []; + private $parentClasses = []; /** * @param class-string[] $parentClasses */ - public function __construct( - private readonly ClassToSuffixResolver $classToSuffixResolver, - array $parentClasses = [], - ) { + public function __construct(ClassToSuffixResolver $classToSuffixResolver, array $parentClasses = []) + { + $this->classToSuffixResolver = $classToSuffixResolver; $this->parentClasses = array_merge($parentClasses, self::DEFAULT_PARENT_CLASSES); } @@ -127,7 +131,7 @@ private function processClassNameAndShort(ClassReflection $classReflection): arr } $expectedSuffix = $this->classToSuffixResolver->resolveFromClass($parentClass); - if (\str_ends_with($classReflection->getName(), $expectedSuffix)) { + if (substr_compare($classReflection->getName(), $expectedSuffix, -strlen($expectedSuffix)) === 0) { return []; } diff --git a/src/Rules/Complexity/ForbiddenArrayMethodCallRule.php b/src/Rules/Complexity/ForbiddenArrayMethodCallRule.php index 872afa46..2d0c4650 100644 --- a/src/Rules/Complexity/ForbiddenArrayMethodCallRule.php +++ b/src/Rules/Complexity/ForbiddenArrayMethodCallRule.php @@ -18,7 +18,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Complexity\ForbiddenArrayMethodCallRule\ForbiddenArrayMethodCallRuleTest */ -final class ForbiddenArrayMethodCallRule implements Rule, DocumentedRuleInterface +final class ForbiddenArrayMethodCallRule implements Rule { /** * @var string diff --git a/src/Rules/Domain/RequireAttributeNamespaceRule.php b/src/Rules/Domain/RequireAttributeNamespaceRule.php index bab902cc..dafcd091 100644 --- a/src/Rules/Domain/RequireAttributeNamespaceRule.php +++ b/src/Rules/Domain/RequireAttributeNamespaceRule.php @@ -15,7 +15,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Domain\RequireAttributeNamespaceRule\RequireAttributeNamespaceRuleTest */ -final class RequireAttributeNamespaceRule implements Rule, DocumentedRuleInterface +final class RequireAttributeNamespaceRule implements Rule { /** * @var string @@ -70,7 +70,7 @@ public function processNode(Node $node, Scope $scope): array // is class in "Attribute" namespace? $className = $classReflection->getName(); - if (str_contains($className, '\\Attribute\\')) { + if (strpos($className, '\\Attribute\\') !== false) { return []; } diff --git a/src/Rules/Domain/RequireExceptionNamespaceRule.php b/src/Rules/Domain/RequireExceptionNamespaceRule.php index afcd522c..bf922c56 100644 --- a/src/Rules/Domain/RequireExceptionNamespaceRule.php +++ b/src/Rules/Domain/RequireExceptionNamespaceRule.php @@ -15,7 +15,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Domain\RequireExceptionNamespaceRule\RequireExceptionNamespaceRuleTest */ -final class RequireExceptionNamespaceRule implements Rule, DocumentedRuleInterface +final class RequireExceptionNamespaceRule implements Rule { /** * @var string @@ -73,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array // is class in "Exception" namespace? $className = $classReflection->getName(); - if (str_contains($className, '\\Exception\\')) { + if (strpos($className, '\\Exception\\') !== false) { return []; } diff --git a/src/Rules/Enum/RequireUniqueEnumConstantRule.php b/src/Rules/Enum/RequireUniqueEnumConstantRule.php index d57dbca5..a306bd11 100644 --- a/src/Rules/Enum/RequireUniqueEnumConstantRule.php +++ b/src/Rules/Enum/RequireUniqueEnumConstantRule.php @@ -18,16 +18,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Enum\RequireUniqueEnumConstantRule\RequireUniqueEnumConstantRuleTest */ -final class RequireUniqueEnumConstantRule implements Rule, DocumentedRuleInterface +final class RequireUniqueEnumConstantRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\EnumAnalyzer + */ + private $enumAnalyzer; /** * @var string */ public const ERROR_MESSAGE = 'Enum constants "%s" are duplicated. Make them unique instead'; - public function __construct( - private readonly EnumAnalyzer $enumAnalyzer - ) { + public function __construct(EnumAnalyzer $enumAnalyzer) + { + $this->enumAnalyzer = $enumAnalyzer; } /** diff --git a/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php b/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php index 4768b1a5..5b132895 100644 --- a/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php +++ b/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php @@ -20,7 +20,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Explicit\ExplicitClassPrefixSuffixRule\ExplicitClassPrefixSuffixRuleTest */ -final class ExplicitClassPrefixSuffixRule implements Rule, DocumentedRuleInterface +final class ExplicitClassPrefixSuffixRule implements Rule { /** * @api @@ -117,11 +117,11 @@ public function processNode(Node $node, Scope $scope): array */ private function processInterfaceSuffix(Identifier $identifier): array { - if (str_ends_with($identifier->toString(), 'Interface')) { + if (substr_compare($identifier->toString(), 'Interface', -strlen('Interface')) === 0) { return []; } - if (str_ends_with($identifier->toString(), 'Trait')) { + if (substr_compare($identifier->toString(), 'Trait', -strlen('Trait')) === 0) { return [self::TRAIT_ERROR_MESSAGE]; } @@ -133,7 +133,7 @@ private function processInterfaceSuffix(Identifier $identifier): array */ private function processTraitSuffix(Identifier $identifier): array { - if (str_ends_with($identifier->toString(), 'Trait')) { + if (substr_compare($identifier->toString(), 'Trait', -strlen('Trait')) === 0) { return []; } @@ -145,19 +145,19 @@ private function processTraitSuffix(Identifier $identifier): array */ private function processClassSuffix(Identifier $identifier, bool $isAbstract): array { - if ($isAbstract && ! str_starts_with($identifier->toString(), 'Abstract')) { + if ($isAbstract && strncmp($identifier->toString(), 'Abstract', strlen('Abstract')) !== 0) { return [self::ABSTRACT_ERROR_MESSAGE]; } - if (! $isAbstract && str_starts_with($identifier->toString(), 'Abstract')) { + if (! $isAbstract && strncmp($identifier->toString(), 'Abstract', strlen('Abstract')) === 0) { return [self::ABSTRACT_ERROR_MESSAGE]; } - if (str_ends_with($identifier->toString(), 'Interface')) { + if (substr_compare($identifier->toString(), 'Interface', -strlen('Interface')) === 0) { return [self::INTERFACE_ERROR_MESSAGE]; } - if (str_ends_with($identifier->toString(), 'Trait')) { + if (substr_compare($identifier->toString(), 'Trait', -strlen('Trait')) === 0) { return [self::TRAIT_ERROR_MESSAGE]; } diff --git a/src/Rules/Explicit/NoMixedMethodCallerRule.php b/src/Rules/Explicit/NoMixedMethodCallerRule.php index 2369482b..bb2bfbb0 100644 --- a/src/Rules/Explicit/NoMixedMethodCallerRule.php +++ b/src/Rules/Explicit/NoMixedMethodCallerRule.php @@ -18,16 +18,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Explicit\NoMixedMethodCallerRule\NoMixedMethodCallerRuleTest */ -final class NoMixedMethodCallerRule implements Rule, DocumentedRuleInterface +final class NoMixedMethodCallerRule implements Rule { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $printerStandard; /** * @var string */ public const ERROR_MESSAGE = 'Anonymous variable in a `%s->...()` method call can lead to false dead methods. Make sure the variable type is known'; - public function __construct( - private readonly Standard $printerStandard, - ) { + public function __construct(Standard $printerStandard) + { + $this->printerStandard = $printerStandard; } /** diff --git a/src/Rules/Explicit/NoMixedPropertyFetcherRule.php b/src/Rules/Explicit/NoMixedPropertyFetcherRule.php index d170b543..d2bb93a2 100644 --- a/src/Rules/Explicit/NoMixedPropertyFetcherRule.php +++ b/src/Rules/Explicit/NoMixedPropertyFetcherRule.php @@ -17,16 +17,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Explicit\NoMixedPropertyFetcherRule\NoMixedPropertyFetcherRuleTest */ -final class NoMixedPropertyFetcherRule implements Rule, DocumentedRuleInterface +final class NoMixedPropertyFetcherRule implements Rule { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $standard; /** * @var string */ public const ERROR_MESSAGE = 'Anonymous variables in a "%s->..." property fetch can lead to false dead property. Make sure the variable type is known'; - public function __construct( - private readonly Standard $standard, - ) { + public function __construct(Standard $standard) + { + $this->standard = $standard; } /** diff --git a/src/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule.php b/src/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule.php index fdf57cf4..7cfd2d6b 100644 --- a/src/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule.php +++ b/src/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule.php @@ -23,17 +23,27 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\Explicit\RequireSpecificReturnTypeOverAbstractRule\RequireSpecificReturnTypeOverAbstractRuleTest */ -final class RequireSpecificReturnTypeOverAbstractRule implements Rule, DocumentedRuleInterface +final class RequireSpecificReturnTypeOverAbstractRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeFinder\ReturnNodeFinder + */ + private $returnNodeFinder; + /** + * @readonly + * @var \Symplify\PHPStanRules\Reflection\MethodNodeAnalyser + */ + private $methodNodeAnalyser; /** * @var string */ public const ERROR_MESSAGE = 'Provide more specific return type "%s" over abstract one'; - public function __construct( - private readonly ReturnNodeFinder $returnNodeFinder, - private readonly MethodNodeAnalyser $methodNodeAnalyser, - ) { + public function __construct(ReturnNodeFinder $returnNodeFinder, MethodNodeAnalyser $methodNodeAnalyser) + { + $this->returnNodeFinder = $returnNodeFinder; + $this->methodNodeAnalyser = $methodNodeAnalyser; } public function getRuleDefinition(): RuleDefinition diff --git a/src/Rules/ForbiddenExtendOfNonAbstractClassRule.php b/src/Rules/ForbiddenExtendOfNonAbstractClassRule.php index 20c622f8..4ea228c5 100644 --- a/src/Rules/ForbiddenExtendOfNonAbstractClassRule.php +++ b/src/Rules/ForbiddenExtendOfNonAbstractClassRule.php @@ -16,7 +16,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenExtendOfNonAbstractClassRule\ForbiddenExtendOfNonAbstractClassRuleTest */ -final class ForbiddenExtendOfNonAbstractClassRule implements Rule, DocumentedRuleInterface +final class ForbiddenExtendOfNonAbstractClassRule implements Rule { /** * @var string @@ -59,7 +59,7 @@ public function processNode(Node $node, Scope $scope): array // skip vendor based classes, as designed for extension $fileName = $parentClassReflection->getFileName(); - if (is_string($fileName) && str_contains($fileName, 'vendor')) { + if (is_string($fileName) && strpos($fileName, 'vendor') !== false) { return []; } diff --git a/src/Rules/ForbiddenFuncCallRule.php b/src/Rules/ForbiddenFuncCallRule.php index 6b633d1c..8fc93bbe 100644 --- a/src/Rules/ForbiddenFuncCallRule.php +++ b/src/Rules/ForbiddenFuncCallRule.php @@ -23,8 +23,23 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenFuncCallRule\ForbiddenFuncCallRuleTest */ -final class ForbiddenFuncCallRule implements Rule, DocumentedRuleInterface, ConfigurableRuleInterface +final class ForbiddenFuncCallRule implements Rule { + /** + * @var string[]|array<(string | int), string> + * @readonly + */ + private $forbiddenFunctions; + /** + * @readonly + * @var \Symplify\PHPStanRules\Matcher\ArrayStringAndFnMatcher + */ + private $arrayStringAndFnMatcher; + /** + * @readonly + * @var \Symplify\PHPStanRules\Formatter\RequiredWithMessageFormatter + */ + private $requiredWithMessageFormatter; /** * @var string */ @@ -33,11 +48,11 @@ final class ForbiddenFuncCallRule implements Rule, DocumentedRuleInterface, Conf /** * @param string[]|array $forbiddenFunctions */ - public function __construct( - private readonly array $forbiddenFunctions, - private readonly ArrayStringAndFnMatcher $arrayStringAndFnMatcher, - private readonly RequiredWithMessageFormatter $requiredWithMessageFormatter, - ) { + public function __construct(array $forbiddenFunctions, ArrayStringAndFnMatcher $arrayStringAndFnMatcher, RequiredWithMessageFormatter $requiredWithMessageFormatter) + { + $this->forbiddenFunctions = $forbiddenFunctions; + $this->arrayStringAndFnMatcher = $arrayStringAndFnMatcher; + $this->requiredWithMessageFormatter = $requiredWithMessageFormatter; } /** diff --git a/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php b/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php index 3bec2ef9..97e54883 100644 --- a/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php +++ b/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php @@ -18,16 +18,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenMultipleClassLikeInOneFileRule\ForbiddenMultipleClassLikeInOneFileRuleTest */ -final class ForbiddenMultipleClassLikeInOneFileRule implements Rule, DocumentedRuleInterface +final class ForbiddenMultipleClassLikeInOneFileRule implements Rule { + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; /** * @var string */ public const ERROR_MESSAGE = 'Multiple class/interface/trait is not allowed in single file'; - public function __construct( - private readonly NodeFinder $nodeFinder - ) { + public function __construct(NodeFinder $nodeFinder) + { + $this->nodeFinder = $nodeFinder; } /** diff --git a/src/Rules/ForbiddenNodeRule.php b/src/Rules/ForbiddenNodeRule.php index a2576f51..ade2d760 100644 --- a/src/Rules/ForbiddenNodeRule.php +++ b/src/Rules/ForbiddenNodeRule.php @@ -21,8 +21,13 @@ * @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenNodeRule\ForbiddenNodeRuleTest * @implements Rule */ -final class ForbiddenNodeRule implements Rule, DocumentedRuleInterface, ConfigurableRuleInterface +final class ForbiddenNodeRule implements Rule { + /** + * @readonly + * @var \PhpParser\PrettyPrinter\Standard + */ + private $standard; /** * @var string */ @@ -31,15 +36,16 @@ final class ForbiddenNodeRule implements Rule, DocumentedRuleInterface, Configur /** * @var array> */ - private array $forbiddenNodes = []; + private $forbiddenNodes = []; /** * @param array> $forbiddenNodes */ public function __construct( - private readonly Standard $standard, + Standard $standard, array $forbiddenNodes ) { + $this->standard = $standard; Assert::allIsAOf($forbiddenNodes, Node::class); $this->forbiddenNodes = $forbiddenNodes; diff --git a/src/Rules/ForbiddenParamTypeRemovalRule.php b/src/Rules/ForbiddenParamTypeRemovalRule.php index dacb42c0..0a080eb8 100644 --- a/src/Rules/ForbiddenParamTypeRemovalRule.php +++ b/src/Rules/ForbiddenParamTypeRemovalRule.php @@ -19,16 +19,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenParamTypeRemovalRule\ForbiddenParamTypeRemovalRuleTest */ -final class ForbiddenParamTypeRemovalRule implements Rule, DocumentedRuleInterface +final class ForbiddenParamTypeRemovalRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\Reflection\MethodNodeAnalyser + */ + private $methodNodeAnalyser; /** * @var string */ public const ERROR_MESSAGE = 'Removing parent param type is forbidden'; - public function __construct( - private readonly MethodNodeAnalyser $methodNodeAnalyser - ) { + public function __construct(MethodNodeAnalyser $methodNodeAnalyser) + { + $this->methodNodeAnalyser = $methodNodeAnalyser; } /** diff --git a/src/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule.php b/src/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule.php index d2224d3a..34f3763e 100644 --- a/src/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule.php +++ b/src/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule.php @@ -24,7 +24,7 @@ * * @implements Rule */ -final class NarrowPublicClassMethodParamTypeByCallerTypeRule implements Rule, DocumentedRuleInterface +final class NarrowPublicClassMethodParamTypeByCallerTypeRule implements Rule { /** * @var string diff --git a/src/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule.php b/src/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule.php index d63b405b..4a3b52e2 100644 --- a/src/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule.php +++ b/src/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule.php @@ -19,7 +19,7 @@ /** * @implements Rule */ -final class NoReturnFalseInNonBoolClassMethodRule implements Rule, DocumentedRuleInterface +final class NoReturnFalseInNonBoolClassMethodRule implements Rule { /** * @api @@ -27,7 +27,11 @@ final class NoReturnFalseInNonBoolClassMethodRule implements Rule, DocumentedRul */ public const ERROR_MESSAGE = 'Returning false in non return bool class method. Use null instead'; - private readonly NodeFinder $nodeFinder; + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; public function __construct( ) { diff --git a/src/Rules/NoArrayAccessOnObjectRule.php b/src/Rules/NoArrayAccessOnObjectRule.php index 73796bec..1a76c718 100644 --- a/src/Rules/NoArrayAccessOnObjectRule.php +++ b/src/Rules/NoArrayAccessOnObjectRule.php @@ -16,7 +16,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoArrayAccessOnObjectRule\NoArrayAccessOnObjectRuleTest */ -final class NoArrayAccessOnObjectRule implements Rule, DocumentedRuleInterface +final class NoArrayAccessOnObjectRule implements Rule { /** * @var string diff --git a/src/Rules/NoDuplicatedShortClassNameRule.php b/src/Rules/NoDuplicatedShortClassNameRule.php index 0c638720..df110799 100644 --- a/src/Rules/NoDuplicatedShortClassNameRule.php +++ b/src/Rules/NoDuplicatedShortClassNameRule.php @@ -18,8 +18,13 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoDuplicatedShortClassNameRule\NoDuplicatedShortClassNameRuleTest */ -final class NoDuplicatedShortClassNameRule implements Rule, DocumentedRuleInterface, ConfigurableRuleInterface +final class NoDuplicatedShortClassNameRule implements Rule { + /** + * @readonly + * @var int + */ + private $toleratedNestingLevel; /** * @var string */ @@ -42,11 +47,11 @@ final class NoDuplicatedShortClassNameRule implements Rule, DocumentedRuleInterf /** * @var array */ - private array $declaredClassesByShortName = []; + private $declaredClassesByShortName = []; - public function __construct( - private readonly int $toleratedNestingLevel - ) { + public function __construct(int $toleratedNestingLevel) + { + $this->toleratedNestingLevel = $toleratedNestingLevel; } /** diff --git a/src/Rules/NoDynamicNameRule.php b/src/Rules/NoDynamicNameRule.php index 35783553..e627ab3b 100644 --- a/src/Rules/NoDynamicNameRule.php +++ b/src/Rules/NoDynamicNameRule.php @@ -23,14 +23,19 @@ */ final class NoDynamicNameRule extends AbstractSymplifyRule { + /** + * @readonly + * @var \Symplify\PHPStanRules\TypeAnalyzer\CallableTypeAnalyzer + */ + private $callableTypeAnalyzer; /** * @var string */ public const ERROR_MESSAGE = 'Use explicit names over dynamic ones'; - public function __construct( - private readonly CallableTypeAnalyzer $callableTypeAnalyzer, - ) { + public function __construct(CallableTypeAnalyzer $callableTypeAnalyzer) + { + $this->callableTypeAnalyzer = $callableTypeAnalyzer; } /** diff --git a/src/Rules/NoInlineStringRegexRule.php b/src/Rules/NoInlineStringRegexRule.php index cc51e5df..d9e903d9 100644 --- a/src/Rules/NoInlineStringRegexRule.php +++ b/src/Rules/NoInlineStringRegexRule.php @@ -21,17 +21,27 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoInlineStringRegexRule\NoInlineStringRegexRuleTest */ -final class NoInlineStringRegexRule implements Rule, DocumentedRuleInterface +final class NoInlineStringRegexRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\RegexFuncCallAnalyzer + */ + private $regexFuncCallAnalyzer; + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\RegexStaticCallAnalyzer + */ + private $regexStaticCallAnalyzer; /** * @var string */ public const ERROR_MESSAGE = 'Use local named constant instead of inline string for regex to explain meaning by constant name'; - public function __construct( - private readonly RegexFuncCallAnalyzer $regexFuncCallAnalyzer, - private readonly RegexStaticCallAnalyzer $regexStaticCallAnalyzer - ) { + public function __construct(RegexFuncCallAnalyzer $regexFuncCallAnalyzer, RegexStaticCallAnalyzer $regexStaticCallAnalyzer) + { + $this->regexFuncCallAnalyzer = $regexFuncCallAnalyzer; + $this->regexStaticCallAnalyzer = $regexStaticCallAnalyzer; } /** diff --git a/src/Rules/NoMissingDirPathRule.php b/src/Rules/NoMissingDirPathRule.php index acf8ef63..bbd90104 100644 --- a/src/Rules/NoMissingDirPathRule.php +++ b/src/Rules/NoMissingDirPathRule.php @@ -26,7 +26,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoMissingDirPathRule\NoMissingDirPathRuleTest */ -final class NoMissingDirPathRule implements Rule, DocumentedRuleInterface +final class NoMissingDirPathRule implements Rule { /** * @var string @@ -134,7 +134,7 @@ private function shouldSkip(string $relativeDirPath): bool return true; } - if (\str_contains($relativeDirPath, '*')) { + if (strpos($relativeDirPath, '*') !== false) { return true; } diff --git a/src/Rules/NoNullableArrayPropertyRule.php b/src/Rules/NoNullableArrayPropertyRule.php index fbd4482d..173d1f34 100644 --- a/src/Rules/NoNullableArrayPropertyRule.php +++ b/src/Rules/NoNullableArrayPropertyRule.php @@ -16,7 +16,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoNullableArrayPropertyRule\NoNullableArrayPropertyRuleTest */ -final class NoNullableArrayPropertyRule implements Rule, DocumentedRuleInterface +final class NoNullableArrayPropertyRule implements Rule { /** * @var string diff --git a/src/Rules/NoReferenceRule.php b/src/Rules/NoReferenceRule.php index 47b584e4..22cec296 100644 --- a/src/Rules/NoReferenceRule.php +++ b/src/Rules/NoReferenceRule.php @@ -24,14 +24,19 @@ */ final class NoReferenceRule extends AbstractSymplifyRule { + /** + * @readonly + * @var \Symplify\PHPStanRules\ParentClassMethodNodeResolver + */ + private $parentClassMethodNodeResolver; /** * @var string */ public const ERROR_MESSAGE = 'Use explicit return value over magic &reference'; - public function __construct( - private readonly ParentClassMethodNodeResolver $parentClassMethodNodeResolver, - ) { + public function __construct(ParentClassMethodNodeResolver $parentClassMethodNodeResolver) + { + $this->parentClassMethodNodeResolver = $parentClassMethodNodeResolver; } /** diff --git a/src/Rules/NoReturnArrayVariableListRule.php b/src/Rules/NoReturnArrayVariableListRule.php index 5a66536a..fdbc43c6 100644 --- a/src/Rules/NoReturnArrayVariableListRule.php +++ b/src/Rules/NoReturnArrayVariableListRule.php @@ -23,8 +23,13 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoReturnArrayVariableListRule\NoReturnArrayVariableListRuleTest */ -final class NoReturnArrayVariableListRule implements Rule, DocumentedRuleInterface +final class NoReturnArrayVariableListRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\ParentClassMethodNodeResolver + */ + private $parentClassMethodNodeResolver; /** * @var string */ @@ -36,9 +41,9 @@ final class NoReturnArrayVariableListRule implements Rule, DocumentedRuleInterfa */ private const TESTS_DIRECTORY_REGEX = '#\/Tests\/#i'; - public function __construct( - private readonly ParentClassMethodNodeResolver $parentClassMethodNodeResolver, - ) { + public function __construct(ParentClassMethodNodeResolver $parentClassMethodNodeResolver) + { + $this->parentClassMethodNodeResolver = $parentClassMethodNodeResolver; } /** @@ -117,11 +122,11 @@ private function shouldSkip(Scope $scope, Return_ $return): bool return true; } - if (str_contains($namespace, 'Enum')) { + if (strpos($namespace, 'Enum') !== false) { return true; } - if (str_contains($namespace, 'ValueObject')) { + if (strpos($namespace, 'ValueObject') !== false) { return true; } diff --git a/src/Rules/NoReturnSetterMethodRule.php b/src/Rules/NoReturnSetterMethodRule.php index 0a4ee1ba..132b3e15 100644 --- a/src/Rules/NoReturnSetterMethodRule.php +++ b/src/Rules/NoReturnSetterMethodRule.php @@ -21,8 +21,13 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\NoReturnSetterMethodRule\NoReturnSetterMethodRuleTest */ -final class NoReturnSetterMethodRule implements Rule, DocumentedRuleInterface +final class NoReturnSetterMethodRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeFinder\TypeAwareNodeFinder + */ + private $typeAwareNodeFinder; /** * @var string */ @@ -34,9 +39,9 @@ final class NoReturnSetterMethodRule implements Rule, DocumentedRuleInterface */ private const SETTER_START_REGEX = '#^set[A-Z]#'; - public function __construct( - private readonly TypeAwareNodeFinder $typeAwareNodeFinder - ) { + public function __construct(TypeAwareNodeFinder $typeAwareNodeFinder) + { + $this->typeAwareNodeFinder = $typeAwareNodeFinder; } /** diff --git a/src/Rules/PHPUnit/NoTestMocksRule.php b/src/Rules/PHPUnit/NoTestMocksRule.php index bfc705e4..9ba5d762 100644 --- a/src/Rules/PHPUnit/NoTestMocksRule.php +++ b/src/Rules/PHPUnit/NoTestMocksRule.php @@ -17,8 +17,13 @@ /** * @implements Rule */ -final class NoTestMocksRule implements Rule, DocumentedRuleInterface +final class NoTestMocksRule implements Rule { + /** + * @var string[] + * @readonly + */ + private $allowedTypes = []; /** * @api * @var string @@ -33,9 +38,9 @@ final class NoTestMocksRule implements Rule, DocumentedRuleInterface /** * @param string[] $allowedTypes */ - public function __construct( - private readonly array $allowedTypes = [] - ) { + public function __construct(array $allowedTypes = []) + { + $this->allowedTypes = $allowedTypes; } /** diff --git a/src/Rules/PreferredClassRule.php b/src/Rules/PreferredClassRule.php index c7a703a0..45284184 100644 --- a/src/Rules/PreferredClassRule.php +++ b/src/Rules/PreferredClassRule.php @@ -22,21 +22,24 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\PreferredClassRule\PreferredClassRuleTest */ -final class PreferredClassRule extends AbstractSymplifyRule implements ConfigurableRuleInterface +final class PreferredClassRule extends AbstractSymplifyRule { + /** + * @var string[] + * @readonly + */ + private $oldToPreferredClasses; /** * @var string */ public const ERROR_MESSAGE = 'Instead of "%s" class/interface use "%s"'; - /** * @param string[] $oldToPreferredClasses */ - public function __construct( - private readonly array $oldToPreferredClasses - ) { + public function __construct(array $oldToPreferredClasses) + { + $this->oldToPreferredClasses = $oldToPreferredClasses; } - /** * @return array> */ @@ -44,7 +47,6 @@ public function getNodeTypes(): array { return [New_::class, Name::class, InClassNode::class, StaticCall::class, Instanceof_::class]; } - /** * @param New_|Name|InClassNode|StaticCall|Instanceof_ $node * @return string[] @@ -65,7 +67,6 @@ public function process(Node $node, Scope $scope): array return $this->processClassName($node->toString()); } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition(self::ERROR_MESSAGE, [ @@ -98,7 +99,6 @@ public function run() ), ]); } - /** * @return string[] */ @@ -111,7 +111,6 @@ private function processNew(New_ $new): array $className = $new->class->toString(); return $this->processClassName($className); } - /** * @return string[] */ @@ -143,7 +142,6 @@ private function processClass(InClassNode $inClassNode): array return []; } - /** * @return string[] */ @@ -160,11 +158,11 @@ private function processClassName(string $className): array return []; } - /** * @return string[] + * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\Instanceof_ $node */ - private function processExprWithClass(StaticCall|Instanceof_ $node): array + private function processExprWithClass($node): array { if ($node->class instanceof Expr) { return []; diff --git a/src/Rules/PreventParentMethodVisibilityOverrideRule.php b/src/Rules/PreventParentMethodVisibilityOverrideRule.php index a6e8c489..c6056df8 100644 --- a/src/Rules/PreventParentMethodVisibilityOverrideRule.php +++ b/src/Rules/PreventParentMethodVisibilityOverrideRule.php @@ -18,16 +18,21 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\PreventParentMethodVisibilityOverrideRule\PreventParentMethodVisibilityOverrideRuleTest */ -final class PreventParentMethodVisibilityOverrideRule implements Rule, DocumentedRuleInterface +final class PreventParentMethodVisibilityOverrideRule implements Rule { + /** + * @readonly + * @var \PHPStan\Reflection\ReflectionProvider + */ + private $reflectionProvider; /** * @var string */ public const ERROR_MESSAGE = 'Change "%s()" method visibility to "%s" to respect parent method visibility.'; - public function __construct( - private readonly ReflectionProvider $reflectionProvider - ) { + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; } /** diff --git a/src/Rules/Rector/NoInstanceOfStaticReflectionRule.php b/src/Rules/Rector/NoInstanceOfStaticReflectionRule.php index 14ee0e8b..5179a9b0 100644 --- a/src/Rules/Rector/NoInstanceOfStaticReflectionRule.php +++ b/src/Rules/Rector/NoInstanceOfStaticReflectionRule.php @@ -59,7 +59,10 @@ public function processNode(Node $node, Scope $scope): array return [self::ERROR_MESSAGE]; } - private function resolveExprStaticType(FuncCall|Instanceof_ $node, Scope $scope): ?Type + /** + * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\Instanceof_ $node + */ + private function resolveExprStaticType($node, Scope $scope): ?Type { if ($node instanceof Instanceof_) { return $this->resolveInstanceOfType($node, $scope); diff --git a/src/Rules/Rector/NoLeadingBackslashInNameRule.php b/src/Rules/Rector/NoLeadingBackslashInNameRule.php index 27f0ac06..8f8f2aa0 100644 --- a/src/Rules/Rector/NoLeadingBackslashInNameRule.php +++ b/src/Rules/Rector/NoLeadingBackslashInNameRule.php @@ -56,7 +56,7 @@ public function processNode(Node $node, Scope $scope): array return []; } - if (! str_starts_with($argType->getValue(), '\\')) { + if (strncmp($argType->getValue(), '\\', strlen('\\')) !== 0) { return []; } diff --git a/src/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule.php b/src/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule.php index de3d1d5b..44e9409f 100644 --- a/src/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule.php +++ b/src/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule.php @@ -60,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array $configContent = FileSystem::read($configFilePath); // is rule registered? - if (str_contains($configContent, $className)) { + if (strpos($configContent, $className) !== false) { return []; } diff --git a/src/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule.php b/src/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule.php index 1c49f584..a186cb49 100644 --- a/src/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule.php +++ b/src/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule.php @@ -43,7 +43,7 @@ public function processNode(Node $node, Scope $scope): array { /** @var string $className */ $className = (string) $node->namespacedName; - if (! str_ends_with($className, 'Rector')) { + if (substr_compare($className, 'Rector', -strlen('Rector')) !== 0) { return []; } diff --git a/src/Rules/Rector/RequireAssertConfigureValueObjectRectorRule.php b/src/Rules/Rector/RequireAssertConfigureValueObjectRectorRule.php index 57905363..0c3ded29 100644 --- a/src/Rules/Rector/RequireAssertConfigureValueObjectRectorRule.php +++ b/src/Rules/Rector/RequireAssertConfigureValueObjectRectorRule.php @@ -31,7 +31,11 @@ final class RequireAssertConfigureValueObjectRectorRule implements Rule */ public const ERROR_MESSAGE = 'Method configure() with passed value object must contain assert to verify passed type'; - private readonly NodeFinder $nodeFinder; + /** + * @readonly + * @var \PhpParser\NodeFinder + */ + private $nodeFinder; public function __construct( ) { diff --git a/src/Rules/RegexSuffixInRegexConstantRule.php b/src/Rules/RegexSuffixInRegexConstantRule.php index 1f57440d..67bad613 100644 --- a/src/Rules/RegexSuffixInRegexConstantRule.php +++ b/src/Rules/RegexSuffixInRegexConstantRule.php @@ -21,17 +21,27 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\RegexSuffixInRegexConstantRule\RegexSuffixInRegexConstantRuleTest */ -final class RegexSuffixInRegexConstantRule implements Rule, DocumentedRuleInterface +final class RegexSuffixInRegexConstantRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\RegexFuncCallAnalyzer + */ + private $regexFuncCallAnalyzer; + /** + * @readonly + * @var \Symplify\PHPStanRules\NodeAnalyzer\RegexStaticCallAnalyzer + */ + private $regexStaticCallAnalyzer; /** * @var string */ public const ERROR_MESSAGE = 'Name your constant with "_REGEX" suffix, instead of "%s"'; - public function __construct( - private readonly RegexFuncCallAnalyzer $regexFuncCallAnalyzer, - private readonly RegexStaticCallAnalyzer $regexStaticCallAnalyzer - ) { + public function __construct(RegexFuncCallAnalyzer $regexFuncCallAnalyzer, RegexStaticCallAnalyzer $regexStaticCallAnalyzer) + { + $this->regexFuncCallAnalyzer = $regexFuncCallAnalyzer; + $this->regexStaticCallAnalyzer = $regexStaticCallAnalyzer; } /** @@ -104,7 +114,7 @@ private function processConstantName(Expr $expr): array } $constantName = (string) $expr->name; - if (\str_ends_with($constantName, '_REGEX')) { + if (substr_compare($constantName, '_REGEX', -strlen('_REGEX')) === 0) { return []; } diff --git a/src/Rules/RequireAttributeNameRule.php b/src/Rules/RequireAttributeNameRule.php index 06943c8b..a1fb18fb 100644 --- a/src/Rules/RequireAttributeNameRule.php +++ b/src/Rules/RequireAttributeNameRule.php @@ -20,7 +20,7 @@ * @see \Symplify\PHPStanRules\Tests\Rules\RequireAttributeNameRule\RequireAttributeNameRuleTest * @implements Rule */ -final class RequireAttributeNameRule implements Rule, DocumentedRuleInterface +final class RequireAttributeNameRule implements Rule { /** * @var string @@ -78,7 +78,7 @@ public function processNode(Node $node, Scope $scope): array } // skip PHPUnit - if (str_starts_with($attributeName, 'PHPUnit\Framework\Attributes\\')) { + if (strncmp($attributeName, 'PHPUnit\Framework\Attributes\\', strlen('PHPUnit\Framework\Attributes\\')) === 0) { continue; } diff --git a/src/Rules/SeeAnnotationToTestRule.php b/src/Rules/SeeAnnotationToTestRule.php index 19c1dd3b..907153f1 100644 --- a/src/Rules/SeeAnnotationToTestRule.php +++ b/src/Rules/SeeAnnotationToTestRule.php @@ -25,8 +25,23 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\SeeAnnotationToTestRule\SeeAnnotationToTestRuleTest */ -final class SeeAnnotationToTestRule implements Rule, DocumentedRuleInterface, ConfigurableRuleInterface +final class SeeAnnotationToTestRule implements Rule { + /** + * @readonly + * @var \Symplify\PHPStanRules\PhpDoc\PhpDocResolver + */ + private $phpDocResolver; + /** + * @readonly + * @var \Symplify\PHPStanRules\PhpDoc\SeePhpDocTagNodesFinder + */ + private $seePhpDocTagNodesFinder; + /** + * @var string[] + * @readonly + */ + private $requiredSeeTypes; /** * @var string */ @@ -35,11 +50,11 @@ final class SeeAnnotationToTestRule implements Rule, DocumentedRuleInterface, Co /** * @param string[] $requiredSeeTypes */ - public function __construct( - private readonly PhpDocResolver $phpDocResolver, - private readonly SeePhpDocTagNodesFinder $seePhpDocTagNodesFinder, - private readonly array $requiredSeeTypes - ) { + public function __construct(PhpDocResolver $phpDocResolver, SeePhpDocTagNodesFinder $seePhpDocTagNodesFinder, array $requiredSeeTypes) + { + $this->phpDocResolver = $phpDocResolver; + $this->seePhpDocTagNodesFinder = $seePhpDocTagNodesFinder; + $this->requiredSeeTypes = $requiredSeeTypes; } /** diff --git a/src/Rules/UppercaseConstantRule.php b/src/Rules/UppercaseConstantRule.php index cf885671..cce7d720 100644 --- a/src/Rules/UppercaseConstantRule.php +++ b/src/Rules/UppercaseConstantRule.php @@ -15,7 +15,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Rules\UppercaseConstantRule\UppercaseConstantRuleTest */ -final class UppercaseConstantRule implements Rule, DocumentedRuleInterface +final class UppercaseConstantRule implements Rule { /** * @var string diff --git a/src/Symfony/NodeAnalyzer/SymfonyControllerAnalyzer.php b/src/Symfony/NodeAnalyzer/SymfonyControllerAnalyzer.php index d07c66a4..94968e8f 100644 --- a/src/Symfony/NodeAnalyzer/SymfonyControllerAnalyzer.php +++ b/src/Symfony/NodeAnalyzer/SymfonyControllerAnalyzer.php @@ -32,6 +32,6 @@ public static function isControllerActionMethod(ClassMethod $classMethod): bool return false; } - return \str_contains($docComment->getText(), '@Route'); + return strpos($docComment->getText(), '@Route') !== false; } } diff --git a/src/Symfony/Rules/RequireInvokableControllerRule.php b/src/Symfony/Rules/RequireInvokableControllerRule.php index 156a9915..aad75516 100644 --- a/src/Symfony/Rules/RequireInvokableControllerRule.php +++ b/src/Symfony/Rules/RequireInvokableControllerRule.php @@ -20,7 +20,7 @@ /** * @see \Symplify\PHPStanRules\Tests\Symfony\Rules\RequireInvokableControllerRule\RequireInvokableControllerRuleTest */ -final class RequireInvokableControllerRule implements Rule, DocumentedRuleInterface +final class RequireInvokableControllerRule implements Rule { /** * @var string diff --git a/src/ValueObject/ClassNamespaceAndDirectory.php b/src/ValueObject/ClassNamespaceAndDirectory.php index bf129c84..db9fdd94 100644 --- a/src/ValueObject/ClassNamespaceAndDirectory.php +++ b/src/ValueObject/ClassNamespaceAndDirectory.php @@ -6,11 +6,26 @@ final class ClassNamespaceAndDirectory { - public function __construct( - private readonly string $namespace, - private readonly string $directory, - private readonly string $namespaceBeforeClass - ) { + /** + * @readonly + * @var string + */ + private $namespace; + /** + * @readonly + * @var string + */ + private $directory; + /** + * @readonly + * @var string + */ + private $namespaceBeforeClass; + public function __construct(string $namespace, string $directory, string $namespaceBeforeClass) + { + $this->namespace = $namespace; + $this->directory = $directory; + $this->namespaceBeforeClass = $namespaceBeforeClass; } public function getNamespace(): string diff --git a/src/ValueObject/Configuration/RequiredWithMessage.php b/src/ValueObject/Configuration/RequiredWithMessage.php index d052ad3f..2478ab8d 100644 --- a/src/ValueObject/Configuration/RequiredWithMessage.php +++ b/src/ValueObject/Configuration/RequiredWithMessage.php @@ -6,10 +6,20 @@ final class RequiredWithMessage { - public function __construct( - private readonly string $required, - private readonly ?string $message - ) { + /** + * @readonly + * @var string + */ + private $required; + /** + * @readonly + * @var string|null + */ + private $message; + public function __construct(string $required, ?string $message) + { + $this->required = $required; + $this->message = $message; } public function getRequired(): string diff --git a/src/ValueObject/MethodCallReference.php b/src/ValueObject/MethodCallReference.php index 023b289a..e5318444 100644 --- a/src/ValueObject/MethodCallReference.php +++ b/src/ValueObject/MethodCallReference.php @@ -6,10 +6,20 @@ final class MethodCallReference { - public function __construct( - private readonly string $class, - private readonly 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/Composer/Psr4PathValidatorTest.php b/tests/Composer/Psr4PathValidatorTest.php deleted file mode 100644 index 5c5b364d..00000000 --- a/tests/Composer/Psr4PathValidatorTest.php +++ /dev/null @@ -1,64 +0,0 @@ -psr4PathValidator = new Psr4PathValidator(); - } - - #[DataProvider('provideCorrectData')] - public function testCorrectCase(string $namespace, string $directory): void - { - $isClassNamespaceCorrect = $this->isNamespaceAndDirectoryCorrect($namespace, $directory); - - $this->assertTrue($isClassNamespaceCorrect); - } - - #[DataProvider('provideFailingData')] - public function testFailingCase(string $namespace, string $directory): void - { - $isClassNamespaceCorrect = $this->isNamespaceAndDirectoryCorrect($namespace, $directory); - - $this->assertFalse($isClassNamespaceCorrect); - } - - /** - * @return Iterator - */ - public static function provideCorrectData(): Iterator - { - yield ['Symplify\\PHPStanRules\\Tests\\', 'tests']; - yield ['Symplify\\PHPStanRules\\Tests\\', 'tests/']; - } - - public static function provideFailingData(): Iterator - { - yield ['Symplify\\PHPStanRules\\Tests\\', 'test/']; - yield ['Symplify\\PHPStanRules\\Tests\\', '/']; - yield ['PHPStanRules\\Tests', '/']; - } - - private function isNamespaceAndDirectoryCorrect(string $namespace, string $directory): bool - { - $classNamespaceAndDirectory = new ClassNamespaceAndDirectory( - $namespace, - $directory, - sprintf('%sComposer\\', $namespace) - ); - - return $this->psr4PathValidator->isClassNamespaceCorrect($classNamespaceAndDirectory, __FILE__); - } -} diff --git a/tests/Naming/ClassToSuffixResolverTest.php b/tests/Naming/ClassToSuffixResolverTest.php deleted file mode 100644 index 6f26ff7f..00000000 --- a/tests/Naming/ClassToSuffixResolverTest.php +++ /dev/null @@ -1,39 +0,0 @@ -classToSuffixResolver = new ClassToSuffixResolver(); - } - - #[DataProvider('provideData')] - public function test(string $className, string $expectedSuffix): void - { - $resolvedSuffix = $this->classToSuffixResolver->resolveFromClass($className); - $this->assertSame($expectedSuffix, $resolvedSuffix); - } - - /** - * @return Iterator - */ - public static function provideData(): Iterator - { - yield ['Exception', 'Exception']; - yield ['Symfony\Component\Console\Command\Command', 'Command']; - yield [TestCase::class, 'Test']; - yield [EventSubscriberInterface::class, 'EventSubscriber']; - } -} diff --git a/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php b/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php deleted file mode 100644 index 1ad227fd..00000000 --- a/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php +++ /dev/null @@ -1,8 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipId.php', []]; - - $errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'em', 3); - $yeErrorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'YE', 3); - yield [__DIR__ . '/Fixture/ShortNamingClass.php', [[$errorMessage, 9], [$yeErrorMessage, 11]]]; - - $errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'n', 3); - yield [__DIR__ . '/Fixture/ShortClosureParam.php', [[$errorMessage, 11]]]; - yield [__DIR__ . '/Fixture/ShortParam.php', [[$errorMessage, 9]]]; - - yield [__DIR__ . '/Fixture/AllowD.php', []]; - - $errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'n', 3); - yield [ - __DIR__ . '/Fixture/ShortAssignParameter.php', - [[$errorMessage, 11], [$errorMessage, 13], [$errorMessage, 15]], ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoShortNameRule::class); - } -} diff --git a/tests/ObjectCalisthenics/Rules/NoShortNameRule/config/configured_rule.neon b/tests/ObjectCalisthenics/Rules/NoShortNameRule/config/configured_rule.neon deleted file mode 100644 index c918b33b..00000000 --- a/tests/ObjectCalisthenics/Rules/NoShortNameRule/config/configured_rule.neon +++ /dev/null @@ -1,12 +0,0 @@ -includes: - - ../../../../../tests/config/included_services.neon - -services: - - - class: Symplify\PHPStanRules\ObjectCalisthenics\Rules\NoShortNameRule - tags: [phpstan.rules.rule] - arguments: - minNameLength: 3 - allowedShortNames: - - id - - d diff --git a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/NodeGetAttributeTypeExtensionTest.php b/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/NodeGetAttributeTypeExtensionTest.php deleted file mode 100644 index 66d55b9a..00000000 --- a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/NodeGetAttributeTypeExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertFileAsserts($assertType, $file, ...$args); - } - - public static function dataAsserts(): Iterator - { - yield from self::gatherAssertTypes(__DIR__ . '/data/get_parent_node.php.inc'); - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/type_extension.neon']; - } -} diff --git a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/config/type_extension.neon b/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/config/type_extension.neon deleted file mode 100644 index f8cef7ee..00000000 --- a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/config/type_extension.neon +++ /dev/null @@ -1,5 +0,0 @@ -services: - # $node->getAttribute($1) => Type|null by $1 - - - class: Symplify\PHPStanRules\ReturnTypeExtension\NodeGetAttributeTypeExtension - tags: [phpstan.broker.dynamicMethodReturnTypeExtension] diff --git a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/data/get_parent_node.php.inc b/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/data/get_parent_node.php.inc deleted file mode 100644 index 4adb58ed..00000000 --- a/tests/ReturnTypeExtension/NodeGetAttributeTypeExtension/data/get_parent_node.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -getAttribute(AttributeKey::SCOPE); -\PHPStan\Testing\assertType('PHPStan\Analyser\Scope|null', $scope); diff --git a/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/AnnotateRegexClassConstWithRegexLinkRuleTest.php b/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/AnnotateRegexClassConstWithRegexLinkRuleTest.php deleted file mode 100644 index 77c5e7a5..00000000 --- a/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/AnnotateRegexClassConstWithRegexLinkRuleTest.php +++ /dev/null @@ -1,49 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/ClassConstMissingLink.php', - [[AnnotateRegexClassConstWithRegexLinkRule::ERROR_MESSAGE, 12]], - ]; - - yield [__DIR__ . '/Fixture/SkipShort.php', []]; - yield [__DIR__ . '/Fixture/SkipWithLink.php', []]; - yield [__DIR__ . '/Fixture/SkipAlphabet.php', []]; - yield [__DIR__ . '/Fixture/SkipPlaceholder.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(AnnotateRegexClassConstWithRegexLinkRule::class); - } -} diff --git a/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/Fixture/ClassConstMissingLink.php b/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/Fixture/ClassConstMissingLink.php deleted file mode 100644 index 4756d3b7..00000000 --- a/tests/Rules/AnnotateRegexClassConstWithRegexLinkRule/Fixture/ClassConstMissingLink.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipAnonymousClass.php', []]; - yield [__DIR__ . '/Fixture/SkipValidNamespaceInterface.php', []]; - - yield [__DIR__ . '/Fixture/InvalidNamespaceClass.php', [ - [sprintf(CheckClassNamespaceFollowPsr4Rule::ERROR_MESSAGE, 'Foo\Bar'), 7], - ]]; - yield [__DIR__ . '/Fixture/InvalidNamespaceInterface.php', [ - [sprintf(CheckClassNamespaceFollowPsr4Rule::ERROR_MESSAGE, 'Foo\Bar'), 7], - ]]; - yield [__DIR__ . '/Fixture/InvalidNamespaceTrait.php', [ - [sprintf(CheckClassNamespaceFollowPsr4Rule::ERROR_MESSAGE, 'Foo\Bar'), 7], - ]]; - - $errorMessage = sprintf( - CheckClassNamespaceFollowPsr4Rule::ERROR_MESSAGE, - 'Symplify\PHPStanRules\Tests\Rules\CheckClassNamespaceFollowPsr4Rule' - ); - yield [__DIR__ . '/Fixture/MissingFixtureNamespaceClass.php', [[$errorMessage, 7]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(CheckClassNamespaceFollowPsr4Rule::class); - } -} diff --git a/tests/Rules/CheckClassNamespaceFollowPsr4Rule/Fixture/InvalidNamespaceClass.php b/tests/Rules/CheckClassNamespaceFollowPsr4Rule/Fixture/InvalidNamespaceClass.php deleted file mode 100644 index 75cb9f95..00000000 --- a/tests/Rules/CheckClassNamespaceFollowPsr4Rule/Fixture/InvalidNamespaceClass.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/Contract/SkipInterfaceInContract.php', []]; - yield [__DIR__ . '/Fixture/Illuminate/Contracts/View/View.php', []]; - yield [ - __DIR__ . '/Fixture/AnInterfaceNotInContract.php', - [[CheckRequiredInterfaceInContractNamespaceRule::ERROR_MESSAGE, 7]], ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(CheckRequiredInterfaceInContractNamespaceRule::class); - } -} diff --git a/tests/Rules/CheckRequiredInterfaceInContractNamespaceRule/Fixture/AnInterfaceNotInContract.php b/tests/Rules/CheckRequiredInterfaceInContractNamespaceRule/Fixture/AnInterfaceNotInContract.php deleted file mode 100644 index 08a2d7dd..00000000 --- a/tests/Rules/CheckRequiredInterfaceInContractNamespaceRule/Fixture/AnInterfaceNotInContract.php +++ /dev/null @@ -1,10 +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(CheckTypehintCallerTypeRule::ERROR_MESSAGE, 1, MethodCall::class); - yield [__DIR__ . '/Fixture/Fixture.php', [[$errorMessage, 19]]]; - yield [__DIR__ . '/Fixture/DifferentClassSameMethodCallName.php', [[$errorMessage, 25]]]; - - $argErrorMessage = sprintf(CheckTypehintCallerTypeRule::ERROR_MESSAGE, 1, Arg::class); - $paramErrorMessage = sprintf(CheckTypehintCallerTypeRule::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/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(CheckTypehintCallerTypeRule::class); - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/DifferentClassSameMethodCallName.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/DifferentClassSameMethodCallName.php deleted file mode 100644 index b915601b..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/DoubleShot.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/DoubleShot.php deleted file mode 100644 index 189b34b1..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/Fixture.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/Fixture.php deleted file mode 100644 index d018bc45..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/Fixture.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAbstractBase.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAbstractBase.php deleted file mode 100644 index 50436649..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAbstractBase.php +++ /dev/null @@ -1,16 +0,0 @@ -isCheck($arg); - } - private function isCheck(ConceptBase $arg) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAlreadyCorrectType.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAlreadyCorrectType.php deleted file mode 100644 index 02afd973..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipAlreadyCorrectType.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(MethodCall $node) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipCorrectUnionType.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipCorrectUnionType.php deleted file mode 100644 index d65fe635..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php deleted file mode 100644 index a639dd02..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/SkipGenericType.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipGenericType.php deleted file mode 100644 index 431d5019..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/SkipMayOverrideArg.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMayOverrideArg.php deleted file mode 100644 index f6ad3ced..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMayOverrideArg.php +++ /dev/null @@ -1,27 +0,0 @@ -mayOverrideNode(); - - $this->isCheck($node); - - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMixed.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMixed.php deleted file mode 100644 index b82eca26..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMixed.php +++ /dev/null @@ -1,18 +0,0 @@ -isCheck($arg); - } - private function isCheck(\PhpParser\Node $arg) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMultipleUsed.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipMultipleUsed.php deleted file mode 100644 index df663df6..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Fixture/SkipNoArgs.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNoArgs.php deleted file mode 100644 index c308ec73..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNoArgs.php +++ /dev/null @@ -1,15 +0,0 @@ -execute(); - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotFromThis.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotFromThis.php deleted file mode 100644 index 5fc6fa71..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotFromThis.php +++ /dev/null @@ -1,14 +0,0 @@ -format('Y-m-d'); - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotPrivate.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotPrivate.php deleted file mode 100644 index 54dcfea8..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipNotPrivate.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheckNotPrivate($node); - } - } - - public function isCheckNotPrivate(Node $node) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipOptedOut.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipOptedOut.php deleted file mode 100644 index 6c6091e5..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipOptedOut.php +++ /dev/null @@ -1,23 +0,0 @@ -isCheck($type); - } - - private function isCheck(\PHPStan\Type\Type $type) - { - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipParentNotIf.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipParentNotIf.php deleted file mode 100644 index 455b9ee9..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipParentNotIf.php +++ /dev/null @@ -1,15 +0,0 @@ -execute($node); - } -} diff --git a/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipRecursive.php b/tests/Rules/CheckTypehintCallerTypeRule/Fixture/SkipRecursive.php deleted file mode 100644 index 192a14c6..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/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/CheckTypehintCallerTypeRule/Source/AnotherClassWithRun.php b/tests/Rules/CheckTypehintCallerTypeRule/Source/AnotherClassWithRun.php deleted file mode 100644 index 24f6228f..00000000 --- a/tests/Rules/CheckTypehintCallerTypeRule/Source/AnotherClassWithRun.php +++ /dev/null @@ -1,15 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipCommand.php', []]; - yield [__DIR__ . '/Fixture/SkipSomeEventSubscriber.php', []]; - yield [__DIR__ . '/Fixture/SkipFixer.php', []]; - yield [__DIR__ . '/Fixture/SkipAnonymousClass.php', []]; - yield [__DIR__ . '/Fixture/SkipTest.php', []]; - yield [__DIR__ . '/Fixture/SkipAbstractTestCase.php', []]; - - $errorMessage = sprintf(ClassNameRespectsParentSuffixRule::ERROR_MESSAGE, 'Test'); - yield [__DIR__ . '/Fixture/NonTestSuffix.php', [[$errorMessage, 9]]]; - - $errorMessage = sprintf(ClassNameRespectsParentSuffixRule::ERROR_MESSAGE, 'Command'); - yield [__DIR__ . '/Fixture/SomeController.php', [[$errorMessage, 9]]]; - - $errorMessage = sprintf(ClassNameRespectsParentSuffixRule::ERROR_MESSAGE, 'EventSubscriber'); - yield [__DIR__ . '/Fixture/SomeEventSubscriberFalse.php', [[$errorMessage, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ClassNameRespectsParentSuffixRule::class); - } -} diff --git a/tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/NonTestSuffix.php b/tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/NonTestSuffix.php deleted file mode 100644 index 6da9fb6a..00000000 --- a/tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/NonTestSuffix.php +++ /dev/null @@ -1,11 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipNormalArray.php', []]; - yield [__DIR__ . '/Fixture/ReturnCallable.php', [[ForbiddenArrayMethodCallRule::ERROR_MESSAGE, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenArrayMethodCallRule::class); - } -} diff --git a/tests/Rules/Complexity/ForbiddenArrayMethodCallRule/config/configured_rule.neon b/tests/Rules/Complexity/ForbiddenArrayMethodCallRule/config/configured_rule.neon deleted file mode 100644 index 6273d331..00000000 --- a/tests/Rules/Complexity/ForbiddenArrayMethodCallRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule diff --git a/tests/Rules/Domain/RequireAttributeNamespaceRule/Fixture/Attribute/SkipCorrectAttribute.php b/tests/Rules/Domain/RequireAttributeNamespaceRule/Fixture/Attribute/SkipCorrectAttribute.php deleted file mode 100644 index bfc2a1dd..00000000 --- a/tests/Rules/Domain/RequireAttributeNamespaceRule/Fixture/Attribute/SkipCorrectAttribute.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/MisslocatedAttribute.php', [[RequireAttributeNamespaceRule::ERROR_MESSAGE, 7]]]; - yield [__DIR__ . '/Fixture/Attribute/SkipCorrectAttribute.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireAttributeNamespaceRule::class); - } -} diff --git a/tests/Rules/Domain/RequireAttributeNamespaceRule/config/configured_rule.neon b/tests/Rules/Domain/RequireAttributeNamespaceRule/config/configured_rule.neon deleted file mode 100644 index 5443e442..00000000 --- a/tests/Rules/Domain/RequireAttributeNamespaceRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\Domain\RequireAttributeNamespaceRule diff --git a/tests/Rules/Domain/RequireExceptionNamespaceRule/Fixture/Exception/SkipCorrectException.php b/tests/Rules/Domain/RequireExceptionNamespaceRule/Fixture/Exception/SkipCorrectException.php deleted file mode 100644 index c09aae43..00000000 --- a/tests/Rules/Domain/RequireExceptionNamespaceRule/Fixture/Exception/SkipCorrectException.php +++ /dev/null @@ -1,11 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/MisslocatedException.php', [[RequireExceptionNamespaceRule::ERROR_MESSAGE, 9]]]; - yield [__DIR__ . '/Fixture/Exception/SkipCorrectException.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireExceptionNamespaceRule::class); - } -} diff --git a/tests/Rules/Domain/RequireExceptionNamespaceRule/config/configured_rule.neon b/tests/Rules/Domain/RequireExceptionNamespaceRule/config/configured_rule.neon deleted file mode 100644 index d344fc41..00000000 --- a/tests/Rules/Domain/RequireExceptionNamespaceRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\Domain\RequireExceptionNamespaceRule diff --git a/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture/InvalidAnnotationEnum.php b/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture/InvalidAnnotationEnum.php deleted file mode 100644 index a50ff5c8..00000000 --- a/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture/InvalidAnnotationEnum.php +++ /dev/null @@ -1,15 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - $expectedErrorMessage = sprintf(RequireUniqueEnumConstantRule::ERROR_MESSAGE, 'yes'); - yield [__DIR__ . '/Fixture/InvalidEnum.php', [[$expectedErrorMessage, 8]]]; - yield [__DIR__ . '/Fixture/InvalidAnnotationEnum.php', [[$expectedErrorMessage, 8]]]; - - yield [__DIR__ . '/Fixture/SkipValidEnum.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireUniqueEnumConstantRule::class); - } -} diff --git a/tests/Rules/Enum/RequireUniqueEnumConstantRule/config/configured_rule.neon b/tests/Rules/Enum/RequireUniqueEnumConstantRule/config/configured_rule.neon deleted file mode 100644 index 317a3057..00000000 --- a/tests/Rules/Enum/RequireUniqueEnumConstantRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule diff --git a/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/ExplicitClassPrefixSuffixRuleTest.php b/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/ExplicitClassPrefixSuffixRuleTest.php deleted file mode 100644 index 92f581bc..00000000 --- a/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/ExplicitClassPrefixSuffixRuleTest.php +++ /dev/null @@ -1,63 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/CorrectInterface.php', []]; - yield [__DIR__ . '/Fixture/CorrectTrait.php', []]; - - yield [__DIR__ . '/Fixture/AbstractCorrectClass.php', []]; - yield [__DIR__ . '/Fixture/AbstractIncorrectClass.php', [ - [ExplicitClassPrefixSuffixRule::ABSTRACT_ERROR_MESSAGE, 5], - ]]; - - yield [__DIR__ . '/Fixture/WrongTraitSuffix.php', [ - [ExplicitClassPrefixSuffixRule::TRAIT_ERROR_MESSAGE, 5], - ]]; - - yield [__DIR__ . '/Fixture/WrongSuffixTrait.php', [ - [ExplicitClassPrefixSuffixRule::TRAIT_ERROR_MESSAGE, 5], - ]]; - - yield [__DIR__ . '/Fixture/WrongInterfaceSuffix.php', [ - [ExplicitClassPrefixSuffixRule::INTERFACE_ERROR_MESSAGE, 5], - ]]; - - yield [__DIR__ . '/Fixture/IncorrectClassInterface.php', [ - [ExplicitClassPrefixSuffixRule::INTERFACE_ERROR_MESSAGE, 5], - ]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ExplicitClassPrefixSuffixRule::class); - } -} diff --git a/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/Fixture/AbstractCorrectClass.php b/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/Fixture/AbstractCorrectClass.php deleted file mode 100644 index 12a71150..00000000 --- a/tests/Rules/Explicit/ExplicitClassPrefixSuffixRule/Fixture/AbstractCorrectClass.php +++ /dev/null @@ -1,8 +0,0 @@ -$magic(); - } -} diff --git a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php b/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php deleted file mode 100644 index c655b48b..00000000 --- a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php +++ /dev/null @@ -1,15 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipMockObject.php b/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipMockObject.php deleted file mode 100644 index 169f00c8..00000000 --- a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/SkipMockObject.php +++ /dev/null @@ -1,19 +0,0 @@ -createMock(MagicMethodName::class); - - $mock - ->method('run') - ->willReturn(true); - } -} diff --git a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php b/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php deleted file mode 100644 index adbf92c7..00000000 --- a/tests/Rules/Explicit/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php +++ /dev/null @@ -1,13 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/Explicit/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php b/tests/Rules/Explicit/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php deleted file mode 100644 index 42d767dc..00000000 --- a/tests/Rules/Explicit/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ -> $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorsWithLines): void - { - $this->analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipKnownCallerType.php', []]; - yield [__DIR__ . '/Fixture/SkipMockObject.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/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedMethodCallerRule::class); - } -} diff --git a/tests/Rules/Explicit/NoMixedMethodCallerRule/Source/KnownType.php b/tests/Rules/Explicit/NoMixedMethodCallerRule/Source/KnownType.php deleted file mode 100644 index 0a8907b4..00000000 --- a/tests/Rules/Explicit/NoMixedMethodCallerRule/Source/KnownType.php +++ /dev/null @@ -1,12 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php b/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php deleted file mode 100644 index 8ffba3b0..00000000 --- a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php +++ /dev/null @@ -1,15 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php b/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php deleted file mode 100644 index 588d7930..00000000 --- a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php +++ /dev/null @@ -1,15 +0,0 @@ -name; - } -} diff --git a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php b/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php deleted file mode 100644 index 7e40c237..00000000 --- a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php b/tests/Rules/Explicit/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php deleted file mode 100644 index 54a2018f..00000000 --- a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ -> $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorsWithLines): void - { - $this->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, 13]]]; - - $message = sprintf(NoMixedPropertyFetcherRule::ERROR_MESSAGE, '$unknownType'); - yield [__DIR__ . '/Fixture/UnknownPropertyFetcher.php', [[$message, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedPropertyFetcherRule::class); - } -} diff --git a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Source/KnownType.php b/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Source/KnownType.php deleted file mode 100644 index b99e5da7..00000000 --- a/tests/Rules/Explicit/NoMixedPropertyFetcherRule/Source/KnownType.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipSpecificReturnType.php', []]; - yield [__DIR__ . '/Fixture/SkipSomeContract.php', []]; - - $errorMessage = sprintf(RequireSpecificReturnTypeOverAbstractRule::ERROR_MESSAGE, SpecificControl::class); - yield [__DIR__ . '/Fixture/SomeAbstractReturnType.php', [[$errorMessage, 12]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireSpecificReturnTypeOverAbstractRule::class); - } -} diff --git a/tests/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule/Source/AbstractControl.php b/tests/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule/Source/AbstractControl.php deleted file mode 100644 index 7eba6f80..00000000 --- a/tests/Rules/Explicit/RequireSpecificReturnTypeOverAbstractRule/Source/AbstractControl.php +++ /dev/null @@ -1,9 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/ClassExtendingNonAbstractClass.php', - [[ForbiddenExtendOfNonAbstractClassRule::ERROR_MESSAGE, 9]], ]; - - yield [__DIR__ . '/Fixture/SkipVendorBasedClasses.php', []]; - yield [__DIR__ . '/Fixture/SkipClassExtendingAbstractClass.php', []]; - yield [__DIR__ . '/Fixture/SkipException.php', []]; - yield [__DIR__ . '/Fixture/SkipAnonymousExtend.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenExtendOfNonAbstractClassRule::class); - } -} diff --git a/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Source/NonAbstractClass.php b/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Source/NonAbstractClass.php deleted file mode 100644 index 68a5b0ab..00000000 --- a/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Source/NonAbstractClass.php +++ /dev/null @@ -1,9 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'dump'); - yield [__DIR__ . '/Fixture/DebugFuncCall.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'extract'); - yield [__DIR__ . '/Fixture/ExtractCall.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'curl_init'); - yield [__DIR__ . '/Fixture/CurlCall.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'property_exists'); - yield [__DIR__ . '/Fixture/PropertyExists.php', [[$errorMessage, 11]]]; - - yield [__DIR__ . '/Fixture/SkipPropertyExistsOnXml.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenFuncCallRule::class); - } -} diff --git a/tests/Rules/ForbiddenFuncCallRule/ForbiddenFuncCallRuleWithDeprecationsTest.php b/tests/Rules/ForbiddenFuncCallRule/ForbiddenFuncCallRuleWithDeprecationsTest.php deleted file mode 100644 index eb0c08bf..00000000 --- a/tests/Rules/ForbiddenFuncCallRule/ForbiddenFuncCallRuleWithDeprecationsTest.php +++ /dev/null @@ -1,59 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - // custom messages are defined in the config file - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'dump'); - $errorMessage .= ': seems you missed some debugging function'; - yield [__DIR__ . '/Fixture/DebugFuncCall.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'extract'); - $errorMessage .= ': you shouldn"t use this dynamic things'; - yield [__DIR__ . '/Fixture/ExtractCall.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'curl_init'); - $errorMessage .= ': we use a proper http client these days'; - yield [__DIR__ . '/Fixture/CurlCall.php', [[$errorMessage, 11]]]; - - // custom error defined as empty-string -> just prints the default message - $errorMessage = sprintf(ForbiddenFuncCallRule::ERROR_MESSAGE, 'property_exists'); - yield [__DIR__ . '/Fixture/PropertyExists.php', [[$errorMessage, 11]]]; - - yield [__DIR__ . '/Fixture/SkipPropertyExistsOnXml.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule_with_deprecations.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenFuncCallRule::class); - } -} diff --git a/tests/Rules/ForbiddenFuncCallRule/config/configured_rule.neon b/tests/Rules/ForbiddenFuncCallRule/config/configured_rule.neon deleted file mode 100644 index bcc99b22..00000000 --- a/tests/Rules/ForbiddenFuncCallRule/config/configured_rule.neon +++ /dev/null @@ -1,13 +0,0 @@ -includes: - - ../../../config/included_services.neon - -services: - - - class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule - tags: [phpstan.rules.rule] - arguments: - forbiddenFunctions: - - 'extract' - - 'dump' - - 'curl_*' - - 'property_exists' diff --git a/tests/Rules/ForbiddenFuncCallRule/config/configured_rule_with_deprecations.neon b/tests/Rules/ForbiddenFuncCallRule/config/configured_rule_with_deprecations.neon deleted file mode 100644 index 0442c12b..00000000 --- a/tests/Rules/ForbiddenFuncCallRule/config/configured_rule_with_deprecations.neon +++ /dev/null @@ -1,13 +0,0 @@ -includes: - - ../../../config/included_services.neon - -services: - - - class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule - tags: [phpstan.rules.rule] - arguments: - forbiddenFunctions: - 'extract': 'you shouldn"t use this dynamic things' - 'dump': 'seems you missed some debugging function' - 'curl_*': 'we use a proper http client these days' - - 'property_exists' diff --git a/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/Fixture/MultipleClassLike.php b/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/Fixture/MultipleClassLike.php deleted file mode 100644 index ebe21580..00000000 --- a/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/Fixture/MultipleClassLike.php +++ /dev/null @@ -1,17 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipOneInterface.php', []]; - yield [__DIR__ . '/Fixture/SkipOneClassWithAnonymousClass.php', []]; - yield [__DIR__ . '/Fixture/SkipOneClass.php', []]; - yield [__DIR__ . '/Fixture/SkipOneTrait.php', []]; - - yield [ - __DIR__ . '/Fixture/MultipleClassLike.php', - [[ForbiddenMultipleClassLikeInOneFileRule::ERROR_MESSAGE, 3]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenMultipleClassLikeInOneFileRule::class); - } -} diff --git a/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/config/configured_rule.neon b/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/config/configured_rule.neon deleted file mode 100644 index e641c8bf..00000000 --- a/tests/Rules/ForbiddenMultipleClassLikeInOneFileRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\ForbiddenMultipleClassLikeInOneFileRule diff --git a/tests/Rules/ForbiddenNodeRule/Fixture/EmptyCall.php b/tests/Rules/ForbiddenNodeRule/Fixture/EmptyCall.php deleted file mode 100644 index c65359f3..00000000 --- a/tests/Rules/ForbiddenNodeRule/Fixture/EmptyCall.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - /** - * @return \Iterator>|string[]> - */ - public static function provideData(): Iterator - { - $errorMessage = sprintf(ForbiddenNodeRule::ERROR_MESSAGE, 'empty($value)'); - yield [__DIR__ . '/Fixture/EmptyCall.php', [[$errorMessage, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenNodeRule::class); - } -} diff --git a/tests/Rules/ForbiddenNodeRule/config/configured_rule.neon b/tests/Rules/ForbiddenNodeRule/config/configured_rule.neon deleted file mode 100644 index ea9c437a..00000000 --- a/tests/Rules/ForbiddenNodeRule/config/configured_rule.neon +++ /dev/null @@ -1,12 +0,0 @@ -includes: - - ../../../config/included_services.neon - -services: - - - class: Symplify\PHPStanRules\Rules\ForbiddenNodeRule - tags: [phpstan.rules.rule] - arguments: - forbiddenNodes: - - PhpParser\Node\Expr\Empty_ - - PhpParser\Node\Stmt\Switch_ - - PhpParser\Node\Expr\ErrorSuppress diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/AnInterface.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/AnInterface.php deleted file mode 100644 index 25678b83..00000000 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Fixture/AnInterface.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', [[ForbiddenParamTypeRemovalRule::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', - [[ForbiddenParamTypeRemovalRule::ERROR_MESSAGE, 9]], - ]; - yield [ - __DIR__ . '/Fixture/HasDifferentParameterWithInterfaceMethod.php', - [[ForbiddenParamTypeRemovalRule::ERROR_MESSAGE, 9], [ - ForbiddenParamTypeRemovalRule::ERROR_MESSAGE, - 13, - ]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ForbiddenParamTypeRemovalRule::class); - } -} diff --git a/tests/Rules/ForbiddenParamTypeRemovalRule/Source/NoTypeInterface.php b/tests/Rules/ForbiddenParamTypeRemovalRule/Source/NoTypeInterface.php deleted file mode 100644 index aeeccbf3..00000000 --- a/tests/Rules/ForbiddenParamTypeRemovalRule/Source/NoTypeInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -callMe(...); - - $someCalledMethod->callMe(1000); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php deleted file mode 100644 index 0ac659b3..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.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/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipExpectedClassType.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipExpectedClassType.php deleted file mode 100644 index a999b186..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipExpectedClassType.php +++ /dev/null @@ -1,14 +0,0 @@ -callMe(1000); - } - - private function callMe($number) - { - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipNullableCompare.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipNullableCompare.php deleted file mode 100644 index b0f7bf95..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/SkipNullableCompare.php +++ /dev/null @@ -1,14 +0,0 @@ -run(new DateTime('now')); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/ThisPassedFromInterface.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Fixture/ThisPassedFromInterface.php deleted file mode 100644 index 8203b416..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/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(NarrowPublicClassMethodParamTypeByCallerTypeRule::ERROR_MESSAGE, 'int'); - yield [[ - __DIR__ . '/Fixture/PublicDoubleShot.php', - __DIR__ . '/Source/FirstCaller.php', - __DIR__ . '/Source/SecondCaller.php', - ], [[$argErrorMessage, 9]]]; - - // this passed from interface - $argErrorMessage = sprintf( - NarrowPublicClassMethodParamTypeByCallerTypeRule::ERROR_MESSAGE, - CallByThisFromInterface::class - ); - yield [[ - __DIR__ . '/Fixture/ThisPassedFromInterface.php', - __DIR__ . '/Source/ExpectedThisType/CallByThisFromInterface.php', - ], [[$argErrorMessage, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowPublicClassMethodParamTypeByCallerTypeRule::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/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/FirstTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/FirstTypedCaller.php deleted file mode 100644 index 87ae41d6..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/FirstTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/SecondTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/SecondTypedCaller.php deleted file mode 100644 index 3ddaf19e..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassString/SecondTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php deleted file mode 100644 index 7559c85d..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php deleted file mode 100644 index 2115fb45..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedNodeApi/CallWithProperty.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedNodeApi/CallWithProperty.php deleted file mode 100644 index 953fc231..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedNodeApi/CallWithProperty.php +++ /dev/null @@ -1,17 +0,0 @@ -callNode($property); - } - -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThis.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThis.php deleted file mode 100644 index 25550ad7..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThis.php +++ /dev/null @@ -1,15 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php deleted file mode 100644 index 43c47ccb..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/FirstTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/FirstTypedCaller.php deleted file mode 100644 index d8e8f8f0..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/FirstTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php deleted file mode 100644 index 6f87ec43..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php +++ /dev/null @@ -1,16 +0,0 @@ -run(new stdClass()); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/SecondTypedCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/SecondTypedCaller.php deleted file mode 100644 index f3e4b63b..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedType/SecondTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionArrayType.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionArrayType.php deleted file mode 100644 index f6e620ef..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/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/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionType.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionType.php deleted file mode 100644 index fd0997b2..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionType.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php deleted file mode 100644 index 3d11e4b7..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php deleted file mode 100644 index 06b448a2..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernary($value); - } - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php deleted file mode 100644 index 44354627..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernaryFlipped($value); - } - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/FirstCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/FirstCaller.php deleted file mode 100644 index 96b2d77d..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/FirstCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/FirstCaller.php deleted file mode 100644 index 34668e2a..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve('string'); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/SecondCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/SecondCaller.php deleted file mode 100644 index 45aebda1..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/SecondCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve($mixedValue); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/ThirdCaller.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/ThirdCaller.php deleted file mode 100644 index 7a45e1d0..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/MixedAndString/ThirdCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve(1000); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/FirstNullable.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/FirstNullable.php deleted file mode 100644 index c1fae48d..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/FirstNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/SecondNullable.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/SecondNullable.php deleted file mode 100644 index 45ebf77a..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/NullableParam/SecondNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/PassMeAsType.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/PassMeAsType.php deleted file mode 100644 index 68b73bff..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/PassMeAsType.php +++ /dev/null @@ -1,10 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/SomeInterface.php b/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/SomeInterface.php deleted file mode 100644 index 2cc7e62f..00000000 --- a/tests/Rules/NarrowType/NarrowPublicClassMethodParamTypeByCallerTypeRule/Source/SomeInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/ReturnFalseOnly.php', - [[NoReturnFalseInNonBoolClassMethodRule::ERROR_MESSAGE, 9]], - ]; - - yield [__DIR__ . '/Fixture/SkipReturnBool.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/config/configured_rule.neon', - ]; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoReturnFalseInNonBoolClassMethodRule::class); - } -} diff --git a/tests/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule/config/configured_rule.neon b/tests/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule/config/configured_rule.neon deleted file mode 100644 index 9ba875e7..00000000 --- a/tests/Rules/NarrowType/NoReturnFalseInNonBoolClassMethodRule/config/configured_rule.neon +++ /dev/null @@ -1,2 +0,0 @@ -rules: - - Symplify\PHPStanRules\Rules\NarrowType\NoReturnFalseInNonBoolClassMethodRule diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php b/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php deleted file mode 100644 index c929dad1..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php +++ /dev/null @@ -1,16 +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 8a8343fc..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/configured_rule.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 4d59b53d..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php +++ /dev/null @@ -1,9 +0,0 @@ -analyse($filePaths, $expectedErrorMessagesWithLines); - } - - /** - * @return Iterator - */ - public static function provideData(): Iterator - { - // might be same, but skipped for shallow nesting - see config file - yield [ - [ - __DIR__ . '/Fixture/SkipAlreadyExistingShortName.php', - __DIR__ . '/Source/SkipAlreadyExistingShortName.php', - ], - [], - ]; - - $errorMessage = sprintf( - NoDuplicatedShortClassNameRule::ERROR_MESSAGE, - 'SameShortName', - implode( - '", "', - [SameShortName::class, - \Symplify\PHPStanRules\Tests\Rules\NoDuplicatedShortClassNameRule\Fixture\Nested\OneMoreNested\SameShortName::class, - ] - ) - ); - - yield [ - [ - __DIR__ . '/Fixture/Nested/SameShortName.php', - __DIR__ . '/Fixture/Nested/OneMoreNested/SameShortName.php', - ], - [[$errorMessage, 7]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoDuplicatedShortClassNameRule::class); - } -} diff --git a/tests/Rules/NoDuplicatedShortClassNameRule/Source/SkipAlreadyExistingShortName.php b/tests/Rules/NoDuplicatedShortClassNameRule/Source/SkipAlreadyExistingShortName.php deleted file mode 100644 index c13c8858..00000000 --- a/tests/Rules/NoDuplicatedShortClassNameRule/Source/SkipAlreadyExistingShortName.php +++ /dev/null @@ -1,10 +0,0 @@ -$value(); - } -} diff --git a/tests/Rules/NoDynamicNameRule/Fixture/DynamicPropertyFetch.php b/tests/Rules/NoDynamicNameRule/Fixture/DynamicPropertyFetch.php deleted file mode 100644 index f6ed6c91..00000000 --- a/tests/Rules/NoDynamicNameRule/Fixture/DynamicPropertyFetch.php +++ /dev/null @@ -1,12 +0,0 @@ -$value; - } -} diff --git a/tests/Rules/NoDynamicNameRule/Fixture/DynamicStaticMethodCallName.php b/tests/Rules/NoDynamicNameRule/Fixture/DynamicStaticMethodCallName.php deleted file mode 100644 index 3c137a47..00000000 --- a/tests/Rules/NoDynamicNameRule/Fixture/DynamicStaticMethodCallName.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/DynamicConstantName.php', [[NoDynamicNameRule::ERROR_MESSAGE, 10]]]; - yield [__DIR__ . '/Fixture/DynamicMethodCallName.php', [[NoDynamicNameRule::ERROR_MESSAGE, 11]]]; - yield [__DIR__ . '/Fixture/DynamicStaticMethodCallName.php', [[NoDynamicNameRule::ERROR_MESSAGE, 11]]]; - yield [__DIR__ . '/Fixture/DynamicFuncCallName.php', [[NoDynamicNameRule::ERROR_MESSAGE, 11]]]; - - yield [__DIR__ . '/Fixture/DynamicPropertyFetch.php', [[NoDynamicNameRule::ERROR_MESSAGE, 10]]]; - yield [__DIR__ . '/Fixture/DynamicClassOnStaticPropertyFetch.php', [[NoDynamicNameRule::ERROR_MESSAGE, 10]]]; - - yield [__DIR__ . '/Fixture/SkipObjectClassOnPhp8.php', []]; - yield [__DIR__ . '/Fixture/SkipInvokable.php', []]; - yield [__DIR__ . '/Fixture/SkipClosure.php', []]; - yield [__DIR__ . '/Fixture/SkipCallable.php', []]; - yield [__DIR__ . '/Fixture/SkipNullableClosure.php', []]; - yield [__DIR__ . '/Fixture/SkipImmediatelyInvokedFunctionExpression.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoDynamicNameRule::class); - } -} diff --git a/tests/Rules/NoDynamicNameRule/Source/SomeInvokableClass.php b/tests/Rules/NoDynamicNameRule/Source/SomeInvokableClass.php deleted file mode 100644 index 670950b5..00000000 --- a/tests/Rules/NoDynamicNameRule/Source/SomeInvokableClass.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/InlineMatchRegex.php', [[NoInlineStringRegexRule::ERROR_MESSAGE, 11]]]; - yield [ - __DIR__ . '/Fixture/NetteUtilsStringsInlineMatchRegex.php', - [[NoInlineStringRegexRule::ERROR_MESSAGE, 13]], - ]; - - yield [__DIR__ . '/Fixture/SkipVariable.php', []]; - yield [__DIR__ . '/Fixture/SkipSingleLetter.php', []]; - yield [__DIR__ . '/Fixture/SkipConstRegex.php', []]; - yield [__DIR__ . '/Fixture/SkipNetteUtilsStringsConstRegex.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoInlineStringRegexRule::class); - } -} diff --git a/tests/Rules/NoInlineStringRegexRule/config/configured_rule.neon b/tests/Rules/NoInlineStringRegexRule/config/configured_rule.neon deleted file mode 100644 index 06c63f38..00000000 --- a/tests/Rules/NoInlineStringRegexRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoInlineStringRegexRule diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php b/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php deleted file mode 100644 index 588062ed..00000000 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php +++ /dev/null @@ -1,21 +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 a39ec0e3..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/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoIssetOnObjectRule::class); - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/config/configured_rule.neon b/tests/Rules/NoIssetOnObjectRule/config/configured_rule.neon deleted file mode 100644 index 753ee29d..00000000 --- a/tests/Rules/NoIssetOnObjectRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoIssetOnObjectRule diff --git a/tests/Rules/NoMissingDirPathRule/Fixture/FileMissing.php b/tests/Rules/NoMissingDirPathRule/Fixture/FileMissing.php deleted file mode 100644 index 6910d282..00000000 --- a/tests/Rules/NoMissingDirPathRule/Fixture/FileMissing.php +++ /dev/null @@ -1,13 +0,0 @@ -assertFileExists(__DIR__ . '/../PotentialFile.php'); - $this->assertFileNotExists(__DIR__ . '/../../PotentialFile.php'); - - if (method_exists($this, 'assertFileDoesNotExist')) { - $this->assertFileDoesNotExist(__DIR__ . '/temp/file.php'); - } else { - $this->assertFileNotExists(__DIR__ . '/temp/file.php'); - } - - $possibleFile = __DIR__ . '/Whatever'; - } -} diff --git a/tests/Rules/NoMissingDirPathRule/Fixture/SkipBracketPathFromSymfonyConfigImport.php b/tests/Rules/NoMissingDirPathRule/Fixture/SkipBracketPathFromSymfonyConfigImport.php deleted file mode 100644 index f3bede11..00000000 --- a/tests/Rules/NoMissingDirPathRule/Fixture/SkipBracketPathFromSymfonyConfigImport.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - $message = sprintf(NoMissingDirPathRule::ERROR_MESSAGE, '/not_here.php'); - yield [__DIR__ . '/Fixture/FileMissing.php', [[$message, 11]]]; - - yield [__DIR__ . '/Fixture/SkipBracketPathFromSymfonyConfigImport.php', []]; - yield [__DIR__ . '/Fixture/SkipConcat.php', []]; - yield [__DIR__ . '/Fixture/SkipVendorAutoload.php', []]; - yield [__DIR__ . '/Fixture/SkipVendorAutoload.php', []]; - yield [__DIR__ . '/Fixture/SkipAssertMethod.php', []]; - yield [__DIR__ . '/Fixture/SkipFnMatch.php', []]; - yield [__DIR__ . '/Fixture/SkipFileExistsFuncCall.php', []]; - yield [__DIR__ . '/Fixture/SkipFileExistsFuncCallOneLayerAbove.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMissingDirPathRule::class); - } -} diff --git a/tests/Rules/NoMissingDirPathRule/config/configured_rule.neon b/tests/Rules/NoMissingDirPathRule/config/configured_rule.neon deleted file mode 100644 index fa682f0c..00000000 --- a/tests/Rules/NoMissingDirPathRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoMissingDirPathRule diff --git a/tests/Rules/NoNullableArrayPropertyRule/Fixture/NullableArrayProperty.php b/tests/Rules/NoNullableArrayPropertyRule/Fixture/NullableArrayProperty.php deleted file mode 100644 index ccc484fc..00000000 --- a/tests/Rules/NoNullableArrayPropertyRule/Fixture/NullableArrayProperty.php +++ /dev/null @@ -1,11 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipNoType.php', []]; - yield [__DIR__ . '/Fixture/SkipNotNullable.php', []]; - yield [__DIR__ . '/Fixture/SkipNotArray.php', []]; - yield [__DIR__ . '/Fixture/SkipClassNameProperty.php', []]; - yield [__DIR__ . '/Fixture/NullableArrayProperty.php', [[NoNullableArrayPropertyRule::ERROR_MESSAGE, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoNullableArrayPropertyRule::class); - } -} diff --git a/tests/Rules/NoNullableArrayPropertyRule/config/configured_rule.neon b/tests/Rules/NoNullableArrayPropertyRule/config/configured_rule.neon deleted file mode 100644 index f982c7bc..00000000 --- a/tests/Rules/NoNullableArrayPropertyRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoNullableArrayPropertyRule diff --git a/tests/Rules/NoReferenceRule/Fixture/AssignReference.php b/tests/Rules/NoReferenceRule/Fixture/AssignReference.php deleted file mode 100644 index ee683365..00000000 --- a/tests/Rules/NoReferenceRule/Fixture/AssignReference.php +++ /dev/null @@ -1,16 +0,0 @@ -args[1]; - $some = &$arg->value; - } -} diff --git a/tests/Rules/NoReferenceRule/Fixture/FunctionWithReference.php b/tests/Rules/NoReferenceRule/Fixture/FunctionWithReference.php deleted file mode 100644 index cdd88fec..00000000 --- a/tests/Rules/NoReferenceRule/Fixture/FunctionWithReference.php +++ /dev/null @@ -1,9 +0,0 @@ -run([&$argument]); - } - - private function run(array $array) - { - } -} diff --git a/tests/Rules/NoReferenceRule/Fixture/SkipParentMethodWithReference.php b/tests/Rules/NoReferenceRule/Fixture/SkipParentMethodWithReference.php deleted file mode 100644 index 597703d2..00000000 --- a/tests/Rules/NoReferenceRule/Fixture/SkipParentMethodWithReference.php +++ /dev/null @@ -1,14 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/MethodWithReference.php', [[NoReferenceRule::ERROR_MESSAGE, 9]]]; - yield [__DIR__ . '/Fixture/FunctionWithReference.php', [[NoReferenceRule::ERROR_MESSAGE, 7]]]; - yield [__DIR__ . '/Fixture/VariableReference.php', [[NoReferenceRule::ERROR_MESSAGE, 11]]]; - yield [__DIR__ . '/Fixture/ReferenceArgument.php', [[NoReferenceRule::ERROR_MESSAGE, 11]]]; - yield [__DIR__ . '/Fixture/AssignReference.php', [[NoReferenceRule::ERROR_MESSAGE, 14]]]; - - yield [__DIR__ . '/Fixture/SkipUseInReference.php', []]; - yield [__DIR__ . '/Fixture/SkipParentMethodWithReference.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoReferenceRule::class); - } -} diff --git a/tests/Rules/NoReferenceRule/Source/AbstractSomeParentClassWithReference.php b/tests/Rules/NoReferenceRule/Source/AbstractSomeParentClassWithReference.php deleted file mode 100644 index 35001a16..00000000 --- a/tests/Rules/NoReferenceRule/Source/AbstractSomeParentClassWithReference.php +++ /dev/null @@ -1,12 +0,0 @@ - 'Yes', - self::NO => 'No', - ]; - } -} diff --git a/tests/Rules/NoReturnArrayVariableListRule/Fixture/ReturnVariables.php b/tests/Rules/NoReturnArrayVariableListRule/Fixture/ReturnVariables.php deleted file mode 100644 index a0267e1f..00000000 --- a/tests/Rules/NoReturnArrayVariableListRule/Fixture/ReturnVariables.php +++ /dev/null @@ -1,14 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/ReturnVariables.php', [[NoReturnArrayVariableListRule::ERROR_MESSAGE, 11]]]; - - yield [__DIR__ . '/Fixture/Enum/SkipEnum.php', []]; - yield [__DIR__ . '/Fixture/SkipReturnOne.php', []]; - yield [__DIR__ . '/Fixture/SkipNews.php', []]; - yield [__DIR__ . '/Fixture/ValueObject/SkipValueObject.php', []]; - yield [__DIR__ . '/Fixture/SkipParentMethod.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoReturnArrayVariableListRule::class); - } -} diff --git a/tests/Rules/NoReturnArrayVariableListRule/config/configured_rule.neon b/tests/Rules/NoReturnArrayVariableListRule/config/configured_rule.neon deleted file mode 100644 index 176c5712..00000000 --- a/tests/Rules/NoReturnArrayVariableListRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoReturnArrayVariableListRule diff --git a/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipArrayFilter.php b/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipArrayFilter.php deleted file mode 100644 index 9c136278..00000000 --- a/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipArrayFilter.php +++ /dev/null @@ -1,15 +0,0 @@ -name === 'hey') { - return; - } - - $this->name = $name; - } -} diff --git a/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipRoute.php b/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipRoute.php deleted file mode 100644 index 8a3bca10..00000000 --- a/tests/Rules/NoReturnSetterMethodRule/Fixture/SkipRoute.php +++ /dev/null @@ -1,17 +0,0 @@ -name = $name; - } -} diff --git a/tests/Rules/NoReturnSetterMethodRule/Fixture/SomeSetterClass.php b/tests/Rules/NoReturnSetterMethodRule/Fixture/SomeSetterClass.php deleted file mode 100644 index 1f3c43ff..00000000 --- a/tests/Rules/NoReturnSetterMethodRule/Fixture/SomeSetterClass.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SomeSetterClass.php', [[NoReturnSetterMethodRule::ERROR_MESSAGE, 9]]]; - - yield [__DIR__ . '/Fixture/SkipRoute.php', []]; - yield [__DIR__ . '/Fixture/SkipEmptyReturn.php', []]; - yield [__DIR__ . '/Fixture/SkipVoidSetter.php', []]; - yield [__DIR__ . '/Fixture/SkipSetUp.php', []]; - yield [__DIR__ . '/Fixture/SkipArrayFilter.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoReturnSetterMethodRule::class); - } -} diff --git a/tests/Rules/NoReturnSetterMethodRule/config/configured_rule.neon b/tests/Rules/NoReturnSetterMethodRule/config/configured_rule.neon deleted file mode 100644 index 21f69cee..00000000 --- a/tests/Rules/NoReturnSetterMethodRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule diff --git a/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SkipApiMock.php b/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SkipApiMock.php deleted file mode 100644 index 789634fb..00000000 --- a/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SkipApiMock.php +++ /dev/null @@ -1,16 +0,0 @@ -createMock(SomeAllowedType::class); - } -} diff --git a/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SomeMocking.php b/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SomeMocking.php deleted file mode 100644 index 66df9c7d..00000000 --- a/tests/Rules/PHPUnit/NoTestMocksRule/Fixture/SomeMocking.php +++ /dev/null @@ -1,15 +0,0 @@ -createMock('SomeClass'); - } -} diff --git a/tests/Rules/PHPUnit/NoTestMocksRule/NoTestMocksRuleTest.php b/tests/Rules/PHPUnit/NoTestMocksRule/NoTestMocksRuleTest.php deleted file mode 100644 index 9cd4738a..00000000 --- a/tests/Rules/PHPUnit/NoTestMocksRule/NoTestMocksRuleTest.php +++ /dev/null @@ -1,45 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/SomeMocking.php', - [[sprintf(NoTestMocksRule::ERROR_MESSAGE, 'SomeClass'), 13]], - ]; - - yield [__DIR__ . '/Fixture/SkipApiMock.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/config/configured_rule.neon', - ]; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoTestMocksRule::class); - } -} diff --git a/tests/Rules/PHPUnit/NoTestMocksRule/Source/SomeAllowedType.php b/tests/Rules/PHPUnit/NoTestMocksRule/Source/SomeAllowedType.php deleted file mode 100644 index 16c9e7fb..00000000 --- a/tests/Rules/PHPUnit/NoTestMocksRule/Source/SomeAllowedType.php +++ /dev/null @@ -1,7 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - $errorMessage = sprintf(PreferredClassRule::ERROR_MESSAGE, NativeDateTime::class, DateTime::class); - yield [__DIR__ . '/Fixture/ClassUsingOld.php', [[$errorMessage, 13]]]; - yield [__DIR__ . '/Fixture/ClassExtendingOld.php', [[$errorMessage, 9]]]; - yield [__DIR__ . '/Fixture/ClassMethodParameterUsingOld.php', [[$errorMessage, 11]]]; - yield [__DIR__ . '/Fixture/SomeStaticCall.php', [[$errorMessage, 13]]]; - - $errorMessage = sprintf( - PreferredClassRule::ERROR_MESSAGE, - AbstractNotWhatYouWant::class, - SkipPreferredExtendingTheOldOne::class - ); - yield [__DIR__ . '/Fixture/InstanceOfName.php', [[$errorMessage, 13]]]; - - yield [__DIR__ . '/Fixture/SkipPreferredExtendingTheOldOne.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(PreferredClassRule::class); - } -} diff --git a/tests/Rules/PreferredClassRule/Source/AbstractNotWhatYouWant.php b/tests/Rules/PreferredClassRule/Source/AbstractNotWhatYouWant.php deleted file mode 100644 index e0bfb566..00000000 --- a/tests/Rules/PreferredClassRule/Source/AbstractNotWhatYouWant.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - /** - * @return Iterator> - */ - public static function provideData(): Iterator - { - $errorMessage = sprintf(PreventParentMethodVisibilityOverrideRule::ERROR_MESSAGE, 'run', 'protected'); - yield [__DIR__ . '/Fixture/ClassWithOverridingVisibility.php', [[$errorMessage, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(PreventParentMethodVisibilityOverrideRule::class); - } -} diff --git a/tests/Rules/PreventParentMethodVisibilityOverrideRule/config/configured_rule.neon b/tests/Rules/PreventParentMethodVisibilityOverrideRule/config/configured_rule.neon deleted file mode 100644 index a8f51950..00000000 --- a/tests/Rules/PreventParentMethodVisibilityOverrideRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule diff --git a/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/Fixture/NewOnExternal.php b/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/Fixture/NewOnExternal.php deleted file mode 100644 index e4865298..00000000 --- a/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/Fixture/NewOnExternal.php +++ /dev/null @@ -1,15 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/NewOnExternal.php', [[NoClassReflectionStaticReflectionRule::ERROR_MESSAGE, 13]]]; - - yield [__DIR__ . '/Fixture/SkipAllowedType.php', []]; - yield [__DIR__ . '/Fixture/SkipNonReflectionNew.php', []]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoClassReflectionStaticReflectionRule::class); - } -} diff --git a/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/config/configured_rule.neon b/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/config/configured_rule.neon deleted file mode 100644 index 03e55f2d..00000000 --- a/tests/Rules/Rector/NoClassReflectionStaticReflectionRule/config/configured_rule.neon +++ /dev/null @@ -1,2 +0,0 @@ -rules: - - Symplify\PHPStanRules\Rules\Rector\NoClassReflectionStaticReflectionRule diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/InstanceofWithType.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/InstanceofWithType.php deleted file mode 100644 index c305dfd9..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/InstanceofWithType.php +++ /dev/null @@ -1,19 +0,0 @@ -> - */ - private const BEFORE_TRAIT_TYPES = [TraitUse::class, Property::class, ClassMethod::class]; - - public function find(object $node): bool - { - foreach (self::BEFORE_TRAIT_TYPES as $beforeTraitType) { - if (is_a($node, $beforeTraitType, true)) { - return true; - } - } - - return false; - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipGenericNodeType.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipGenericNodeType.php deleted file mode 100644 index f52533e5..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipGenericNodeType.php +++ /dev/null @@ -1,21 +0,0 @@ - $type - */ - public function find(object $node, string $type): bool - { - if (is_a($node, $type, true)) { - return true; - } - - return true; - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAGenericClassString.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAGenericClassString.php deleted file mode 100644 index 6ddee56e..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAGenericClassString.php +++ /dev/null @@ -1,26 +0,0 @@ - $type - * @return T|null - */ - public function findParentType(Node $parent, string $type) - { - do { - if (is_a($parent, $type, true)) { - return $parent; - } - } while ($parent = $parent->getAttribute('parent_node')); - - return null; - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAsClassString.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAsClassString.php deleted file mode 100644 index cde6580d..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipIsAsClassString.php +++ /dev/null @@ -1,20 +0,0 @@ - $desiredType - */ - private function hasOnlyStmtOfType(If_ $if, string $desiredType): bool - { - $stmts = $if->stmts; - return is_a($stmts[0], $desiredType); - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipPHPStanType.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipPHPStanType.php deleted file mode 100644 index c5d00698..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipPHPStanType.php +++ /dev/null @@ -1,15 +0,0 @@ - $type - */ - public function find(object $node, $type): bool - { - return is_a($node, $type, true); - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipReflection.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipReflection.php deleted file mode 100644 index 3aa42a0f..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture/SkipReflection.php +++ /dev/null @@ -1,19 +0,0 @@ -> - */ - private const COLLECTABLE_NODE_TYPES = [ - Class_::class, - Interface_::class, - ClassConst::class, - ClassConstFetch::class, - New_::class, - StaticCall::class, - MethodCall::class, - Array_::class, - Param::class, - ]; - - public function isCollectableNode(Node $node): bool - { - foreach (self::COLLECTABLE_NODE_TYPES as $collectableNodeType) { - /** @var class-string $collectableNodeType */ - if (is_a($node, $collectableNodeType, true)) { - return true; - } - } - - return false; - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/NoInstanceOfStaticReflectionRuleTest.php b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/NoInstanceOfStaticReflectionRuleTest.php deleted file mode 100644 index 600c7ba1..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/NoInstanceOfStaticReflectionRuleTest.php +++ /dev/null @@ -1,54 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - $errorMessage = NoInstanceOfStaticReflectionRule::ERROR_MESSAGE; - yield [__DIR__ . '/Fixture/InstanceofWithType.php', [[$errorMessage, 13]]]; - - $errorMessage = NoInstanceOfStaticReflectionRule::ERROR_MESSAGE; - yield [__DIR__ . '/Fixture/IsAWithType.php', [[$errorMessage, 13]]]; - - yield [__DIR__ . '/Fixture/SkipAllowedType.php', []]; - yield [__DIR__ . '/Fixture/SkipGenericNodeType.php', []]; - yield [__DIR__ . '/Fixture/SkipIsAGenericClassString.php', []]; - yield [__DIR__ . '/Fixture/SkipIsAsClassString.php', []]; - yield [__DIR__ . '/Fixture/SkipArrayClassString.php', []]; - yield [__DIR__ . '/Fixture/SkipReflection.php', []]; - yield [__DIR__ . '/Fixture/SkipTypesArray.php', []]; - yield [__DIR__ . '/Fixture/SkipSymfony.php', []]; - yield [__DIR__ . '/Fixture/SkipPhpDocNode.php', []]; - yield [__DIR__ . '/Fixture/SkipPHPStanType.php', []]; - yield [__DIR__ . '/Fixture/SkipSelfType.php', []]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoInstanceOfStaticReflectionRule::class); - } -} diff --git a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/config/configured_rule.neon b/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/config/configured_rule.neon deleted file mode 100644 index 4b1c9d43..00000000 --- a/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/config/configured_rule.neon +++ /dev/null @@ -1,2 +0,0 @@ -rules: - - Symplify\PHPStanRules\Rules\Rector\NoInstanceOfStaticReflectionRule diff --git a/tests/Rules/Rector/NoLeadingBackslashInNameRule/Fixture/LeadingBackslashInName.php b/tests/Rules/Rector/NoLeadingBackslashInNameRule/Fixture/LeadingBackslashInName.php deleted file mode 100644 index df6f7f7a..00000000 --- a/tests/Rules/Rector/NoLeadingBackslashInNameRule/Fixture/LeadingBackslashInName.php +++ /dev/null @@ -1,15 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - $errorMessage = NoLeadingBackslashInNameRule::ERROR_MESSAGE; - yield [__DIR__ . '/Fixture/LeadingBackslashInName.php', [[$errorMessage, 13]]]; - - yield [__DIR__ . '/Fixture/SkipNoBackslash.php', []]; - yield [__DIR__ . '/Fixture/SkipUseFullyQualified.php', []]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoLeadingBackslashInNameRule::class); - } -} diff --git a/tests/Rules/Rector/NoLeadingBackslashInNameRule/config/configured_rule.neon b/tests/Rules/Rector/NoLeadingBackslashInNameRule/config/configured_rule.neon deleted file mode 100644 index c6649019..00000000 --- a/tests/Rules/Rector/NoLeadingBackslashInNameRule/config/configured_rule.neon +++ /dev/null @@ -1,2 +0,0 @@ -rules: - - Symplify\PHPStanRules\Rules\Rector\NoLeadingBackslashInNameRule diff --git a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Fixture/DowngradePhp80/SomePhpFeature2Rector.php b/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Fixture/DowngradePhp80/SomePhpFeature2Rector.php deleted file mode 100644 index 532d17a0..00000000 --- a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Fixture/DowngradePhp80/SomePhpFeature2Rector.php +++ /dev/null @@ -1,27 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipSomePhpFeatureRector.php', []]; - yield [__DIR__ . '/Fixture/Php80/SkipConfigurableRector.php', []]; - - $errorMessage = sprintf( - PhpUpgradeDowngradeRegisteredInSetRule::ERROR_MESSAGE, - SomePhpFeatureRector::class, - 'php80.php' - ); - yield [__DIR__ . '/Fixture/Php80/SomePhpFeatureRector.php', [[$errorMessage, 10]]]; - - $errorMessage = sprintf( - PhpUpgradeDowngradeRegisteredInSetRule::ERROR_MESSAGE, - SomePhpFeature2Rector::class, - 'downgrade-php80.php' - ); - yield [__DIR__ . '/Fixture/DowngradePhp80/SomePhpFeature2Rector.php', [[$errorMessage, 12]]]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(PhpUpgradeDowngradeRegisteredInSetRule::class); - } -} diff --git a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Source/Set/downgrade-php80.php b/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Source/Set/downgrade-php80.php deleted file mode 100644 index b1e0877e..00000000 --- a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Source/Set/downgrade-php80.php +++ /dev/null @@ -1,5 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipDowngradeRector.php', []]; - yield [__DIR__ . '/Fixture/SkipAlreadyImplementsMinPhpVersionRector.php', []]; - yield [__DIR__ . '/Fixture/SomePhpFeatureRector.php', [ - [ - sprintf( - PhpUpgradeImplementsMinPhpVersionInterfaceRule::ERROR_MESSAGE, - SomePhpFeatureRector::class - ), - 7, - ], - ]]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(PhpUpgradeImplementsMinPhpVersionInterfaceRule::class); - } -} diff --git a/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/config/configured_rule.neon b/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/config/configured_rule.neon deleted file mode 100644 index 38b70a18..00000000 --- a/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/config/configured_rule.neon +++ /dev/null @@ -1,3 +0,0 @@ -rules: - - Symplify\PHPStanRules\Rules\Rector\PhpUpgradeImplementsMinPhpVersionInterfaceRule - diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/MissingConfigureWithAssert.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/MissingConfigureWithAssert.php deleted file mode 100644 index 3cd894bd..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/MissingConfigureWithAssert.php +++ /dev/null @@ -1,42 +0,0 @@ - $configuration - */ - public function configure(array $configuration): void - { - $valueObjects = $configuration[self::SOME_KEY] ?? []; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('...', []); - } - - public function getNodeTypes(): array - { - return []; - } - - public function refactor(Node $node) - { - return null; - } -} diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssert.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssert.php deleted file mode 100644 index d69f7de4..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssert.php +++ /dev/null @@ -1,26 +0,0 @@ - $configuration - */ - public function configure(array $configuration): void - { - $valueObjects = $configuration[self::SOME_KEY] ?? []; - Assert::allIsAOf($valueObjects, SomeValueObject::class); - } -} diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssertInstanceof.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssertInstanceof.php deleted file mode 100644 index 8bf96a38..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipConfigureWithAssertInstanceof.php +++ /dev/null @@ -1,26 +0,0 @@ - $configuration - */ - public function configure(array $configuration): void - { - $valueObjects = $configuration[self::SOME_KEY] ?? []; - Assert::allIsInstanceOf($valueObjects, SomeValueObject::class); - } -} diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipNoArray.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipNoArray.php deleted file mode 100644 index 1956196a..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Fixture/SkipNoArray.php +++ /dev/null @@ -1,23 +0,0 @@ - $configuration - */ - public function configure(array $configuration): void - { - $valueObjects = $configuration[self::SOME_KEY] ?? []; - } -} diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/RequireAssertConfigureValueObjectRectorRuleTest.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/RequireAssertConfigureValueObjectRectorRuleTest.php deleted file mode 100644 index 6c69e57d..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/RequireAssertConfigureValueObjectRectorRuleTest.php +++ /dev/null @@ -1,42 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/MissingConfigureWithAssert.php', [[RequireAssertConfigureValueObjectRectorRule::ERROR_MESSAGE, 23]]]; - - yield [__DIR__ . '/Fixture/SkipConfigureWithAssert.php', []]; - yield [__DIR__ . '/Fixture/SkipConfigureWithAssertInstanceof.php', []]; - yield [__DIR__ . '/Fixture/SkipNoArray.php', []]; - } - - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireAssertConfigureValueObjectRectorRule::class); - } -} diff --git a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Source/SomeValueObject.php b/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Source/SomeValueObject.php deleted file mode 100644 index 55efb473..00000000 --- a/tests/Rules/Rector/RequireAssertConfigureValueObjectRectorRule/Source/SomeValueObject.php +++ /dev/null @@ -1,9 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - /** - * @return Iterator> - */ - public static function provideData(): Iterator - { - $errorMessage = sprintf(RegexSuffixInRegexConstantRule::ERROR_MESSAGE, 'SOME_NAME'); - - yield [__DIR__ . '/Fixture/DifferentSuffix.php', [[$errorMessage, 15]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RegexSuffixInRegexConstantRule::class); - } -} diff --git a/tests/Rules/RegexSuffixInRegexConstantRule/config/configured_rule.neon b/tests/Rules/RegexSuffixInRegexConstantRule/config/configured_rule.neon deleted file mode 100644 index 472dba51..00000000 --- a/tests/Rules/RegexSuffixInRegexConstantRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\RegexSuffixInRegexConstantRule diff --git a/tests/Rules/RequireAttributeNameRule/Fixture/MissingName.php b/tests/Rules/RequireAttributeNameRule/Fixture/MissingName.php deleted file mode 100644 index c0f10f7e..00000000 --- a/tests/Rules/RequireAttributeNameRule/Fixture/MissingName.php +++ /dev/null @@ -1,15 +0,0 @@ -analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/MissingName.php', [[RequireAttributeNameRule::ERROR_MESSAGE, 11]]]; - - yield [__DIR__ . '/Fixture/SkipCorrectName.php', []]; - yield [__DIR__ . '/Fixture/SkipDefaultName.php', []]; - yield [__DIR__ . '/Fixture/SkipPHPUnitAttributes.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireAttributeNameRule::class); - } -} diff --git a/tests/Rules/RequireAttributeNameRule/config/configured_rule.neon b/tests/Rules/RequireAttributeNameRule/config/configured_rule.neon deleted file mode 100644 index 5d8751d9..00000000 --- a/tests/Rules/RequireAttributeNameRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\RequireAttributeNameRule diff --git a/tests/Rules/SeeAnnotationToTestRule/Fixture/RuleWithSee.php b/tests/Rules/SeeAnnotationToTestRule/Fixture/RuleWithSee.php deleted file mode 100644 index 6d7ce2b6..00000000 --- a/tests/Rules/SeeAnnotationToTestRule/Fixture/RuleWithSee.php +++ /dev/null @@ -1,24 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - $errorMessage = sprintf(SeeAnnotationToTestRule::ERROR_MESSAGE, RuleWithoutSee::class); - yield [__DIR__ . '/Fixture/RuleWithoutSee.php', [[$errorMessage, 12]]]; - - $errorMessage = sprintf(SeeAnnotationToTestRule::ERROR_MESSAGE, RuleWithSeeRandom::class); - yield [__DIR__ . '/Fixture/RuleWithSeeRandom.php', [[$errorMessage, 15]]]; - - yield [__DIR__ . '/Fixture/SkipDeprecatedRuleWithoutSee.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(SeeAnnotationToTestRule::class); - } -} diff --git a/tests/Rules/SeeAnnotationToTestRule/config/configured_rule.neon b/tests/Rules/SeeAnnotationToTestRule/config/configured_rule.neon deleted file mode 100644 index 6de88d79..00000000 --- a/tests/Rules/SeeAnnotationToTestRule/config/configured_rule.neon +++ /dev/null @@ -1,10 +0,0 @@ -includes: - - ../../../config/included_services.neon - -services: - - - class: Symplify\PHPStanRules\Rules\SeeAnnotationToTestRule - tags: [phpstan.rules.rule] - arguments: - requiredSeeTypes: - - PHPStan\Rules\Rule diff --git a/tests/Rules/UppercaseConstantRule/Fixture/ConstantLower.php b/tests/Rules/UppercaseConstantRule/Fixture/ConstantLower.php deleted file mode 100644 index e0942c48..00000000 --- a/tests/Rules/UppercaseConstantRule/Fixture/ConstantLower.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - /** - * @return Iterator|string>> - */ - public static function provideData(): Iterator - { - $errorMessage = sprintf(UppercaseConstantRule::ERROR_MESSAGE, 'SMall'); - yield [__DIR__ . '/Fixture/ConstantLower.php', [[$errorMessage, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(UppercaseConstantRule::class); - } -} diff --git a/tests/Rules/UppercaseConstantRule/config/configured_rule.neon b/tests/Rules/UppercaseConstantRule/config/configured_rule.neon deleted file mode 100644 index 510e5da4..00000000 --- a/tests/Rules/UppercaseConstantRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../config/included_services.neon - -rules: - - Symplify\PHPStanRules\Rules\UppercaseConstantRule 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/Symfony/Rules/RequireInvokableControllerRule/Fixture/MissnamedController.php b/tests/Symfony/Rules/RequireInvokableControllerRule/Fixture/MissnamedController.php deleted file mode 100644 index 67d0eb2d..00000000 --- a/tests/Symfony/Rules/RequireInvokableControllerRule/Fixture/MissnamedController.php +++ /dev/null @@ -1,18 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/MissnamedRouteAttributeController.php', - [[RequireInvokableControllerRule::ERROR_MESSAGE, 12]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireInvokableControllerRule::class); - } -} diff --git a/tests/Symfony/Rules/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php b/tests/Symfony/Rules/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php deleted file mode 100644 index 432a6d1e..00000000 --- a/tests/Symfony/Rules/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php +++ /dev/null @@ -1,44 +0,0 @@ -analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipInvokableController.php', []]; - yield [__DIR__ . '/Fixture/SkipRandomPublicMethodController.php', []]; - - yield [__DIR__ . '/Fixture/MissnamedController.php', [[RequireInvokableControllerRule::ERROR_MESSAGE, 15]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(RequireInvokableControllerRule::class); - } -} diff --git a/tests/Symfony/Rules/RequireInvokableControllerRule/config/configured_rule.neon b/tests/Symfony/Rules/RequireInvokableControllerRule/config/configured_rule.neon deleted file mode 100644 index f8313e81..00000000 --- a/tests/Symfony/Rules/RequireInvokableControllerRule/config/configured_rule.neon +++ /dev/null @@ -1,5 +0,0 @@ -includes: - - ../../../../../tests/config/included_services.neon - -rules: - - Symplify\PHPStanRules\Symfony\Rules\RequireInvokableControllerRule diff --git a/tests/config/included_services.neon b/tests/config/included_services.neon deleted file mode 100644 index bdcc782c..00000000 --- a/tests/config/included_services.neon +++ /dev/null @@ -1,2 +0,0 @@ -includes: - - ../../config/services/services.neon