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

psalm doesn't work with aerospike extension #6894

Open
max-matiukhin opened this issue Nov 11, 2021 · 6 comments
Open

psalm doesn't work with aerospike extension #6894

max-matiukhin opened this issue Nov 11, 2021 · 6 comments

Comments

@max-matiukhin
Copy link

if PHP has an aerospike extension, psalm fails with this stacktrace:

Uncaught TypeError: Argument 1 passed to Psalm\Storage\FunctionLikeParameter::__construct() must be of the type string, null given, called in /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php on line 333 and defined in /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Storage/FunctionLikeParameter.php:115
Stack trace:
#0 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php(333): Psalm\Storage\FunctionLikeParameter->__construct(NULL, false, Object(Psalm\Type\Union), NULL, NULL, false, false, false)
#1 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php(301): Psalm\Internal\Codebase\Reflection->getReflectionParamData(Object(ReflectionParameter))
#2 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php(197): Psalm\Internal\Codebase\Reflection->extractReflectionMethodInfo(Object(ReflectionMethod))
#3 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(511): Psalm\Internal\Codebase\Reflection->registerClass(Object(ReflectionClass))
#4 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(298): Psalm\Internal\Codebase\Scanner->convertClassesToFilePaths(Object(Psalm\Internal\Codebase\ClassLikes))
#5 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Config.php(2098): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes))
#6 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(405): Psalm\Config->visitComposerAutoloadFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), Object(Psalm\Progress\VoidProgress))
#7 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(1150): Psalm\Internal\Analyzer\ProjectAnalyzer->visitAutoloadFiles()
#8 /home/maxm/psalm/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(362): Psalm\Internal\Analyzer\ProjectAnalyzer->checkPaths(Array)
#9 /home/maxm/psalm/vendor/vimeo/psalm/psalm(4): Psalm\Internal\Cli\Psalm::run(Array)

It happens probably because aerospike extension doesn't provide parameters names for the implemented methods ( see details in comments aerospike-community/aerospike-client-php#30 )

Any chance to fix it on the psalm side as aerospike authors seem reluctant to fix it on their side?
Or maybe you have any ideas for a workaround?

@psalm-github-bot
Copy link

Hey @max-matiukhin, can you reproduce the issue on https://psalm.dev ?

@max-matiukhin
Copy link
Author

@psalm-github-bot
no, because psalm.dev doesn't have aerospike extension

@orklah
Copy link
Collaborator

orklah commented Nov 11, 2021

We have exactly the same issue as Ondrej reported here: aerospike-community/aerospike-client-php#30 (comment)

However, the actual issue does not seem to critical. Please try proposing a PR to coalesce null returned by this line

$param_name = $param->getName();
with ''(empty string) and we'll see if this pass the CI

@zwick
Copy link

zwick commented Nov 11, 2021

+1 - Just tried setting up Psalm today and running into the same issue with Aerospike

Using reflection to get metadata for Aerospike
Uncaught TypeError: Argument 1 passed to Psalm\Storage\FunctionLikeParameter::__construct() must be of the type string, null given

@orklah
Copy link
Collaborator

orklah commented Nov 11, 2021

You're both in the best spot to fix this and check this is working after

I highlighted the place the error is coming from, if there are more, please give feedback and I'll help you through this

@zwick
Copy link

zwick commented Nov 12, 2021

@orklah That was exactly what I did and I was able to get past the initial setup. After that, it's irrelevant because the vendor directory can just be ignored

Thank you for sharing the workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants