spaze / phpstan-disallowed-calls

PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute & superglobal usages
MIT License
255 stars 17 forks source link

After update psalm dies to unknown class #216

Closed vlakarados closed 1 year ago

vlakarados commented 1 year ago

Bug Description Running psalm on a codebase with recent version of phpstan-disallowed-calls (which is included in vendor due to running in development) ends up with psalm dying:

Uncaught Exception: InvalidArgumentException Could not get class storage for spaze\phpstan\rules\disallowed\allowed\allowdirectivesconfig
Emitted in /.../vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45

Additional context

Seems to be related to line 179 in \vendor\spaze\phpstan-disallowed-calls\src\Allowed\Allowed.php: * @phpstan-param AllowDirectivesConfig $allowed where indeed AllowDirectivesConfig is undefined and not found across the project.

https://github.com/spaze/phpstan-disallowed-calls/blob/main/src/Allowed/Allowed.php#L179

vlakarados commented 1 year ago

Despite this is actually a problem, the main issue is with a recent commit to psalm: https://github.com/vimeo/psalm/issues/10132

spaze commented 1 year ago

AllowDirectivesConfig is a global type alias defined here https://github.com/spaze/phpstan-disallowed-calls/blob/c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c/phpstan.neon#L12

vlakarados commented 1 year ago

I see, actually never used that, but this can be achieved with https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-type and @psalm-import-type which phpstan seems to also understand.

In any case, this is a question of preference, and I think this issue can be closed

spaze commented 1 year ago

Thanks, I don't know if Psalm supports aliases in @phpstan-param, guess they don't and guess they should 😅

Alright, closing.