You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I want to override a typehint that a method returns an interface so that it returns a specific concrete implementation of it, I always end up with either
NonInvariantPropertyType for redeclaring the (protected readonly) property with the more specific type https://psalm.dev/r/c307b13eee
LessSpecificReturnStatement/MoreSpecificReturnType because the property is still typehinted to the interface https://psalm.dev/r/e3b7a09b6c
Using templating works (https://psalm.dev/r/292de936c4) but I have to annotate a bunch of subclasses to use the template, and I don't want to have to do runtime checks or @psalm-var when I know certain classes have specific guaranteed concrete implementations.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If I want to override a typehint that a method returns an interface so that it returns a specific concrete implementation of it, I always end up with either
Using templating works (https://psalm.dev/r/292de936c4) but I have to annotate a bunch of subclasses to use the template, and I don't want to have to do runtime checks or
@psalm-var
when I know certain classes have specific guaranteed concrete implementations.How should I go about this?
Beta Was this translation helpful? Give feedback.
All reactions