Doctrine entity: is never written, only read.
ivoba opened this issue · 5 comments
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.
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 ?
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.
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.
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.
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.