Skip to content

PhpDocParser: read a quoted key of a Doctrine annotation argument - #338

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:doctrine-quoted-argument-key
Oct 28, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:doctrine-quoted-argument-key

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Doctrine reads only a name as the key of an annotation argument: @Foo(key="value"). Some code has a key in quotes: @Foo("key"="value"). Before, the parser returned InvalidTagValueNode for all of the tag.

Now the parser reads a quoted key as the name of the argument. DoctrineArgument::$key is IdentifierTypeNode('key'), so the type of the property does not change. The format-preserving printer keeps the quotes.

The grammar in doc/grammars/phpdoc-block.pp3 has the same change.

Rector needs this to keep its existing fixtures, for example @ORM\OneToMany(..., "indexBy"="id").

@ondrejmirtes ondrejmirtes reopened this Oct 28, 2026
@ondrejmirtes
ondrejmirtes merged commit 88d1b98 into phpstan:2.3.x Oct 28, 2026
129 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.

1 participant