diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 592b8fdb6..008deb6a6 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -12,6 +12,6 @@ 'Spaze\\PHPStan\\Rules\\Disallowed\\' => array($vendorDir . '/spaze/phpstan-disallowed-calls/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), 'PHPStan\\PhpDocParser\\' => array($vendorDir . '/phpstan/phpdoc-parser/src'), - 'PHPStan\\' => array($vendorDir . '/phpstan/phpstan-deprecation-rules/src', $vendorDir . '/phpstan/phpstan-phpunit/src', $vendorDir . '/phpstan/phpstan-symfony/src', $vendorDir . '/phpstan/phpstan-strict-rules/src'), + 'PHPStan\\' => array($vendorDir . '/phpstan/phpstan-deprecation-rules/src', $vendorDir . '/phpstan/phpstan-phpunit/src', $vendorDir . '/phpstan/phpstan-strict-rules/src', $vendorDir . '/phpstan/phpstan-symfony/src'), 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e19899b0a..6a0e3fd34 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -66,8 +66,8 @@ class ComposerStaticInit7d28987f5749c840ef9609f53969aebc array ( 0 => __DIR__ . '/..' . '/phpstan/phpstan-deprecation-rules/src', 1 => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src', - 2 => __DIR__ . '/..' . '/phpstan/phpstan-symfony/src', - 3 => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src', + 2 => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src', + 3 => __DIR__ . '/..' . '/phpstan/phpstan-symfony/src', ), 'Composer\\Semver\\' => array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index cb8ccf931..1110d446b 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -281,17 +281,17 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.3", - "version_normalized": "1.8.3.0", + "version": "1.8.4", + "version_normalized": "1.8.4.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "5583623b61caafebd62bc78a99533aa9d769d097" + "reference": "eed4c9da531f6ebb4787235b6fb486e2c20f34e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5583623b61caafebd62bc78a99533aa9d769d097", - "reference": "5583623b61caafebd62bc78a99533aa9d769d097", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/eed4c9da531f6ebb4787235b6fb486e2c20f34e5", + "reference": "eed4c9da531f6ebb4787235b6fb486e2c20f34e5", "shasum": "" }, "require": { @@ -300,7 +300,7 @@ "conflict": { "phpstan/phpstan-shim": "*" }, - "time": "2022-09-01T15:27:34+00:00", + "time": "2022-09-03T13:08:04+00:00", "bin": [ "phpstan", "phpstan.phar" @@ -323,7 +323,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.3" + "source": "https://github.com/phpstan/phpstan/tree/1.8.4" }, "funding": [ { @@ -694,17 +694,17 @@ }, { "name": "symplify/phpstan-rules", - "version": "11.1.6", - "version_normalized": "11.1.6.0", + "version": "11.1.9", + "version_normalized": "11.1.9.0", "source": { "type": "git", "url": "https://github.com/symplify/phpstan-rules.git", - "reference": "cdc32e41315225ce96e8aba6814000d965c32592" + "reference": "955b239d4a360af1bec7652e3dce9a3b86ee2acc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/phpstan-rules/zipball/cdc32e41315225ce96e8aba6814000d965c32592", - "reference": "cdc32e41315225ce96e8aba6814000d965c32592", + "url": "https://api.github.com/repos/symplify/phpstan-rules/zipball/955b239d4a360af1bec7652e3dce9a3b86ee2acc", + "reference": "955b239d4a360af1bec7652e3dce9a3b86ee2acc", "shasum": "" }, "require": { @@ -715,7 +715,7 @@ "phpstan/phpstan": "^1.8.1", "webmozart/assert": "^1.10" }, - "time": "2022-08-31T08:14:48+00:00", + "time": "2022-09-02T10:08:04+00:00", "type": "phpstan-extension", "extra": { "branch-alias": { @@ -725,8 +725,7 @@ "includes": [ "config/services/services.neon", "config/packages/cognitive-complexity/cognitive-complexity-services.neon", - "config/packages/symfony/services.neon", - "config/packages/nette/services.neon" + "config/packages/symfony/services.neon" ] } }, @@ -745,7 +744,7 @@ ], "description": "Set of Symplify rules for PHPStan", "support": { - "source": "https://github.com/symplify/phpstan-rules/tree/11.1.6" + "source": "https://github.com/symplify/phpstan-rules/tree/11.1.9" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index dcb6cbc72..7b9e02c4f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '4fdf4d755c55f98a22f026e7ee1239efa6b6f2eb', + 'reference' => '9bc7ad30c0b58bc3b32fc3ea7cc28cf87e3c5daf', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '4fdf4d755c55f98a22f026e7ee1239efa6b6f2eb', + 'reference' => '9bc7ad30c0b58bc3b32fc3ea7cc28cf87e3c5daf', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -56,9 +56,9 @@ 'dev_requirement' => false, ), 'phpstan/phpstan' => array( - 'pretty_version' => '1.8.3', - 'version' => '1.8.3.0', - 'reference' => '5583623b61caafebd62bc78a99533aa9d769d097', + 'pretty_version' => '1.8.4', + 'version' => '1.8.4.0', + 'reference' => 'eed4c9da531f6ebb4787235b6fb486e2c20f34e5', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), @@ -119,9 +119,9 @@ 'dev_requirement' => false, ), 'symplify/phpstan-rules' => array( - 'pretty_version' => '11.1.6', - 'version' => '11.1.6.0', - 'reference' => 'cdc32e41315225ce96e8aba6814000d965c32592', + 'pretty_version' => '11.1.9', + 'version' => '11.1.9.0', + 'reference' => '955b239d4a360af1bec7652e3dce9a3b86ee2acc', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../symplify/phpstan-rules', 'aliases' => array(), diff --git a/vendor/phpstan/phpstan/phpstan.phar b/vendor/phpstan/phpstan/phpstan.phar index dc6fed23b..b0c41c3fe 100755 Binary files a/vendor/phpstan/phpstan/phpstan.phar and b/vendor/phpstan/phpstan/phpstan.phar differ diff --git a/vendor/phpstan/phpstan/phpstan.phar.asc b/vendor/phpstan/phpstan/phpstan.phar.asc index 27c24a4fe..feeb880b7 100644 --- a/vendor/phpstan/phpstan/phpstan.phar.asc +++ b/vendor/phpstan/phpstan/phpstan.phar.asc @@ -1,16 +1,16 @@ -----BEGIN PGP SIGNATURE----- -iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmMQz1kACgkQzxoQjQ56 -5yC1Vg/8D2IVVjPtejDaIb19jO/g8MfwK/utEW1q12k4yKNeLRYh44gLh72s05ib -NhlxVcWjRF3B5i/cDF6m/rIEKX8zwHiN2zi7t6GueU/h5/wU822IMTM8MoVmSN/L -43vtIcOJIoWu5I/IMm2hu55GORNtFcDk6r7KVkq0wqa78QcykSqjWAHTEUOwLEMy -EE/1j2cRxfD25YpR/zlQA7WidG1UD0mARn+50pGqtZMYUKy/avkZGBA2XijM4SQn -Bqf3XORyhxNUePP1k7KdnCg2pQDmc4u3JW/cKY4IGNlLwhwpIE2iRrj1K7uz+d7l -71lM2fBNBNP+f21flGiYW3L+TYbaObi98qOtmAs/7OYM5lMDG1rEBCiVIkYaYjSv -9offoxUAVOgsKQO/Lhn4dDvImeXibkX0c0jWzYnoO9hxMMJABEovmHAWTeSVzkZF -kXQoSLQokn9MdyFtiAgNjLhkpAUyqxMkp6jsdyzsS2D7ALssVt3Ym3VWHMibqMNJ -nzDfjrcr75lc8+vNQEEbeSnH81yPMQ3J+3UJL4rrXDsbID7croqnZ5QaRdRqWBYZ -DmWhEg6hwUjHgzyQSMFgvH49uI0ufWBOKNYZfCkGHEK+DmJbcfd0+m78d3PaUGYa -nysLQYtS1hlQVLBYaZuvRfGtd0HgO9V8c5uvjZKuJ5WQSuAazNA= -=3o8/ +iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmMTUacACgkQzxoQjQ56 +5yBSUBAAgtZtDPGvm8q7QhtoerfbsV4Y+7ZD0VVis9z0/DEVGKzhVBIOpfta8yS9 +AOj8tVVdMsNAsaDYS/h1wMQ+hy+1svmg0sO37/DAVpS/r62DgnKz+aPYIjHYV0H6 +75Z/ytBKifhsv3Z0qFhOu2G/JgX8/FlOnr277L4g5ipgebE00dk+jO0cYe1hDUoE +e8W82PODglcmSNehprd5w2Gw9Ce15gjI9osIFbKh1bVbQQxRAy1GXzXrlx1ApAlE +nZXHlZaqmA+ztnzQ7A0Un87AAxe8o+GaLRELyc+pwEumpQv2hbQfPHxAX5/OE7z+ +DvqB6ZajwIBs1KpnvKl4+OIdofaq5E3cycyhWVZ4oY5lMULDa9VM25a2CyeaWndw +LIYvSoV4AUqex9V9p/BhTjfznpOOEHFeBcIjw6UesIlRdGDiDcMdRc+Ib/K9Rpiy +MQOfM2vEIP9lqVqQniAPI4MV7Bo9G6zXJh1KiX5HWAII8FTKaJjzOl0S9n1ZghBq +p+g98HbnmHQVT8yO0XdFsHh9s0HTrI53av2kOFaIti+gp81RSUNFFs36pEjuqADH +CV1Umoyqgr3bwgB/RTO4UXEcd67tyMUlis/jgQrS5ILdpEU62X6kQcrOptAj5tZA +bUHyPl0Gd5m//smhIMePRLPL8tajTl4MFYhDzH4vrxLigmf39pQ= +=hQUs -----END PGP SIGNATURE----- diff --git a/vendor/symplify/phpstan-rules/composer.json b/vendor/symplify/phpstan-rules/composer.json index d430c0fe1..8ac47da9d 100644 --- a/vendor/symplify/phpstan-rules/composer.json +++ b/vendor/symplify/phpstan-rules/composer.json @@ -27,8 +27,7 @@ "includes": [ "config/services/services.neon", "config/packages/cognitive-complexity/cognitive-complexity-services.neon", - "config/packages/symfony/services.neon", - "config/packages/nette/services.neon" + "config/packages/symfony/services.neon" ] } }, diff --git a/vendor/symplify/phpstan-rules/config/packages/nette/nette-rules.neon b/vendor/symplify/phpstan-rules/config/packages/nette/nette-rules.neon deleted file mode 100644 index 42017ecaf..000000000 --- a/vendor/symplify/phpstan-rules/config/packages/nette/nette-rules.neon +++ /dev/null @@ -1,15 +0,0 @@ -rules: - # dibi - - Symplify\PHPStanRules\Nette\Rules\DibiMaskMatchesVariableTypeRule - - # templates - - Symplify\PHPStanRules\Nette\Rules\NoNetteDoubleTemplateAssignRule - - # components - - Symplify\PHPStanRules\Nette\Rules\NoNetteArrayAccessInControlRule - - # inject - - Symplify\PHPStanRules\Nette\Rules\ForbiddenNetteInjectOverrideRule - - Symplify\PHPStanRules\Nette\Rules\NoInjectOnFinalRule - - Symplify\PHPStanRules\Nette\Rules\NoNetteInjectAndConstructorRule - - Symplify\PHPStanRules\Nette\Rules\ValidNetteInjectRule diff --git a/vendor/symplify/phpstan-rules/config/packages/nette/services.neon b/vendor/symplify/phpstan-rules/config/packages/nette/services.neon deleted file mode 100644 index c68f26749..000000000 --- a/vendor/symplify/phpstan-rules/config/packages/nette/services.neon +++ /dev/null @@ -1,6 +0,0 @@ -services: - # php-parser - - Symplify\PHPStanRules\Nette\Dibi\QueryMasksResolver - - - Symplify\PHPStanRules\Nette\NetteInjectAnalyzer - - Symplify\PHPStanRules\Nette\NodeAnalyzer\DibiQueryAnalyzer diff --git a/vendor/symplify/phpstan-rules/config/services/services.neon b/vendor/symplify/phpstan-rules/config/services/services.neon index f6c1b3f84..95ce64702 100644 --- a/vendor/symplify/phpstan-rules/config/services/services.neon +++ b/vendor/symplify/phpstan-rules/config/services/services.neon @@ -53,7 +53,6 @@ services: - Symplify\PHPStanRules\ParentGuard\ParentElementResolver\ParentMethodResolver - Symplify\PHPStanRules\ParentGuard\ParentElementResolver\ParentMethodReturnTypeResolver - Symplify\PHPStanRules\ParentGuard\ParentPropertyGuard - - Symplify\PHPStanRules\PhpDoc\AnnotationAttributeDetector - Symplify\PHPStanRules\PhpDoc\ApiDocStmtAnalyzer - Symplify\PHPStanRules\PhpDoc\BarePhpDocParser - Symplify\PHPStanRules\PhpDoc\ClassAnnotationResolver diff --git a/vendor/symplify/phpstan-rules/packages/CognitiveComplexity/Rules/ClassLikeCognitiveComplexityRule.php b/vendor/symplify/phpstan-rules/packages/CognitiveComplexity/Rules/ClassLikeCognitiveComplexityRule.php index 09a181688..2f1eb03df 100644 --- a/vendor/symplify/phpstan-rules/packages/CognitiveComplexity/Rules/ClassLikeCognitiveComplexityRule.php +++ b/vendor/symplify/phpstan-rules/packages/CognitiveComplexity/Rules/ClassLikeCognitiveComplexityRule.php @@ -69,12 +69,7 @@ public function processNode(Node $node, Scope $scope): array return []; } - if ($this->scoreCompositionOverInheritance) { - $measuredCognitiveComplexity = $this->compositionOverInheritanceAnalyzer->analyzeClassLike($classLike); - } else { - $measuredCognitiveComplexity = $this->astCognitiveComplexityAnalyzer->analyzeClassLike($classLike); - } - + $measuredCognitiveComplexity = $this->resolveMeasuredCognitiveComplexity($classLike); if ($measuredCognitiveComplexity <= $this->maxClassCognitiveComplexity) { return []; } @@ -136,4 +131,13 @@ public function another($value) )] ); } + + private function resolveMeasuredCognitiveComplexity(Class_ $class): int + { + if ($this->scoreCompositionOverInheritance) { + return $this->compositionOverInheritanceAnalyzer->analyzeClassLike($class); + } + + return $this->astCognitiveComplexityAnalyzer->analyzeClassLike($class); + } } diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Dibi/QueryMasksResolver.php b/vendor/symplify/phpstan-rules/packages/Nette/Dibi/QueryMasksResolver.php deleted file mode 100644 index 73e2be6a1..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Dibi/QueryMasksResolver.php +++ /dev/null @@ -1,87 +0,0 @@ -%\w+)\b#'; - - /** - * @return string[] - */ - public function resolveQueryMasks(MethodCall $methodCall, Scope $scope): array - { - $firstArg = $methodCall->args[0]; - if (! $firstArg instanceof Arg) { - return []; - } - - $queryStringType = $scope->getType($firstArg->value); - if (! $queryStringType instanceof ConstantStringType) { - return []; - } - - $queryStringValue = $queryStringType->getValue(); - return $this->resolveMasksFromString($queryStringValue); - } - - public function resolveSingleQueryMask(?\PhpParser\Node\Expr $expr, Scope $scope): ?string - { - if ($expr === null) { - return null; - } - - $exprType = $scope->getType($expr); - if (! $exprType instanceof ConstantStringType) { - return null; - } - - $dimValue = $exprType->getValue(); - if (! is_string($dimValue)) { - return null; - } - - $masks = $this->resolveMasksFromString($dimValue); - if (count($masks) !== 1) { - return null; - } - - return $masks[0]; - } - - /** - * @return string[] - */ - private function resolveMasksFromString(string $queryString): array - { - // compare only if string contains masks - if (strpos($queryString, '%') === false) { - return []; - } - - $maskMatches = Strings::matchAll($queryString, self::MASK_REGEX); - - $masks = []; - foreach ($maskMatches as $maskMatch) { - $masks[] = $maskMatch['mask']; - } - - return $masks; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/NetteInjectAnalyzer.php b/vendor/symplify/phpstan-rules/packages/Nette/NetteInjectAnalyzer.php deleted file mode 100644 index 6afdebd71..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/NetteInjectAnalyzer.php +++ /dev/null @@ -1,179 +0,0 @@ -annotationAttributeDetector = $annotationAttributeDetector; - $this->reflectionParser = $reflectionParser; - $this->nodeFinder = $nodeFinder; - $this->nodeComparator = $nodeComparator; - } - - /** - * @param ClassReflection[] $parentClassReflections - */ - public function isParentInjectPropertyFetch(PropertyFetch $propertyFetch, array $parentClassReflections): bool - { - $propertyFetchName = $propertyFetch->name; - if (! $propertyFetchName instanceof Identifier) { - return false; - } - - $propertyName = $propertyFetchName->name; - - foreach ($parentClassReflections as $parentClassReflection) { - if (! $parentClassReflection->hasNativeProperty($propertyName)) { - continue; - } - - $propertyReflection = $parentClassReflection->getNativeProperty($propertyName); - // we can skip annotated like property-read - if (! $propertyReflection instanceof PhpPropertyReflection) { - continue; - } - - if ($this->hasPropertyReflectionInjectAnnotationAttribute( - $propertyReflection, - $propertyFetch, - $parentClassReflection - )) { - return true; - } - } - - return false; - } - - public function isInjectProperty(Property $property): bool - { - // not possible to inject private property - if ($property->isPrivate()) { - return false; - } - - return $this->annotationAttributeDetector->hasNodeAnnotationOrAttribute( - $property, - self::INJECT, - self::INJECT_ATTRIBUTE_CLASS - ); - } - - public function isInjectClassMethod(ClassMethod $classMethod): bool - { - if (! $classMethod->isPublic()) { - return false; - } - - $methodName = $classMethod->name->toString(); - return strncmp($methodName, 'inject', strlen('inject')) === 0; - } - - private function hasPropertyReflectionInjectAnnotationAttribute( - PhpPropertyReflection $phpPropertyReflection, - PropertyFetch $propertyFetch, - ClassReflection $classReflection - ): bool { - $property = $this->reflectionParser->parsePropertyReflection($phpPropertyReflection->getNativeReflection()); - if (! $property instanceof Property) { - return false; - } - - if ($this->isInjectProperty($property)) { - return true; - } - - return $this->isPropertyInjectedInClassMethod($classReflection, $propertyFetch); - } - - private function isPropertyInjectedInClassMethod( - ClassReflection $classReflection, - PropertyFetch $propertyFetch - ): bool { - $nativeReflection = $classReflection->getNativeReflection(); - - $reflectionMethods = $nativeReflection->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($reflectionMethods as $reflectionMethod) { - if (strncmp($reflectionMethod->getName(), 'inject', strlen('inject')) !== 0) { - continue; - } - - $classMethod = $this->reflectionParser->parseMethodReflection($reflectionMethod); - if (! $classMethod instanceof ClassMethod) { - continue; - } - - if ($this->isClassMethodInjectingCurrentProperty($classMethod, $propertyFetch)) { - return true; - } - } - - return false; - } - - private function isClassMethodInjectingCurrentProperty(ClassMethod $classMethod, PropertyFetch $propertyFetch): bool - { - if (! $this->isInjectClassMethod($classMethod)) { - return false; - } - - /** @var Assign[] $assigns */ - $assigns = $this->nodeFinder->findInstanceOf((array) $classMethod->stmts, Assign::class); - foreach ($assigns as $assign) { - if (! $assign->var instanceof PropertyFetch) { - continue; - } - - /** @var PropertyFetch $injectedPropertyFetch */ - $injectedPropertyFetch = $assign->var; - - if ($this->nodeComparator->areNodesEqual($injectedPropertyFetch, $propertyFetch)) { - return true; - } - } - - return false; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/NodeAnalyzer/DibiQueryAnalyzer.php b/vendor/symplify/phpstan-rules/packages/Nette/NodeAnalyzer/DibiQueryAnalyzer.php deleted file mode 100644 index a3ad7c038..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/NodeAnalyzer/DibiQueryAnalyzer.php +++ /dev/null @@ -1,30 +0,0 @@ -getType($methodCall->var); - - $dibiConnectionObjectType = new ObjectType('Dibi\Connection'); - if (! $callerType->isSuperTypeOf($dibiConnectionObjectType)->yes()) { - return false; - } - - if (! $methodCall->name instanceof Identifier) { - return false; - } - - // check direct caller with string masks - return $methodCall->name->toString() === 'query'; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/DibiMaskMatchesVariableTypeRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/DibiMaskMatchesVariableTypeRule.php deleted file mode 100644 index 50e9da2ce..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/DibiMaskMatchesVariableTypeRule.php +++ /dev/null @@ -1,231 +0,0 @@ - - */ - private $masksToExpectedTypes = []; - /** - * @var \Symplify\PHPStanRules\Nette\NodeAnalyzer\DibiQueryAnalyzer - */ - private $dibiQueryAnalyzer; - /** - * @var \Symplify\PHPStanRules\Nette\Dibi\QueryMasksResolver - */ - private $queryMasksResolver; - /** - * @var \Symplify\PHPStanRules\TypeResolver\ArgTypeResolver - */ - private $argTypeResolver; - public function __construct(DibiQueryAnalyzer $dibiQueryAnalyzer, QueryMasksResolver $queryMasksResolver, ArgTypeResolver $argTypeResolver) - { - $this->dibiQueryAnalyzer = $dibiQueryAnalyzer; - $this->queryMasksResolver = $queryMasksResolver; - $this->argTypeResolver = $argTypeResolver; - $arrayType = new ArrayType(new MixedType(), new MixedType()); - $this->masksToExpectedTypes = [ - '%v' => $arrayType, - '%and' => $arrayType, - '%or' => $arrayType, - '%a' => $arrayType, - '%l' => $arrayType, - '%in' => $arrayType, - '%m' => $arrayType, - '%by' => $arrayType, - '%n' => $arrayType, - // non-array types - '%s' => new StringType(), - '%sN' => new StringType(), - '%b' => new BooleanType(), - '%i' => new IntegerType(), - '%iN' => new IntegerType(), - '%f' => new FloatType(), - ]; - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Assign::class, MethodCall::class, ArrayItem::class]; - } - - /** - * @param Assign|MethodCall|ArrayItem $node - * @return string[] - */ - public function process(Node $node, Scope $scope): array - { - $classReflection = $scope->getClassReflection(); - if (! $classReflection instanceof ClassReflection) { - return []; - } - - // skip itself - if (in_array($classReflection->getName(), [self::class, SprintfSpecifierTypeResolver::class], true)) { - return []; - } - - if ($node instanceof MethodCall) { - return $this->processMethodCall($node, $scope); - } - - if ($node instanceof ArrayItem) { - return $this->processArrayItem($node, $scope); - } - - return $this->processAssign($node, $scope); - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -$database->query('INSERT INTO table %v', 'string'); -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -$database->query('INSERT INTO table %v', ['name' => 'Matthias']); -CODE_SAMPLE - ), - ]); - } - - /** - * @return string[] - */ - private function processMethodCall(MethodCall $methodCall, Scope $scope): array - { - if (! $this->dibiQueryAnalyzer->isDibiConnectionQueryCall($scope, $methodCall)) { - return []; - } - - $queryMasks = $this->queryMasksResolver->resolveQueryMasks($methodCall, $scope); - $argumentTypes = $this->argTypeResolver->resolveArgTypesWithoutFirst($methodCall, $scope); - - if (count($queryMasks) !== count($argumentTypes)) { - return []; - } - - $errorMessages = []; - - foreach ($argumentTypes as $key => $argumentType) { - $queryMask = $queryMasks[$key]; - - $errorMessage = $this->matchErrorMessageIfHappens($queryMask, $argumentType); - if ($errorMessage === null) { - continue; - } - - $errorMessages[] = $errorMessage; - } - - return $errorMessages; - } - - /** - * @return string[] - */ - private function processArrayItem(ArrayItem $arrayItem, Scope $scope): array - { - $mask = $this->queryMasksResolver->resolveSingleQueryMask($arrayItem->key, $scope); - if ($mask === null) { - return []; - } - - $valueType = $scope->getType($arrayItem->value); - - $errorMessage = $this->matchErrorMessageIfHappens($mask, $valueType); - if ($errorMessage === null) { - return []; - } - - return [$errorMessage]; - } - - private function matchErrorMessageIfHappens(string $queryMask, Type $argumentType): ?string - { - $expectedType = $this->masksToExpectedTypes[$queryMask] ?? null; - - // nothing to verify - if (! $expectedType instanceof Type) { - return null; - } - - if ($expectedType->isSuperTypeOf($argumentType)->yes()) { - return null; - } - - return sprintf( - self::ERROR_MESSAGE, - $queryMask, - $argumentType->describe(VerbosityLevel::typeOnly()), - $expectedType->describe(VerbosityLevel::typeOnly()) - ); - } - - /** - * @return string[] - */ - private function processAssign(Assign $assign, Scope $scope): array - { - if (! $assign->var instanceof ArrayDimFetch) { - return []; - } - - $arrayDimFetch = $assign->var; - - $queryMask = $this->queryMasksResolver->resolveSingleQueryMask($arrayDimFetch->dim, $scope); - if ($queryMask === null) { - return []; - } - - $exprType = $scope->getType($assign->expr); - - $errorMessage = $this->matchErrorMessageIfHappens($queryMask, $exprType); - if ($errorMessage === null) { - return []; - } - - return [$errorMessage]; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/ForbiddenNetteInjectOverrideRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/ForbiddenNetteInjectOverrideRule.php deleted file mode 100644 index 2c53f0108..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/ForbiddenNetteInjectOverrideRule.php +++ /dev/null @@ -1,145 +0,0 @@ - - */ -final class ForbiddenNetteInjectOverrideRule implements Rule -{ - /** - * @var string - */ - public const ERROR_MESSAGE = 'Assign to already injected property is not allowed'; - /** - * @var \Symplify\PHPStanRules\Nette\NetteInjectAnalyzer - */ - private $netteInjectAnalyzer; - /** - * @var \PhpParser\NodeFinder - */ - private $nodeFinder; - public function __construct(NetteInjectAnalyzer $netteInjectAnalyzer, NodeFinder $nodeFinder) - { - $this->netteInjectAnalyzer = $netteInjectAnalyzer; - $this->nodeFinder = $nodeFinder; - } - - /** - * @return class-string - */ - public function getNodeType(): string - { - return InClassNode::class; - } - - /** - * @param InClassNode $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - $classReflection = $node->getClassReflection(); - - $classLike = $node->getOriginalNode(); - if (! $classLike instanceof Class_) { - return []; - } - - $parentClassReflections = $classReflection->getParents(); - if ($parentClassReflections === []) { - return []; - } - - /** @var Assign[] $assigns */ - $assigns = $this->nodeFinder->findInstanceOf($classLike->getMethods(), Assign::class); - if ($assigns === []) { - return []; - } - - $errorMessages = []; - - foreach ($assigns as $assign) { - if (! $assign->var instanceof PropertyFetch) { - continue; - } - - $propertyFetch = $assign->var; - if (! $this->netteInjectAnalyzer->isParentInjectPropertyFetch( - $propertyFetch, - $parentClassReflections - )) { - continue; - } - - $errorMessages[] = RuleErrorBuilder::message(self::ERROR_MESSAGE) - ->line($propertyFetch->getLine()) - ->build(); - } - - return $errorMessages; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -abstract class AbstractParent -{ - /** - * @var SomeType - */ - #[Inject] - public $someType; -} - -final class SomeChild extends AbstractParent -{ - public function __construct(AnotherType $anotherType) - { - $this->someType = $anotherType; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -abstract class AbstractParent -{ - /** - * @var SomeType - */ - #[Inject] - public $someType; -} - -final class SomeChild extends AbstractParent -{ -} -CODE_SAMPLE - ), - ]); - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoInjectOnFinalRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoInjectOnFinalRule.php deleted file mode 100644 index 9e7821f17..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoInjectOnFinalRule.php +++ /dev/null @@ -1,105 +0,0 @@ - - */ -final class NoInjectOnFinalRule implements Rule -{ - /** - * @var string - */ - public const ERROR_MESSAGE = 'Use constructor on final classes, instead of property injection'; - /** - * @var \Symplify\PHPStanRules\Nette\NetteInjectAnalyzer - */ - private $netteInjectAnalyzer; - - public function __construct(NetteInjectAnalyzer $netteInjectAnalyzer) - { - $this->netteInjectAnalyzer = $netteInjectAnalyzer; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - self::ERROR_MESSAGE, - [ - new CodeSample( - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -final class SomePresenter -{ - #[Inject] - public $property; -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -abstract class SomePresenter -{ - #[Inject] - public $property; -} -CODE_SAMPLE - ), ] - ); - } - - /** - * @return class-string - */ - public function getNodeType(): string - { - return InClassNode::class; - } - - /** - * @param InClassNode $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - $classLike = $node->getOriginalNode(); - if (! $classLike instanceof Class_) { - return []; - } - - if (! $classLike->isFinal()) { - return []; - } - - $errorMessage = []; - - foreach ($classLike->getProperties() as $property) { - if (! $this->netteInjectAnalyzer->isInjectProperty($property)) { - continue; - } - - $errorMessage[] = RuleErrorBuilder::message(self::ERROR_MESSAGE) - ->line($property->getLine()) - ->build(); - } - - return $errorMessage; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteArrayAccessInControlRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteArrayAccessInControlRule.php deleted file mode 100644 index b3e6381ab..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteArrayAccessInControlRule.php +++ /dev/null @@ -1,97 +0,0 @@ -getComponent()" instead'; - - /** - * @return class-string - */ - public function getNodeType(): string - { - return ArrayDimFetch::class; - } - - /** - * @param ArrayDimFetch $node - * @return string[] - */ - public function processNode(Node $node, Scope $scope): array - { - $classReflection = $scope->getClassReflection(); - if (! $classReflection instanceof ClassReflection) { - return []; - } - - // this type has getComponent() method - if (! $classReflection->isSubclassOf('Nette\ComponentModel\Container')) { - return []; - } - - if (! $node->var instanceof Variable) { - return []; - } - - $callerVariable = $node->var; - if (! is_string($callerVariable->name)) { - return []; - } - - if ($callerVariable->name !== 'this') { - return []; - } - - return [self::ERROR_MESSAGE]; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -use Nette\Application\UI\Presenter; - -class SomeClass extends Presenter -{ - public function render() - { - return $this['someControl']; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Nette\Application\UI\Presenter; - -class SomeClass extends Presenter -{ - public function render() - { - return $this->getComponent('someControl'); - } -} -CODE_SAMPLE - ), - ]); - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteDoubleTemplateAssignRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteDoubleTemplateAssignRule.php deleted file mode 100644 index 0e66caa0d..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteDoubleTemplateAssignRule.php +++ /dev/null @@ -1,196 +0,0 @@ - - */ - public function getNodeType(): string - { - return ClassMethod::class; - } - - /** - * @param ClassMethod $node - * @return string[] - */ - public function processNode(Node $node, Scope $scope): array - { - $classReflection = $scope->getClassReflection(); - if (! $classReflection instanceof ClassReflection) { - return []; - } - - if (! $classReflection->isSubclassOf('Nette\Application\UI\Presenter')) { - return []; - } - - // work only with single root assigns, as nesting can be hard to handle - $assigns = $this->findFirstLevelAssigns($node); - - $duplicatedVariableNames = $this->resolveDuplicatedTemplateVariableNames($assigns); - if ($duplicatedVariableNames === []) { - return []; - } - - $variableNamesString = implode('", "', $duplicatedVariableNames); - $errorMessage = sprintf(self::ERROR_MESSAGE, $variableNamesString); - return [$errorMessage]; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -use Nette\Application\UI\Presenter; - -class SomeClass extends Presenter -{ - public function render() - { - $this->template->key = '1'; - $this->template->key = '2'; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Nette\Application\UI\Presenter; - -class SomeClass extends Presenter -{ - public function render() - { - $this->template->key = '2'; - } -} -CODE_SAMPLE - ), - ]); - } - - private function isThisTemplatePropertyFetch(PropertyFetch $propertyFetch): bool - { - if (! $propertyFetch->var instanceof PropertyFetch) { - return false; - } - - $nestedPropertyFetch = $propertyFetch->var; - if (! $this->isVariableName($nestedPropertyFetch->var, 'this')) { - return false; - } - - if (! $nestedPropertyFetch->name instanceof Identifier) { - return false; - } - - return $nestedPropertyFetch->name->toString() === 'template'; - } - - /** - * @param Assign[] $assigns - * @return string[] - */ - private function resolveDuplicatedTemplateVariableNames(array $assigns): array - { - $assignedTemplateVariableNames = []; - $duplicatedTemplateNames = []; - - foreach ($assigns as $assign) { - $templatePropertyFetch = $this->matchTemplatePropertyFetch($assign); - if (! $templatePropertyFetch instanceof PropertyFetch) { - continue; - } - - if (! $templatePropertyFetch->name instanceof Identifier) { - continue; - } - - $variableName = $templatePropertyFetch->name->toString(); - if (in_array($variableName, $assignedTemplateVariableNames, true)) { - $duplicatedTemplateNames[] = $variableName; - } - - $assignedTemplateVariableNames[] = $variableName; - } - - return array_unique($duplicatedTemplateNames); - } - - private function matchTemplatePropertyFetch(Assign $assign): ?PropertyFetch - { - $assignedVar = $assign->var; - if (! $assignedVar instanceof PropertyFetch) { - return null; - } - - if (! $this->isThisTemplatePropertyFetch($assignedVar)) { - return null; - } - - return $assignedVar; - } - - /** - * @return Assign[] - */ - private function findFirstLevelAssigns(ClassMethod $classMethod): array - { - $assigns = []; - - foreach ((array) $classMethod->stmts as $stmt) { - if (! $stmt instanceof Expression) { - continue; - } - - if (! $stmt->expr instanceof Assign) { - continue; - } - - $assigns[] = $stmt->expr; - } - - return $assigns; - } - - private function isVariableName(Expr $expr, string $variableName): bool - { - if (! $expr instanceof Variable) { - return false; - } - - if (! is_string($expr->name)) { - return false; - } - - return $expr->name === $variableName; - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteInjectAndConstructorRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteInjectAndConstructorRule.php deleted file mode 100644 index fdc334554..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/NoNetteInjectAndConstructorRule.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -final class NoNetteInjectAndConstructorRule implements Rule -{ - /** - * @var string - */ - public const ERROR_MESSAGE = 'Use either __construct() or @inject, not both together'; - /** - * @var \Symplify\PHPStanRules\Nette\NetteInjectAnalyzer - */ - private $netteInjectAnalyzer; - - public function __construct(NetteInjectAnalyzer $netteInjectAnalyzer) - { - $this->netteInjectAnalyzer = $netteInjectAnalyzer; - } - - /** - * @return class-string - */ - public function getNodeType(): string - { - return Class_::class; - } - - /** - * @param Class_ $node - * @return string[] - */ - public function processNode(Node $node, Scope $scope): array - { - if ($node->isAbstract()) { - return []; - } - - $constructMethod = $node->getMethod(MethodName::CONSTRUCTOR); - if (! $constructMethod instanceof ClassMethod) { - return []; - } - - foreach ($node->getMethods() as $classMethod) { - if ($this->netteInjectAnalyzer->isInjectClassMethod($classMethod)) { - return [self::ERROR_MESSAGE]; - } - } - - foreach ($node->getProperties() as $property) { - if ($this->netteInjectAnalyzer->isInjectProperty($property)) { - return [self::ERROR_MESSAGE]; - } - } - - return []; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -class SomeClass -{ - private $someType; - - public function __construct() - { - // ... - } - - public function injectSomeType($someType) - { - $this->someType = $someType; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -class SomeClass -{ - private $someType; - - public function __construct($someType) - { - $this->someType = $someType; - } -} -CODE_SAMPLE - ), - ]); - } -} diff --git a/vendor/symplify/phpstan-rules/packages/Nette/Rules/ValidNetteInjectRule.php b/vendor/symplify/phpstan-rules/packages/Nette/Rules/ValidNetteInjectRule.php deleted file mode 100644 index 8c0236e96..000000000 --- a/vendor/symplify/phpstan-rules/packages/Nette/Rules/ValidNetteInjectRule.php +++ /dev/null @@ -1,95 +0,0 @@ -autowiredMethodPropertyAnalyzer = $autowiredMethodPropertyAnalyzer; - } - - public function getNodeType(): string - { - return Class_::class; - } - - /** - * @param Class_ $node - * @return RuleError[] - */ - public function processNode(Node $node, Scope $scope): array - { - $ruleErrors = []; - - $propertiesAndClassMethods = array_merge($node->getProperties(), $node->getMethods()); - - foreach ($propertiesAndClassMethods as $propertyAndClassMethod) { - if (! $this->autowiredMethodPropertyAnalyzer->detect($propertyAndClassMethod)) { - continue; - } - - if ($propertyAndClassMethod->isPublic()) { - continue; - } - - $ruleErrors[] = RuleErrorBuilder::message(self::ERROR_MESSAGE) - ->line($propertyAndClassMethod->getLine()) - ->build(); - } - - return $ruleErrors; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition(self::ERROR_MESSAGE, [ - new CodeSample( - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -class SomeClass -{ - #[Inject] - private $someDependency; -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Nette\DI\Attributes\Inject; - -class SomeClass -{ - #[Inject] - public $someDependency; -} -CODE_SAMPLE - ), - ]); - } -} diff --git a/vendor/symplify/phpstan-rules/src/NodeAnalyzer/AutowiredMethodPropertyAnalyzer.php b/vendor/symplify/phpstan-rules/src/NodeAnalyzer/AutowiredMethodPropertyAnalyzer.php index db5b6ca8e..537caf715 100644 --- a/vendor/symplify/phpstan-rules/src/NodeAnalyzer/AutowiredMethodPropertyAnalyzer.php +++ b/vendor/symplify/phpstan-rules/src/NodeAnalyzer/AutowiredMethodPropertyAnalyzer.php @@ -15,29 +15,22 @@ final class AutowiredMethodPropertyAnalyzer * @var string * @see https://regex101.com/r/gn2P0C/1 */ - private const REQUIRED_DOCBLOCK_REGEX = '#\*\s+@(required|inject)\n?#'; + private const REQUIRED_DOCBLOCK_REGEX = '#\*\s+@(required)\n?#'; - /** - * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $stmt - */ - public function detect($stmt): bool + public function detect(ClassMethod $classMethod): bool { - $docComment = $stmt->getDocComment(); + $hasRequiredAttribute = $this->hasAttributes($classMethod, ['Symfony\Contracts\Service\Attribute\Required']); + + $docComment = $classMethod->getDocComment(); if (! $docComment instanceof Doc) { - return $this->hasAttributes( - $stmt, - ['Symfony\Contracts\Service\Attribute\Required', 'Nette\DI\Attributes\Inject'] - ); + return $hasRequiredAttribute; } if ((bool) Strings::match($docComment->getText(), self::REQUIRED_DOCBLOCK_REGEX)) { return true; } - return $this->hasAttributes( - $stmt, - ['Symfony\Contracts\Service\Attribute\Required', 'Nette\DI\Attributes\Inject'] - ); + return $hasRequiredAttribute; } /** diff --git a/vendor/symplify/phpstan-rules/src/PhpDoc/AnnotationAttributeDetector.php b/vendor/symplify/phpstan-rules/src/PhpDoc/AnnotationAttributeDetector.php deleted file mode 100644 index 1767fcaa3..000000000 --- a/vendor/symplify/phpstan-rules/src/PhpDoc/AnnotationAttributeDetector.php +++ /dev/null @@ -1,63 +0,0 @@ -barePhpDocParser = $barePhpDocParser; - } - public function hasNodeAnnotationOrAttribute( - Property $property, - string $annotationName, - string $attributeClass - ): bool { - $phpDocTagNodes = $this->barePhpDocParser->parseNodeToPhpDocTagNodes($property); - if ($this->hasPhpDocTagNodeName($phpDocTagNodes, $annotationName)) { - return true; - } - - return $this->hasAttributeClass($property, $attributeClass); - } - - /** - * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $node - */ - private function hasAttributeClass($node, string $attributeClass): bool - { - foreach ($node->attrGroups as $attrGroup) { - foreach ($attrGroup->attrs as $attribute) { - if ($attribute->name->toString() === $attributeClass) { - return true; - } - } - } - - return false; - } - - /** - * @param PhpDocTagNode[] $phpDocTagNodes - */ - private function hasPhpDocTagNodeName(array $phpDocTagNodes, string $tagName): bool - { - foreach ($phpDocTagNodes as $phpDocTagNode) { - if ($phpDocTagNode->name === $tagName) { - return true; - } - } - - return false; - } -} diff --git a/vendor/symplify/phpstan-rules/src/TypeResolver/ArgTypeResolver.php b/vendor/symplify/phpstan-rules/src/TypeResolver/ArgTypeResolver.php index c9fb83a66..63caebb88 100644 --- a/vendor/symplify/phpstan-rules/src/TypeResolver/ArgTypeResolver.php +++ b/vendor/symplify/phpstan-rules/src/TypeResolver/ArgTypeResolver.php @@ -5,7 +5,6 @@ namespace Symplify\PHPStanRules\TypeResolver; use PhpParser\Node\Expr\FuncCall; -use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Type\Type; @@ -13,9 +12,8 @@ final class ArgTypeResolver { /** * @return Type[] - * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall $funcCall */ - public function resolveArgTypesWithoutFirst($funcCall, Scope $scope): array + public function resolveArgTypesWithoutFirst(FuncCall $funcCall, Scope $scope): array { $args = $funcCall->getArgs(); unset($args[0]);