Skip to content
New issue

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

Non-existing @psalm annotation shouldn't break otherwise valid docblock #10880

Closed
kkmuffme opened this issue Apr 4, 2024 · 1 comment · Fixed by #10885
Closed

Non-existing @psalm annotation shouldn't break otherwise valid docblock #10880

kkmuffme opened this issue Apr 4, 2024 · 1 comment · Fixed by #10885

Comments

@kkmuffme
Copy link
Contributor

kkmuffme commented Apr 4, 2024

https://psalm.dev/r/d773315d3f

An otherwise valid docblock should not be rendered unused creating mixed/... issues just because there is an invalid "@psalm" annotation.
e.g. in this case the annotation is something that exists in other static analysis (phpstan) but not in psalm however this doesn't have any impact on the rest of the docblock.
This also is relevant if e.g. @psalm-returnss or something is only misspelled - using the default fallback @return would be fine in that case normally, but completely ignoring the docblock is not.

The use case is that we're using a library that added some of those invalid annotations thus breaking the CI.

Copy link

I found these snippets:

https://psalm.dev/r/d773315d3f
<?php

/**
 * @psalm-impure
 * @return non-falsy-string
 */
function foo() {
	return 'bar';    
}

$x = foo();
/** @psalm-trace $x */;
Psalm output (using commit ef3b018):

ERROR: InvalidDocblock - 7:1 - Unrecognised annotation @psalm-impure

ERROR: InvalidDocblock - 7:1 - Unrecognised annotation @psalm-impure in docblock for foo

INFO: MissingReturnType - 7:10 - Method foo does not have a return type, expecting 'bar'

INFO: MixedAssignment - 11:1 - Unable to determine the type that $x is being assigned to

INFO: Trace - 12:23 - $x: mixed

INFO: UnusedVariable - 11:1 - $x is never referenced or the value is not used

kkmuffme added a commit to kkmuffme/psalm that referenced this issue Apr 6, 2024
kkmuffme added a commit to kkmuffme/psalm that referenced this issue Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant