Repository navigation
Conversation
bocharsky-bw
left a comment
There was a problem hiding this comment.
Hey, thanks for fixing it! We probably have a regression with anonymous classes here. new class {...} in php parser also has Class_ type. Maybe we should skip $node->isAnonymous(), or you have a better idea?
Also, I approved the CI and see some tests are failing, could you take a look? Not sure if it's related to this PR, but if you could fix them - it would help a lot
…lasses Resetting the detection on every Class_ node broke form types containing an anonymous class (e.g. a data transformer): the fields declared after it were no longer extracted. Track the enclosing classes in a stack keyed on their end position instead, as the visitors define their own leaveNode(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
You're right, I ask Claude to check and it confirm the regression : the patch resets He suggest me to keep a stack of classes, keyed on where each one ends in the file. I added a commit for that.
my bad.... I forgot to commit tests... I added them |
Fixes #197
FormTrait::$isFormTypewas never reset once a form type had been found. AsPHPFileExtractorreuses the same visitor instances for every file, all the files (and classes) visited after a form type were considered as form types too. The form visitors then analysed arrays of plain classes, extracting false positive keys and reporting errors on them.Reset the flag in init(), called before each file, and when entering a new class.
Also fix
BaseVisitor::addError()crashing with "Call to a member function getAttribute() on int" when the node is a scalar: scalar nodes have a "value" property holding the raw value, not a Node.