psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Psalm tries to read @phpstan tags that it does not support

Open vudaltsov opened this issue 9 months ago • 6 comments

I have a phpdoc like this: @phpstan-param ReadonlyMessageContext<*, *> $parent. I specifically wrote it for PHPStan. Now Psalm complains that this is an InvalidDocblock. Same for call-site variance. I thought that the idea behind namespaced tags is that other tools ignore them...

vudaltsov avatar Apr 02 '25 19:04 vudaltsov

Hey @vudaltsov, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

psalm-github-bot[bot] avatar Apr 02 '25 19:04 psalm-github-bot[bot]

Both PHPStan and Psalm read each other's phpdoc tags, but each prefers its own. Add a @psalm-param with a syntax Psalm understand, and it will ignore @phpstan-param

weirdan avatar Apr 02 '25 21:04 weirdan

Both PHPStan and Psalm read each other's phpdoc tags, but each prefers its own.

Ok, thank you! Got the idea.

Add a @psalm-param with a syntax Psalm understand, and it will ignore @phpstan-param

It doesn't ignore :( https://psalm.dev/r/afa9872862

vudaltsov avatar Apr 02 '25 21:04 vudaltsov

I found these snippets:

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

/**
 * @template T
 */
final class A {}

/**
 * @psalm-param A $a
 * @phpstan-param A<*> $a
 */
function a(A $a): void {}
Psalm output (using commit 1288d7a):

ERROR: InvalidDocblock - 10:19 - Invalid type '*' in docblock for a

psalm-github-bot[bot] avatar Apr 02 '25 21:04 psalm-github-bot[bot]

Probably the problem here is that Psalm does not understand this phpdoc at a parsing level.

vudaltsov avatar Apr 02 '25 21:04 vudaltsov

Yeah, it looks that way. Type syntax used to be mostly compatible, but that seems to be no longer the case.

weirdan avatar Apr 02 '25 22:04 weirdan