From 4855249ef99e26f4e7b872782f3f7d1eb3a69db2 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 2 May 2022 13:06:42 +0200 Subject: [PATCH] Require PHPStan 1.7.0 --- composer.json | 2 +- phpstan-baseline.neon | 10 ---------- src/Rules/Classes/RequireParentConstructCallRule.php | 6 ++++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index ca9b50ee..4cd7aa63 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.6.3" + "phpstan/phpstan": "^1.7.0" }, "require-dev": { "nikic/php-parser": "^4.13.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c271301d..327481a5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -62,16 +62,6 @@ parameters: count: 1 path: src/Rules/Classes/RequireParentConstructCallRule.php - - - message: "#^Method PHPStan\\\\Rules\\\\Classes\\\\RequireParentConstructCallRule\\:\\:getParentConstructorClass\\(\\) has parameter \\$classReflection with generic class ReflectionClass but does not specify its types\\: T$#" - count: 1 - path: src/Rules/Classes/RequireParentConstructCallRule.php - - - - message: "#^Method PHPStan\\\\Rules\\\\Classes\\\\RequireParentConstructCallRule\\:\\:getParentConstructorClass\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#" - count: 1 - path: src/Rules/Classes/RequireParentConstructCallRule.php - - message: "#^Class PHPStan\\\\Rules\\\\DisallowedConstructs\\\\DisallowedBacktickRule implements generic interface PHPStan\\\\Rules\\\\Rule but does not specify its types\\: TNodeType$#" count: 1 diff --git a/src/Rules/Classes/RequireParentConstructCallRule.php b/src/Rules/Classes/RequireParentConstructCallRule.php index 92e9e41c..c07e04e4 100644 --- a/src/Rules/Classes/RequireParentConstructCallRule.php +++ b/src/Rules/Classes/RequireParentConstructCallRule.php @@ -7,9 +7,10 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; +use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass; +use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum; use PHPStan\Rules\Rule; use PHPStan\ShouldNotHappenException; -use ReflectionClass; use function property_exists; use function sprintf; @@ -114,9 +115,10 @@ private function callsParentConstruct(Node $parserNode): bool } /** + * @param ReflectionClass|ReflectionEnum $classReflection * @return ReflectionClass|false */ - private function getParentConstructorClass(ReflectionClass $classReflection) + private function getParentConstructorClass($classReflection) { while ($classReflection->getParentClass() !== false) { $constructor = $classReflection->getParentClass()->hasMethod('__construct') ? $classReflection->getParentClass()->getMethod('__construct') : null;