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
I have a collection class that has the method foreach(callable(T): void): void and I would like to declare the class as immutable since there's never an internal mutation and it never performs an external mutation itself. In the case of the foreach method it's the callable that must perform mutations.
My problem is that if I add @psalm-immutable psalm will tell me that the foreach method does nothing since it returns nothing and doesn't perform any mutation itself.
Is there a way to declare the class immutable and tell psalm that the callable passed to foreach will perform mutation ?
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
-
Hi,
I have a collection class that has the method
foreach(callable(T): void): void
and I would like to declare the class as immutable since there's never an internal mutation and it never performs an external mutation itself. In the case of theforeach
method it's the callable that must perform mutations.My problem is that if I add
@psalm-immutable
psalm will tell me that theforeach
method does nothing since it returns nothing and doesn't perform any mutation itself.Is there a way to declare the class immutable and tell psalm that the callable passed to
foreach
will perform mutation ?Beta Was this translation helpful? Give feedback.
All reactions