Skip to content

fix: stop AnnotationToAttributeRector depending on Rector's removed ArrayParser - #443

Merged
bbrala merged 2 commits into
mainfrom
fix/annotation-to-attribute-arrayparser
Nov 4, 2026
Merged

bbrala merged 2 commits into
mainfrom
fix/annotation-to-attribute-arrayparser

Conversation

@bbrala

@bbrala bbrala commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Description

rectorphp/rector-src#8881 (merged 2026-10-29, not in a tagged release yet) removed Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser. AnnotationToAttributeRector takes that class in its constructor, so on Rector dev-main the rule fails to load: 13 test errors (ReflectionException: Class "...ArrayParser" does not exist) and 3 PHPStan class.notFound errors.

The next Rector release will most likely include both #8881 and rectorphp/rector-src#8897, which #441 waits on. This has to land before we raise the Rector requirement.

ArrayParser was only used for tags Rector could not parse as a Doctrine annotation (GenericTagValueNode). That covers a bare @Action, arguments starting on the line after the tag, and @Action followed by a description. Only the empty case produced a correct attribute; the others came out broken, e.g. Action('(id').

The fix:

  • Drops ArrayParser and TokenIteratorFactory.
  • An argument-less tag still becomes the argument-less attribute, as before.
  • Any other unparsed tag is now left alone, annotation included, instead of being turned into a broken attribute.
  • Parsed Doctrine annotations, which is nearly all real code, are unchanged.

No existing fixture reached that branch. There are four new fixtures for the no-arguments and arguments-on-next-line cases, in both the default and next-major runs.

To Test

Tests and PHPStan pass on Rector 2.6.5, 2.8.3 and dev-main (2a5280bf): 699 tests each, no baseline changes.

composer require --dev rector/rector:dev-main -W
vendor/bin/phpunit
vendor/bin/phpstan analyse

Related: #441

…rrayParser

rectorphp/rector-src#8881 removed StaticDoctrineAnnotationParser\ArrayParser,
so the rule failed to construct on Rector dev-main. The GenericTagValueNode
branch only produced a correct attribute for an argument-less tag; convert
that to an attribute without arguments and leave other unparsed tags alone.
@bbrala

bbrala commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@samsonasik it seems we might have a decent regression here because of rectorphp/rector-src#8881 since we cannot see data anymore?

@samsonasik

Copy link
Copy Markdown
Contributor

can that be tweaked here? If yes, then I think tweak here is the way

@bbrala

bbrala commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Seems i overreacted, see related issue

@bbrala
bbrala merged commit da0883c into main Nov 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants