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

Invalid type hint for properties when using psalm --alter #10650

Closed
BenjaminHoegh opened this issue Feb 4, 2024 · 3 comments · Fixed by #10654
Closed

Invalid type hint for properties when using psalm --alter #10650

BenjaminHoegh opened this issue Feb 4, 2024 · 3 comments · Fixed by #10654

Comments

@BenjaminHoegh
Copy link

./vendor/bin/psalm -v                                              
Psalm 5.21.1@8c473e2437be8b6a8fd8f630f0f11a16b114c494

./vendor/bin/psalm --alter --php-version=7.4 --issues=all --dry-run
Target PHP version: 7.4 (set by CLI argument).
Scanning files...
Analyzing files...

Altering files...
@@ -38,7 +38,7 @@
-    private $createAnchorIDCallback = null;
+    private ?callable $createAnchorIDCallback = null;
Copy link

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

@BenjaminHoegh
Copy link
Author

https://psalm.dev

Yes, but I believe psalm.dev is using a newer PHP version where this is valid

@weirdan
Copy link
Collaborator

weirdan commented Feb 4, 2024

I believe the callable type hint for properties is invalid for all existing PHP versions: https://3v4l.org/bXWo2 (also https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.base.function) so this is clearly a bug.

weirdan added a commit to weirdan/psalm that referenced this issue Feb 4, 2024
It's invalid in all PHP versions: https://3v4l.org/bXWo2

Also see php.net/manual/en/language.types.declarations.php#language.types.declarations.base.function

Fixes vimeo#10650
@BenjaminHoegh BenjaminHoegh changed the title invalid type for PHP version when using psalm --alter Invalid type hint for properties when using psalm --alter Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants