Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExplicitMethodCallOverMagicGetSetRector fix #2719

Merged
merged 1 commit into from Jul 28, 2022

Conversation

MartinMystikJonas
Copy link
Contributor

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 28, 2022

Thanks! Could you add the failing test fixture, so we have feature covered?

@MartinMystikJonas
Copy link
Contributor Author

@TomasVotruba I can try

@MartinMystikJonas
Copy link
Contributor Author

OK it seems fix would be more complicated than I thought. For objects with magic methods hasProperty always returns maybe so we cannot check for property existence

@MartinMystikJonas
Copy link
Contributor Author

MartinMystikJonas commented Jul 28, 2022

I see three options:

  1. Use try/catch and skip rule if getProperty fails
  2. Skip rule even for hasProperty()->maybe()
  3. apply rule even for unknown properties by ignoring impossible check of types by
if (! $propertyType->isSuperTypeOf($returnType)->yes()) {
    continue;
}

because it is only place where it is used.

I would go for option 2 but I am not sure it is right way.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 28, 2022

I would go for option 2 but I am not sure it is right way.

Seems the most valid way 👍

How the test perform with this solution?

@MartinMystikJonas
Copy link
Contributor Author

Pushed option 2. Old tests passes and new test works with this.

@TomasVotruba
Copy link
Member

LGTM 👍 Thank you

@TomasVotruba TomasVotruba merged commit 8df7912 into rectorphp:main Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants