Property is never written on inversed side of OneToOne relation properties
Hello, First of all thank you for all your work, it's great!
We recently upgraded to the latest phpstan/phpstan and phpstan/phpstan-doctrine and we started to have some errors reported on inversed side of OneToOne relationship properties.
For example, I have two entities:
class Signature {
// ...
/**
* @ORM\OneToOne(targetEntity="App\Entity\Author", inversedBy="signature")
* @ORM\JoinColumn(onDelete="SET NULL")
*
* @var Author|null
*/
private $author;
// ...
}
class Author {
// ...
/**
* @ORM\OneToOne(targetEntity="App\Entity\Signature", mappedBy="author")
*
* @var Signature|null
*/
private $signature;
// ...
}
Both entities have a constructor and they are both non read-only entities.
When I run phpstan I received the error Property App\Entity\Author::$signature is never written, only read. 💡 See: https://phpstan.org/developing-extensions/always-read-written-properties.
Following the rules explained in https://phpstan.org/developing-extensions/always-read-written-properties it's correct that this error is raised but, I was wondering, if this is really a wanted behavior for this particular case.
If it's not, I'd be happy to try to find a fix for it and submit a PR.
phpstan/phpstan version: 1.3.0
phpstan/phpstan-doctrine version: 1.0.2
did you configure the object manager in the phpstan extension?
Yes
I'm seeing the same behaviour here, with a properly configured object manager.
Did anybody find a solution or workaround? I experienced the same with one-to-one relation and properly configured object manager.
Btw, It works fine with $id fields of entities which is never written too. But not with one-to-one
Seeing same issue with self referenced parent - child table.