Skip to content

Read indexBy key in valid Doctrine syntax, without quotes - #543

Merged
samsonasik merged 1 commit into
rectorphp:mainfrom
ondrejmirtes:doctrine-unquoted-keys
Oct 28, 2026
Merged

samsonasik merged 1 commit into
rectorphp:mainfrom
ondrejmirtes:doctrine-unquoted-keys

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Contributor

CollectionTypeFactory read the indexBy key only when the key had quotes: "indexBy"="id". Doctrine does not accept quoted keys. For the valid syntax indexBy="id", the rule ignored the key.

Now the rule uses getValue('indexBy'), which reads both forms. The fixtures use the valid syntax.

This change is necessary for rectorphp/rector-src, which will parse Doctrine annotations with phpdoc-parser. phpdoc-parser does not accept quoted keys. The change works with the current rector-src and with the new one.

@ondrejmirtes

Copy link
Copy Markdown
Contributor Author

So - back to ready for review again. The original fixtures code is not valid Doctrine grammar so the edits to remove "" are correct here. If you know about some other popular PHPDoc annotations parser that supports them and you want to cover the implementation, there should be some discussion around that.

@ondrejmirtes
ondrejmirtes force-pushed the doctrine-unquoted-keys branch from 1ae480c to 80f6ff5 Compare October 28, 2026 20:08
@samsonasik

Copy link
Copy Markdown
Member

Looks good now, thank you @ondrejmirtes

@samsonasik
samsonasik merged commit 4b3ccaf into rectorphp:main Oct 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants