Skip to content

Do not error if a non-field findByX method exists #56

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

Merged
merged 3 commits into from
Mar 11, 2019

Conversation

roverwolf
Copy link
Contributor

Do not generate an error if a custom findByX (or findOneByX, countByX) method exists but X is not a field in the entity class.

This should fix #52

Do not generate an error if a custom findByX method exists but X is not
a field in the entity class.
@ondrejmirtes
Copy link
Member

ondrejmirtes commented Feb 20, 2019

Hi, this isn't sufficient.

  1. There's no test that reproduces the problem.
  2. PHPStan's reflection objects should be used - you can obtain them by injecting Broker into the rule and calling $this->broker->getClass() and then ask for hasNativeMethod.
  3. There are multiple places that need to be fixed (and all of those bugs need to be reproduced first with tests):

@roverwolf roverwolf force-pushed the fix/52-find-by-methods branch from 9dfbe52 to 28658b5 Compare February 21, 2019 00:50
@roverwolf
Copy link
Contributor Author

I've added a test and changed to use PHPStan's Broker (sorry, I am new to PHPStan).

I have not seen any errors from PHPStan due to ObjectRepositoryDynamicReturnTypeExtension. Does it need to change if we assume the rule stays the same where a "find" method should return the entity class (or null, or an array of them)?

@ondrejmirtes
Copy link
Member

I'll look at ObjectRepositoryDynamicReturnTypeExtension myself. Thank you!

@ondrejmirtes ondrejmirtes merged commit 1933e0d into phpstan:master Mar 11, 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.

issue with findOneByX
2 participants