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
The fix for MissingThrowsDocblock does not prepend the full class names of the exception(s) with a leading slash. The result of this is that within a namespace, the class name in an added @throws annotation will be relative to the namespace, probably resulting in an UndefinedDocblockClass. See https://psalm.dev/r/32c7b62a8d, which shows the result of fixing after initially no @throws annotation was available.
I haven’t seen a way to add an example of the fixer via psalm.dev psalm.dev doesn't seem able to fix the MissingThrowsDocblock so I can't show an example of that, but this can be tested by adding an additional dataset to the data provider of ThrowsBlockAdditionTest. The dataset should look like:
I fear there’s maybe an underlying challenge in regards to adding or detecting use statements. But I think it can be sufficient to simply add the fully qualified class name. Other tools like PHP_CodeSniffer can be used to further transform that into nice formatting, the goal here should be to ensure the @throws annotation is added with the right type.
The text was updated successfully, but these errors were encountered:
Psalm output (using commit afe85fa):
ERROR: UndefinedDocblockClass - 6:12 - Docblock-defined class, interface or enum named Foo\RuntimeException does not exist
INFO: MissingThrowsDocblock - 9:5 - RuntimeException is thrown but not caught - please either catch or add a @throws annotation
The fix for
MissingThrowsDocblock
does not prepend the full class names of the exception(s) with a leading slash. The result of this is that within a namespace, the class name in an added@throws
annotation will be relative to the namespace, probably resulting in anUndefinedDocblockClass
. See https://psalm.dev/r/32c7b62a8d, which shows the result of fixing after initially no@throws
annotation was available.I haven’t seen a way to add an example of the fixer via psalm.devpsalm.dev doesn't seem able to fix theMissingThrowsDocblock
so I can't show an example of that, but this can be tested by adding an additional dataset to the data provider ofThrowsBlockAdditionTest
. The dataset should look like:I fear there’s maybe an underlying challenge in regards to adding or detecting
use
statements. But I think it can be sufficient to simply add the fully qualified class name. Other tools like PHP_CodeSniffer can be used to further transform that into nice formatting, the goal here should be to ensure the@throws
annotation is added with the right type.The text was updated successfully, but these errors were encountered: