Bug report
After recent changes phpstan/phpstan-src#5798 there has been a regression. The attached code snippet is reported as an error.
Because PHPStan does not see any explicit throw points (because the condition is always false), it will mark new FileIteratorSourceLocator([1, 2, 3]) as unused. But in fact the user is expecting the condition to be thrown.
We COULD get explicit throw points even from dead code branches but right now everything from them is thrown away (https://github.com/phpstan/phpstan-src/blob/7fe8b00282cff26f814cbddbec9906a1f4802301/src/Analyser/NodeScopeResolver.php#L1317) so I don't want to change that precedent.
Instead, we could also take @throws above the involved constructors/functions/methods from the WHOLE TRANSITIVE CHAIN into account.
Please add tests to all rules that were changed in the original linked PR, to make sure the implementation is correct.
Code snippet that reproduces the problem
https://phpstan.org/r/1f7b2f5d-3117-4e74-bb2a-61521dbbf40e
Expected output
"Call to new FileIteratorSourceLocator() on a separate line has no effect." should not be reported
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
After recent changes phpstan/phpstan-src#5798 there has been a regression. The attached code snippet is reported as an error.
Because PHPStan does not see any explicit throw points (because the condition is always false), it will mark
new FileIteratorSourceLocator([1, 2, 3])as unused. But in fact the user is expecting the condition to be thrown.We COULD get explicit throw points even from dead code branches but right now everything from them is thrown away (https://github.com/phpstan/phpstan-src/blob/7fe8b00282cff26f814cbddbec9906a1f4802301/src/Analyser/NodeScopeResolver.php#L1317) so I don't want to change that precedent.
Instead, we could also take
@throwsabove the involved constructors/functions/methods from the WHOLE TRANSITIVE CHAIN into account.Please add tests to all rules that were changed in the original linked PR, to make sure the implementation is correct.
Code snippet that reproduces the problem
https://phpstan.org/r/1f7b2f5d-3117-4e74-bb2a-61521dbbf40e
Expected output
"Call to new FileIteratorSourceLocator() on a separate line has no effect." should not be reported
Did PHPStan help you today? Did it make you happy in any way?
No response