Skip to content

Doctrine entity: is never written, only read. #229

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

Closed
ivoba opened this issue Nov 5, 2021 · 5 comments
Closed

Doctrine entity: is never written, only read. #229

ivoba opened this issue Nov 5, 2021 · 5 comments

Comments

@ivoba
Copy link

ivoba commented Nov 5, 2021

I receive phpstan message

is never written, only read.

for doctrine entity, which should probaly not happen.
As discussed in: https://stackoverflow.com/questions/69851516/phpstan-and-doctrine-id-is-never-written-only-read?noredirect=1#comment123480939_69851516

I made a test-repo: https://github.com/ivoba/phpstan-test
that reproduces this issue.

Maybe its just a misconfiguration. Thank you.

@zalexki
Copy link

zalexki commented Nov 8, 2021

same issue, i would have thought that this extension would fix the issue explained here https://phpstan.org/blog/detecting-unused-private-properties-methods-constants#what-if-my-code-is-%E2%80%9Cspecial%E2%80%9D%3F

am i mistaken ?

@pburggraf
Copy link

Currently I suppress this error message with the following setting in the phpstan.neon file.

parameters:
    ignoreErrors:
        - '#Property .+::\$id is never written, only read\.#'

But this is of course not a long-term solution.

@ivoba
Copy link
Author

ivoba commented Nov 22, 2021

It works when adding a ObjectManager like described here: https://github.com/phpstan/phpstan-doctrine#configuration

I am not sure if this issue is solved with this or we should keep it open because it should work even without a ObjectManager.

@ondrejmirtes
Copy link
Member

PHPStan needs the ObjectManager so that Doctrine tells it what's a persisted field and what isn't. Regardless of whether you're using PHPDocs, PHP 8 attributes or for example XML annotation driver.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants