Skip to content

Check that doctrine entities are not final #143

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 1 commit into from
Sep 25, 2020

Conversation

enumag
Copy link
Contributor

@enumag enumag commented Sep 24, 2020

I create all my classes as final by default. This however can cause issues with Doctrine:

  [Doctrine\Common\Proxy\Exception\InvalidArgumentException]
  Unable to create a proxy for a final class "<entity class>".

What do you think about a rule to avoid final entities?

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Yeah, I'm fine with this. Please add it as a bleeding edge rule similar to here: https://github.com/phpstan/phpstan-strict-rules/blob/334898a32217e4605e0f9cfa3d3fc3101bda26be/rules.neon#L67-L69

@enumag enumag force-pushed the feature/final-entities branch 2 times, most recently from 2b17ca7 to 7cc794d Compare September 24, 2020 09:11
@enumag enumag marked this pull request as ready for review September 24, 2020 09:11
@enumag
Copy link
Contributor Author

enumag commented Sep 24, 2020

@ondrejmirtes Updated according to your suggestions. Also added a test case.

@enumag
Copy link
Contributor Author

enumag commented Sep 24, 2020

Hmm... there is already a similar pull request: #84

Except I slightly disagree with the statement that entities shouldn't have final methods. I have a case where I'm actually using final method on purpose. But then again I could just disable that particular rule in my codebase.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

I'm fine with the rule in this PR as it is.

@enumag enumag force-pushed the feature/final-entities branch 2 times, most recently from d52b474 to 30f2b9e Compare September 24, 2020 12:52
@enumag
Copy link
Contributor Author

enumag commented Sep 24, 2020

Done. :-)

@enumag enumag force-pushed the feature/final-entities branch from 30f2b9e to 89c2186 Compare September 25, 2020 13:23
@enumag enumag force-pushed the feature/final-entities branch from 89c2186 to cd8bcc9 Compare September 25, 2020 13:24
@enumag enumag requested a review from ondrejmirtes September 25, 2020 13:25
@enumag
Copy link
Contributor Author

enumag commented Sep 25, 2020

Should be okay now.

@ondrejmirtes ondrejmirtes merged commit 207a6ae into phpstan:master Sep 25, 2020
@ondrejmirtes
Copy link
Member

Thank you!

@ondrejmirtes
Copy link
Member

Tagged as 0.12.20.

@mhujer
Copy link
Contributor

mhujer commented Sep 28, 2020

@enumag thanks! 👍

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.

3 participants