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 5bdd9af7..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.2"
- },
- "require-dev": {
- "nikic/php-parser": "^4.19",
- "symplify/phpstan-extensions": "^11.4",
- "symplify/rule-doc-generator": "^12.1",
- "phpunit/phpunit": "^10.5",
- "symfony/framework-bundle": "6.1.*",
- "rector/rector": "^1.1",
- "symplify/easy-coding-standard": "^12.2",
- "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 d18bc2ca..00000000
--- a/phpstan.neon
+++ /dev/null
@@ -1,45 +0,0 @@
-includes:
- - config/services/services.neon
- - config/naming-rules.neon
-
-parameters:
- level: 8
-
- paths:
- - src
- - config
- - tests
-
- excludePaths:
- # parallel
- - packages/*-phpstan-printer/tests/*ToPhpCompiler/Fixture*
-
- # tests
- - '*/tests/**/Source/*'
- - */stubs/*
- - */Fixture/*
-
- ignoreErrors:
- -
- message: '#Generator expects value type (.*?) given#'
- paths:
- - tests/Rules
-
- # needless generics
- - '#Class Symplify\\PHPStanRules\\(.*?)Rule implements generic interface PHPStan\\Rules\\Rule but does not specify its types\: TNodeType#'
-
- - '#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#'
-
- # 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#'
-
- # overly detailed
- - '#Class Symplify\\PHPStanRules\\Collector\\(.*?) implements generic interface PHPStan\\Collectors\\Collector but does not specify its types\: TNodeType, TValue#'
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/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/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/TypeAwareNodeFinder.php b/src/NodeFinder/TypeAwareNodeFinder.php
index e00a884f..6b364e31 100644
--- a/src/NodeFinder/TypeAwareNodeFinder.php
+++ b/src/NodeFinder/TypeAwareNodeFinder.php
@@ -12,7 +12,11 @@
*/
final class TypeAwareNodeFinder
{
- private readonly NodeFinder $nodeFinder;
+ /**
+ * @readonly
+ * @var \PhpParser\NodeFinder
+ */
+ private $nodeFinder;
public function __construct()
{
@@ -22,11 +26,11 @@ public function __construct()
/**
* @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/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/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/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/Reflection/ReflectionParser.php b/src/Reflection/ReflectionParser.php
index a2c6bd41..2b32b47b 100644
--- a/src/Reflection/ReflectionParser.php
+++ b/src/Reflection/ReflectionParser.php
@@ -20,21 +20,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) {
@@ -57,7 +70,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) {
@@ -71,7 +87,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];
@@ -87,7 +103,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 c84e3424..d9a403d9 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/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 49d722b0..f02c8e53 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/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 19afa4d9..01606d9f 100644
--- a/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php
+++ b/src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php
@@ -18,14 +18,18 @@
/**
* @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenMultipleClassLikeInOneFileRule\ForbiddenMultipleClassLikeInOneFileRuleTest
*/
-final class ForbiddenMultipleClassLikeInOneFileRule implements Rule, DocumentedRuleInterface
+final class ForbiddenMultipleClassLikeInOneFileRule implements Rule
{
/**
* @var string
*/
public const ERROR_MESSAGE = 'Multiple class/interface/trait is not allowed in single file';
- private readonly NodeFinder $nodeFinder;
+ /**
+ * @readonly
+ * @var \PhpParser\NodeFinder
+ */
+ private $nodeFinder;
public function __construct(
) {
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/ForbiddenStaticClassConstFetchRule.php b/src/Rules/ForbiddenStaticClassConstFetchRule.php
index aae53e98..480d2b53 100644
--- a/src/Rules/ForbiddenStaticClassConstFetchRule.php
+++ b/src/Rules/ForbiddenStaticClassConstFetchRule.php
@@ -16,7 +16,7 @@
/**
* @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenStaticClassConstFetchRule\ForbiddenStaticClassConstFetchRuleTest
*/
-final class ForbiddenStaticClassConstFetchRule implements Rule, DocumentedRuleInterface
+final class ForbiddenStaticClassConstFetchRule implements Rule
{
/**
* @var string
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/NoEntityOutsideEntityNamespaceRule.php b/src/Rules/NoEntityOutsideEntityNamespaceRule.php
index 44983726..1c0731c7 100644
--- a/src/Rules/NoEntityOutsideEntityNamespaceRule.php
+++ b/src/Rules/NoEntityOutsideEntityNamespaceRule.php
@@ -16,7 +16,7 @@
/**
* @implements Rule
*/
-final class NoEntityOutsideEntityNamespaceRule implements Rule, DocumentedRuleInterface
+final class NoEntityOutsideEntityNamespaceRule implements Rule
{
/**
* @var string
diff --git a/src/Rules/NoGlobalConstRule.php b/src/Rules/NoGlobalConstRule.php
index 043f56d9..e1ae56fe 100644
--- a/src/Rules/NoGlobalConstRule.php
+++ b/src/Rules/NoGlobalConstRule.php
@@ -16,7 +16,7 @@
* @implements Rule
* @see \Symplify\PHPStanRules\Tests\Rules\NoGlobalConstRule\NoGlobalConstRuleTest
*/
-final class NoGlobalConstRule implements Rule, DocumentedRuleInterface
+final class NoGlobalConstRule implements Rule
{
/**
* @var string
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/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/NoSingleInterfaceImplementerRule.php b/src/Rules/NoSingleInterfaceImplementerRule.php
index 95d9bd88..fe62e577 100644
--- a/src/Rules/NoSingleInterfaceImplementerRule.php
+++ b/src/Rules/NoSingleInterfaceImplementerRule.php
@@ -21,17 +21,22 @@
/**
* @see \Symplify\PHPStanRules\Tests\Rules\NoSingleInterfaceImplementerRule\NoSingleInterfaceImplementerRuleTest
*/
-final class NoSingleInterfaceImplementerRule implements Rule, DocumentedRuleInterface
+final class NoSingleInterfaceImplementerRule implements Rule
{
+ /**
+ * @readonly
+ * @var \PHPStan\Reflection\ReflectionProvider
+ */
+ private $reflectionProvider;
/**
* @api used in test
* @var string
*/
public const ERROR_MESSAGE = 'Interface "%s" has only single implementer. Consider using the class directly as there is no point in using the interface.';
- public function __construct(
- private readonly ReflectionProvider $reflectionProvider
- ) {
+ public function __construct(ReflectionProvider $reflectionProvider)
+ {
+ $this->reflectionProvider = $reflectionProvider;
}
public function getNodeType(): string
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/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/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], $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 @@
-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/ForbiddenStaticClassConstFetchRule/Fixture/SomeClassWithStaticConstFetch.php b/tests/Rules/ForbiddenStaticClassConstFetchRule/Fixture/SomeClassWithStaticConstFetch.php
deleted file mode 100644
index 4caef847..00000000
--- a/tests/Rules/ForbiddenStaticClassConstFetchRule/Fixture/SomeClassWithStaticConstFetch.php
+++ /dev/null
@@ -1,13 +0,0 @@
-analyse([$filePath], $expectedErrorMessagesWithLines);
- }
-
- /**
- * @return \Iterator>|string[]>
- */
- public static function provideData(): Iterator
- {
- yield [
- __DIR__ . '/Fixture/SomeClassWithStaticConstFetch.php',
- [[ForbiddenStaticClassConstFetchRule::ERROR_MESSAGE, 11]],
- ];
- }
-
- /**
- * @return string[]
- */
- public static function getAdditionalConfigFiles(): array
- {
- return [__DIR__ . '/config/configured_rule.neon'];
- }
-
- protected function getRule(): Rule
- {
- return self::getContainer()->getByType(ForbiddenStaticClassConstFetchRule::class);
- }
-}
diff --git a/tests/Rules/ForbiddenStaticClassConstFetchRule/config/configured_rule.neon b/tests/Rules/ForbiddenStaticClassConstFetchRule/config/configured_rule.neon
deleted file mode 100644
index 7edb61a5..00000000
--- a/tests/Rules/ForbiddenStaticClassConstFetchRule/config/configured_rule.neon
+++ /dev/null
@@ -1,5 +0,0 @@
-includes:
- - ../../../config/included_services.neon
-
-rules:
- - Symplify\PHPStanRules\Rules\ForbiddenStaticClassConstFetchRule
diff --git a/tests/Rules/NoDynamicNameRule/Fixture/DynamicClassOnStaticPropertyFetch.php b/tests/Rules/NoDynamicNameRule/Fixture/DynamicClassOnStaticPropertyFetch.php
deleted file mode 100644
index ae1b4f97..00000000
--- a/tests/Rules/NoDynamicNameRule/Fixture/DynamicClassOnStaticPropertyFetch.php
+++ /dev/null
@@ -1,12 +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/SomeGlobalConst.php', [
- [NoGlobalConstRule::ERROR_MESSAGE, 7],
- ]];
- }
-
- /**
- * @return string[]
- */
- public static function getAdditionalConfigFiles(): array
- {
- return [__DIR__ . '/config/configured_rule.neon'];
- }
-
- protected function getRule(): Rule
- {
- return self::getContainer()->getByType(NoGlobalConstRule::class);
- }
-}
diff --git a/tests/Rules/NoGlobalConstRule/config/configured_rule.neon b/tests/Rules/NoGlobalConstRule/config/configured_rule.neon
deleted file mode 100644
index 4b1dd907..00000000
--- a/tests/Rules/NoGlobalConstRule/config/configured_rule.neon
+++ /dev/null
@@ -1,5 +0,0 @@
-includes:
- - ../../../config/included_services.neon
-
-rules:
- - Symplify\PHPStanRules\Rules\NoGlobalConstRule
diff --git a/tests/Rules/NoInlineStringRegexRule/Fixture/InlineMatchRegex.php b/tests/Rules/NoInlineStringRegexRule/Fixture/InlineMatchRegex.php
deleted file mode 100644
index 00eb31e1..00000000
--- a/tests/Rules/NoInlineStringRegexRule/Fixture/InlineMatchRegex.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/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/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php b/tests/Rules/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php
deleted file mode 100644
index a67c3395..00000000
--- a/tests/Rules/NoSingleInterfaceImplementerRule/Fixture/AllowAbstract.php
+++ /dev/null
@@ -1,9 +0,0 @@
-
- */
-final class NoSingleInterfaceImplementerRuleTest extends RuleTestCase
-{
- /**
- * @param string[] $filePaths
- * @param mixed[] $expectedErrorMessagesWithLines
- */
- #[DataProvider('provideData')]
- public function testRule(array $filePaths, array $expectedErrorMessagesWithLines): void
- {
- $this->analyse($filePaths, $expectedErrorMessagesWithLines);
- }
-
- public static function provideData(): Iterator
- {
- yield [[__DIR__ . '/Fixture/SimpleInterface.php'], []];
- yield [[__DIR__ . '/Fixture/AllowAbstract.php', __DIR__ . '/Fixture/SimpleInterface.php'], []];
-
- // already counted in abstract class
- yield [[__DIR__ . '/Fixture/AllowAbstract.php', __DIR__ . '/Fixture/SimpleInterface.php', __DIR__ . '/Fixture/ImplementsSimpleInterface.php'], []];
-
- yield [
- [
- __DIR__ . '/Fixture/SimpleInterface.php',
- __DIR__ . '/Fixture/ImplementsSimpleInterface.php',
- ], [
- [
- sprintf(NoSingleInterfaceImplementerRule::ERROR_MESSAGE, SimpleInterface::class),
- -1,
- ],
- ]];
- }
-
- /**
- * @return string[]
- */
- public static function getAdditionalConfigFiles(): array
- {
- return [__DIR__ . '/config/configured_rule.neon'];
- }
-
- protected function getCollectors(): array
- {
- return [
- self::getContainer()->getByType(ImplementedInterfaceCollector::class),
- self::getContainer()->getByType(InterfaceCollector::class),
- self::getContainer()->getByType(InterfaceOfAbstractClassCollector::class),
- ];
- }
-
- protected function getRule(): Rule
- {
- return self::getContainer()->getByType(NoSingleInterfaceImplementerRule::class);
- }
-}
diff --git a/tests/Rules/NoSingleInterfaceImplementerRule/Source/SomeType.php b/tests/Rules/NoSingleInterfaceImplementerRule/Source/SomeType.php
deleted file mode 100644
index f0033281..00000000
--- a/tests/Rules/NoSingleInterfaceImplementerRule/Source/SomeType.php
+++ /dev/null
@@ -1,7 +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