diff --git a/composer.json b/composer.json index 1557181..f833fcf 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,16 @@ ], "minimum-stability": "stable", "require": { - "php": "^8.1", + "php": "^8.3", "nette/utils": "^4.0", "nikic/php-parser": "^4.3|^5.0", - "phpstan/phpstan": "^1.0" + "phpstan/phpstan": "^2.0" }, "require-dev": { "brainbits/phpcs-standard": "^7.0", "php-coveralls/php-coveralls": "^2.0", - "phpstan/phpstan-php-parser": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^10.5" + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^11.0" }, "scripts": { "check-all": [ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 85e04ff..74ff1d1 100755 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -21,6 +21,6 @@ - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6404af8..d0c06fb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,6 @@ includes: - phar://phpstan.phar/conf/config.levelmax.neon - phar://phpstan.phar/conf/bleedingEdge.neon - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-php-parser/extension.neon - rules.neon parameters: diff --git a/src/CoversClassExistsRule.php b/src/CoversClassExistsRule.php index 1a7c6cc..5f98851 100644 --- a/src/CoversClassExistsRule.php +++ b/src/CoversClassExistsRule.php @@ -10,7 +10,7 @@ use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Class_; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleError; use PHPStan\Rules\RuleErrorBuilder; @@ -28,7 +28,7 @@ final class CoversClassExistsRule implements Rule /** @var bool[] */ private array $alreadyParsedDocComments = []; - public function __construct(private Broker $broker) + public function __construct(private ReflectionProvider $reflectionProvider) { } @@ -74,7 +74,7 @@ public function processNodeAttribute(Class_ $node, Scope $scope): array assert($arg->value->class instanceof Name); $className = (string) $arg->value->class; - if ($this->broker->hasClass($className)) { + if ($this->reflectionProvider->hasClass($className)) { continue; } @@ -85,7 +85,7 @@ public function processNodeAttribute(Class_ $node, Scope $scope): array if ($arg->value instanceof String_) { $className = (string) $arg->value->value; - if ($this->broker->hasClass($className)) { + if ($this->reflectionProvider->hasClass($className)) { continue; } @@ -135,7 +135,7 @@ public function processNodeAnnotation(Class_ $node, Scope $scope): array } } - if ($this->broker->hasClass($matches['className'])) { + if ($this->reflectionProvider->hasClass($matches['className'])) { continue; } diff --git a/tests/CoversClassExistsRuleTest.php b/tests/CoversClassExistsRuleTest.php index dd7946d..598b872 100644 --- a/tests/CoversClassExistsRuleTest.php +++ b/tests/CoversClassExistsRuleTest.php @@ -7,11 +7,10 @@ use BrainbitsPhpStan\CoversClassExistsRule; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \BrainbitsPhpStan\CoversClassExistsRule - * @extends RuleTestCase - */ +/** @extends RuleTestCase */ +#[CoversClass(CoversClassExistsRule::class)] final class CoversClassExistsRuleTest extends RuleTestCase { public function testAttributeRule(): void @@ -31,7 +30,7 @@ public function testAnnotationRule(): void protected function getRule(): Rule { - $broker = $this->createBroker(); + $broker = self::createReflectionProvider(); return new CoversClassExistsRule($broker); } diff --git a/tests/CoversClassPresentRuleTest.php b/tests/CoversClassPresentRuleTest.php index 69b7c90..ec24d0f 100644 --- a/tests/CoversClassPresentRuleTest.php +++ b/tests/CoversClassPresentRuleTest.php @@ -7,11 +7,10 @@ use BrainbitsPhpStan\CoversClassPresentRule; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \BrainbitsPhpStan\CoversClassPresentRule - * @extends RuleTestCase - */ +/** @extends RuleTestCase */ +#[CoversClass(CoversClassPresentRule::class)] final class CoversClassPresentRuleTest extends RuleTestCase { public function testAnnotationWithoutUnitRule(): void