From 24ea3ecd82cfab1d040bed6c0cd7a0cf69a11a85 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 1 Oct 2023 13:40:39 +0200 Subject: [PATCH] make use of findDoctrineAnnotationsByClass() --- .../MergeMethodAnnotationToRouteAnnotationRector.php | 7 +------ .../ReplaceSensioRouteAnnotationWithSymfonyRector.php | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/rules/Symfony34/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php b/rules/Symfony34/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php index 679e12dc..3cf22fc9 100644 --- a/rules/Symfony34/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php +++ b/rules/Symfony34/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php @@ -11,7 +11,6 @@ use Rector\BetterPhpDocParser\PhpDoc\StringNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; -use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Rector\AbstractRector; @@ -32,7 +31,6 @@ public function __construct( private readonly PhpDocTagRemover $phpDocTagRemover, private readonly DocBlockUpdater $docBlockUpdater, private readonly PhpDocInfoFactory $phpDocInfoFactory, - private readonly PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder, ) { } @@ -104,10 +102,7 @@ public function refactor(Node $node): ?Node } // get all routes - $symfonyDoctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass( - $phpDocInfo->getPhpDocNode(), - SymfonyAnnotation::ROUTE - ); + $symfonyDoctrineAnnotationTagValueNodes = $phpDocInfo->findByAnnotationClass(SymfonyAnnotation::ROUTE); // no symfony route? skip it if ($symfonyDoctrineAnnotationTagValueNodes === []) { diff --git a/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php b/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php index 3f486f7f..f1bfbc3a 100644 --- a/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php +++ b/rules/Symfony34/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php @@ -12,7 +12,6 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; -use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Rector\AbstractRector; @@ -39,7 +38,6 @@ public function __construct( private readonly PhpDocTagRemover $phpDocTagRemover, private readonly RenamedClassesDataCollector $renamedClassesDataCollector, private readonly DocBlockUpdater $docBlockUpdater, - private readonly PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder, private readonly PhpDocInfoFactory $phpDocInfoFactory, ) { } @@ -105,10 +103,7 @@ public function refactor(Node $node): ?Node return null; } - $sensioDoctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass( - $phpDocInfo->getPhpDocNode(), - self::SENSIO_ROUTE_NAME - ); + $sensioDoctrineAnnotationTagValueNodes = $phpDocInfo->findByAnnotationClass(self::SENSIO_ROUTE_NAME); // nothing to find if ($sensioDoctrineAnnotationTagValueNodes === []) {