Closed PFQNiet closed 2 months ago
Trait is analysed in context of each class that uses it. I recommend you to ignore this error: https://phpstan.org/r/8641beec-6ae4-4dc0-be0b-0ad9829c9886
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.
Demonstration of the issue: https://phpstan.org/r/b793ec1a-e47e-4f6f-b3d6-0bf9595bb1a2
In my actual use,
SomeTrait
has ORM-like behaviour. Classes using it should provide agetId
method that returns the primary key, and internallygetRawId
is used to convert object-based IDs into anint|string
for use in the DB.But Strict Rules doesn't like the check for object-based IDs because, according to the narrower return type of
getId
on the classes that use the trait, theinstanceof
is always true... but it can also be always false. It depends what type is used by the class (Foo
andBar
classes in the demo).Is this an issue with the rule, or my implementation?