Better anonymous class handling#2239
Conversation
Added test for nodeVisitors
| methodName: null | ||
| ) | ||
| ) | ||
| ) No newline at end of file |
There was a problem hiding this comment.
This would be hell to maintain if php-parser or Rector changes any attribute/property.
Better check this with ->getAttribute() on particular node
There was a problem hiding this comment.
That was my original plan, but it turned out that it was hard to determine which node was what and how it related to other nodes.
Since the attributes you want rendered are whitelisted only attributes that are relevant to the visitor you want to test should be shown. I consider any changes to these attributes relevant to the test as well.
As a solution about the maintainability (and because no sane man would type this dumps themselves) you can run this command:
UPDATE_FIXTURE=1 vendor/bin/phpunit
It will replace the dump.
There was a problem hiding this comment.
I see. Let's give it a try then
TomasVotruba
left a comment
There was a problem hiding this comment.
The visitor tests have to be changed to time-proof and independent on external unrelated change.
Otherwise I like it 👍
Also added test for nodeVisitors
I got a bit carried away while fixing a couple of issues that were caused by incorrect handling of anonymous classes.