Open rzvc opened 2 years ago
I found these snippets:
Even if Psalm understands it's dealing with a singleton, it won't help you.
Any statement between your is_null check and your trim could potentially mutate your instance and change $str value...
That can be said about any object, and it would apply to the scenario where the object is used directly as well, but that one works. If Psalm would be aware of the singleton pattern, it would behave the same in both cases.
I can't find a way to indicate to Psalm that a method/function will always return the same object:
https://psalm.dev/r/55b5ff1a69
Something like
@psalm-singleton
on the method's or function's docblock would be nice.