Skip to content

Better anonymous class handling#2239

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
jeroensmit:NodeVisitorTest
Nov 4, 2019
Merged

Better anonymous class handling#2239
TomasVotruba merged 1 commit intorectorphp:masterfrom
jeroensmit:NodeVisitorTest

Conversation

@jeroensmit
Copy link
Copy Markdown
Contributor

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.

Added test for nodeVisitors
methodName: null
)
)
) No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be hell to maintain if php-parser or Rector changes any attribute/property.

Better check this with ->getAttribute() on particular node

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's give it a try then

@TomasVotruba TomasVotruba self-requested a review November 3, 2019 21:47
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visitor tests have to be changed to time-proof and independent on external unrelated change.

Otherwise I like it 👍

@TomasVotruba TomasVotruba merged commit b4e6ca9 into rectorphp:master Nov 4, 2019
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