We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<?php use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Routing\Annotation\Since; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Annotation\Route; class Test { /** * @Since("6.4.0.1") * @Route("/api/_admin/reset-excluded-search-term", name="api.admin.reset-excluded-search-term", methods={"POST"}) * * @return JsonResponse */ public function resetExcludedSearchTerm(Context $context) { } }
<?php namespace Shopware\Core\DevOps\Rector; use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; use Rector\Core\Rector\AbstractRector; use Rector\Php80\NodeFactory\AttrGroupsFactory; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; class TestRector extends AbstractRector { public function __construct( private AttrGroupsFactory $attrGroupsFactory, private PhpDocTagRemover $phpDocTagRemover, ) { } public function getRuleDefinition(): RuleDefinition { return new RuleDefinition('uff', []); } public function getNodeTypes(): array { return [ ClassMethod::class, ]; } public function refactor(Node $node) { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $route = $phpDocInfo->getByName('Route'); $defaults = $route->value->getValue('defaults'); if ($defaults === null) { $defaults = new CurlyListNode(); } $route->value->changeValue('defaults', $defaults); } }
The route just gets an additional "defaults" and not be duplicated
1) class.php:7 ---------- begin diff ---------- @@ @@ class Test { /** * @Since("6.4.0.1") + * @Route("/api/_admin/reset-excluded-search-term", name="api.admin.reset-excluded-search-term", methods={"POST"}, defaults={}) * @Route("/api/_admin/reset-excluded-search-term", name="api.admin.reset-excluded-search-term", methods={"POST"}) * * @return JsonResponse ----------- end diff ----------- [OK] 1 file would have changed (dry-run) by Rector
The text was updated successfully, but these errors were encountered:
I am looking at it at rectorphp/rector-src#1862, feel free to provide a patch if you found the solution first.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Bug Report
Minimal PHP Code Causing Issue
Code
Rector
Expected Behaviour
The route just gets an additional "defaults" and not be duplicated
The text was updated successfully, but these errors were encountered: