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
Template Parameters + non-empty-string
bug
#5372
Comments
(cherry picked from commit c2a6127)
(cherry picked from commit c2a6127)
* SA: Update Scan* operations. * SA: Add Window static analysis tests. * SA: Add Tails static analysis tests. * SA: Add Tail static analysis tests. * SA: Add Pair static analysis tests. * SA: Add Pack static analysis tests. * SA: Add Lines static analysis tests. * SA: Add Reduction static analysis tests. * refactor: Update Pipe operation. * Show some failures * Fix some phpstan issues * Fix Reduction based on feedback. * Temporary workaround until phpstan/phpstan#5372 is fixed. * Update PHPStan baseline, remove stuff. * SA: Update Reduce operations. * Update PHPStan baseline. Co-authored-by: AlexandruGG <alex.gidei@goodlord.co>
I have a similar problem: an Repro: https://phpstan.org/r/e577e855-62ef-448c-8ccf-7a2e0dda538e |
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (1 error)
+PHP 8.0
==========
-32: Parameter #1 $list of function takesStrings expects Collection<int, string>, Collection<int, non-empty-string> given.
+No errors
-PHP 7.4 (2 errors)
+PHP 7.4 (1 error)
==========
11: Promoted properties are supported only on PHP 8.0 and later.
-32: Parameter #1 $list of function takesStrings expects Collection<int, string>, Collection<int, non-empty-string> given.
PHP 7.1 – 7.3 (3 errors)
========== Full reportPHP 8.0No errors PHP 7.4 (1 error)
PHP 7.1 – 7.3 (3 errors)
|
Fixed the issue from OP: phpstan/phpstan-src@6a33de9 @vhenzl Your issue is different, I improved the type verbosity to highlight the problem:
|
@vhenzl Fixed your problem too: phpstan/phpstan-src@7172e5f |
@ondrejmirtes thank you for fixing this! |
…ixed and released.
* fix: Fix constant type typo. * chore: Update PSalm baseline now that phpstan/phpstan#5372 has been fixed and released. * fix: Update SA tests accordingly.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Hello, the new 0.12.93 release seems to have introduced a bug regarding
non-empty-string
andstring
usage with template parameters.More specifically,
non-empty-string
seems to not be properly treated as a subtype ofstring
.Code snippet that reproduces the problem
https://phpstan.org/r/8ca61235-3da9-49cc-9b61-09b51abc7ee8
Expected output
No error should be reported because it's valid to pass a
non-empty-string
to something that expects astring
. Only the opposite is not allowed.The same snippet in Psalm shows no error: https://psalm.dev/r/f5871a0f0b
The text was updated successfully, but these errors were encountered: