Is non-string exception codes supported? #7846
-
PHP allows specifying string values to exception codes: https://3v4l.org/mgE0M (I know, it is a bit of a "hack") But psalm emits an error about possible return type from
Is it intended by psalm - narrow down possible return types to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is indeed intended. There were a lot of discussions about this and specifically about your case here because there is no good solution for every case. The current compromise is already pretty complex but it covers a lot of use cases and is consistent with the behaviour in PHPStan so I don't think we'll change this in the core If it's really important for you, there may be a way to make a plugin or a stub in order to change Psalm's behaviour, but I wouldn't recommend it |
Beta Was this translation helpful? Give feedback.
It is indeed intended. There were a lot of discussions about this and specifically about your case here because there is no good solution for every case. The current compromise is already pretty complex but it covers a lot of use cases and is consistent with the behaviour in PHPStan so I don't think we'll change this in the core
If it's really important for you, there may be a way to make a plugin or a stub in order to change Psalm's behaviour, but I wouldn't recommend it