diff --git a/rules-tests/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector/Fixture/skip_no_allow_dynamic_properties_attribute.php.inc b/rules-tests/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector/Fixture/skip_no_allow_dynamic_properties_attribute.php.inc new file mode 100644 index 0000000000..b00462d750 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector/Fixture/skip_no_allow_dynamic_properties_attribute.php.inc @@ -0,0 +1,16 @@ +someDependency = new SomeDependency(); + } +} diff --git a/rules/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector.php b/rules/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector.php index 8aa13b19c7..e9859c2193 100644 --- a/rules/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector.php +++ b/rules/CodeQuality/Rector/Class_/DynamicDocBlockPropertyToNativePropertyRector.php @@ -5,7 +5,6 @@ namespace Rector\CodeQuality\Rector\Class_; use PhpParser\Node; -use PhpParser\Node\Attribute; use PhpParser\Node\Expr; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; @@ -17,7 +16,7 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\CodeQuality\NodeFactory\TypedPropertyFactory; use Rector\Comments\NodeDocBlock\DocBlockUpdater; -use Rector\Doctrine\NodeAnalyzer\AttributeFinder; +use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Rector\AbstractRector; @@ -33,7 +32,7 @@ final class DynamicDocBlockPropertyToNativePropertyRector extends AbstractRector implements MinPhpVersionInterface { public function __construct( - private readonly AttributeFinder $attributeFinder, + private readonly PhpAttributeAnalyzer $phpAttributeAnalyzer, private readonly PhpDocInfoFactory $phpDocInfoFactory, private readonly PhpDocTagRemover $phpDocTagRemover, private readonly DocBlockUpdater $docBlockUpdater, @@ -89,11 +88,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - $allowDynamicPropertiesAttribute = $this->attributeFinder->findAttributeByClass( - $node, - 'AllowDynamicProperties' - ); - if (! $allowDynamicPropertiesAttribute instanceof Attribute) { + if (! $this->phpAttributeAnalyzer->hasPhpAttribute($node, 'AllowDynamicProperties')) { return null; }