Skip to content

Check that doctrine entities are not final#143

Merged
ondrejmirtes merged 1 commit into
phpstan:masterfrom
enumag:feature/final-entities
Sep 25, 2020
Merged

Check that doctrine entities are not final#143
ondrejmirtes merged 1 commit into
phpstan:masterfrom
enumag:feature/final-entities

Conversation

@enumag

@enumag enumag commented Sep 24, 2020

Copy link
Copy Markdown
Contributor

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?

@ondrejmirtes ondrejmirtes left a comment

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.

Comment thread src/Rules/Doctrine/ORM/EntityRule.php Outdated
@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

enumag commented Sep 24, 2020

Copy link
Copy Markdown
Contributor Author

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

@enumag

enumag commented Sep 24, 2020

Copy link
Copy Markdown
Contributor Author

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.

@ondrejmirtes ondrejmirtes left a comment

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'm fine with the rule in this PR as it is.

Comment thread rules.neon Outdated
@enumag
enumag force-pushed the feature/final-entities branch 2 times, most recently from d52b474 to 30f2b9e Compare September 24, 2020 12:52
@enumag

enumag commented Sep 24, 2020

Copy link
Copy Markdown
Contributor Author

Done. :-)

Comment thread rules.neon Outdated
@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

enumag commented Sep 25, 2020

Copy link
Copy Markdown
Contributor Author

Should be okay now.

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

Copy link
Copy Markdown
Member

Thank you!

@ondrejmirtes

Copy link
Copy Markdown
Member

Tagged as 0.12.20.

@mhujer

mhujer commented Sep 28, 2020

Copy link
Copy Markdown
Contributor

@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