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

TypeError: ConstantTypeResolver::getLiteralTypeFromScalarValue(PropertyHookType::Get) #11203

Open
mlahargou opened this issue Jan 21, 2025 · 1 comment

Comments

@mlahargou
Copy link

Bug report

I started getting an odd psalm error:

8716 / 8716...Uncaught TypeError: Psalm\Internal\Codebase\ConstantTypeResolver::getLiteralTypeFromScalarValue(): Argument #1 ($value) must be of type array|string|int|float|bool|null, PropertyHookType given, called in /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php on line 166 and defined in /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ConstantTypeResolver.php:371
Stack trace:
#0 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Reflection.php(166): Psalm\Internal\Codebase\ConstantTypeResolver::getLiteralTypeFromScalarValue(PropertyHookType::Get)
#1 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(471): Psalm\Internal\Codebase\Reflection->registerClass(Object(ReflectionClass))
#2 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(265): Psalm\Internal\Codebase\Scanner->convertClassesToFilePaths(Object(Psalm\Internal\Codebase\ClassLikes))
#3 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Codebase.php(436): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 3)
#4 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(487): Psalm\Codebase->scanFiles(3)
#5 /mnt/local/home/next/Code/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(383): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/mnt/local/home...', true)
#6 /mnt/local/home/next/Code/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run(Array)
#7 /mnt/local/home/next/Code/vendor/bin/psalm(119): include('/mnt/local/home...')

Reproduction:

I've created an example repo for demo purposes: https://github.com/mlahargou/psalm-phpstan-bug

Copy link

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

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

No branches or pull requests

1 participant