We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I'm not sure it will be worth fixing but I'll report it anyway.
While working on phpDocumentor/phpDocumentor#2263
I noticed Psalm suggested to delete a cast to string that seemed not useful: https://github.com/phpDocumentor/phpDocumentor/pull/2263/files#diff-5844ff81b5eb5ff658aabe38d06279fdL70
I reproduced something similar in psalm.dev: https://psalm.dev/r/d50c69dac0
We have an exception that could be thrown in __toString (note that this is valid from PHP 7.4 only).
The cast to (string) on a class that implements __toString can actually be valid code that may throw and that could be catched and handled.
The text was updated successfully, but these errors were encountered:
I found these snippets:
<?php class maybe_stringable{ /** @throws Exception */ public function __toString(){ if(rand(0,1)){ throw new exception(); } return ""; } } $a = new maybe_stringable(); try{ (string) $a; } catch(Exception $e){ //this class is not stringable }
Psalm output (using commit b486bd4): No issues!
Sorry, something went wrong.
e567f8c
Anything that deletes working code is a bug that's worth fixing!
No branches or pull requests
Hi,
I'm not sure it will be worth fixing but I'll report it anyway.
While working on phpDocumentor/phpDocumentor#2263
I noticed Psalm suggested to delete a cast to string that seemed not useful: https://github.com/phpDocumentor/phpDocumentor/pull/2263/files#diff-5844ff81b5eb5ff658aabe38d06279fdL70
I reproduced something similar in psalm.dev:
https://psalm.dev/r/d50c69dac0
We have an exception that could be thrown in __toString (note that this is valid from PHP 7.4 only).
The cast to (string) on a class that implements __toString can actually be valid code that may throw and that could be catched and handled.
The text was updated successfully, but these errors were encountered: