-
-
Couldn't load subscription status.
- Fork 933
Description
Bug report
Since I've update to phpstan 2.1.19 I've got a error when analysing my project.
The problem is unfortunatly not reproducible on phpstan playground but I reproduced it on debian bullseye (php 7.4.33), ubuntu 24.10 (php 8.3.11) and mageia Cauldron (php 8.4.10) using phar or composer installed phpstan
when analysing with phpstan level 7 or above, I'v got the following error:
$ ./phpstan-2.1.19.phar analyze --level=7 bug-phpstan-2.1.19.php 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% In ByteString.php line 370: Invalid "UTF-8" string. analyse [-c|--configuration CONFIGURATION] [-l|--level LEVEL] [--no-progress] [--debug] [-a|--autoload-file AUTOLOAD-FILE] [--error-format ERROR-FORMAT] [-b|--generate-baseline [GENERATE-BASELINE]] [--allow-empty-baseline] [--memory-limit MEMORY-LIMIT] [--xdebug] [--tmp-file TMP-FILE] [--instead-of INSTEAD-OF] [--fix] [--watch] [--pro] [--fail-without-result-cache] [--] [<paths>...] If I run php with --debug option I got the following trace:
$ ./phpstan-2.1.19.phar analyze --level=7 bug-phpstan-2.1.19.php --debug /home/shad/Work/bug-phpstan/bug-phpstan-2.1.19.php PHP Fatal error: Uncaught _PHPStan_e7febc360\Symfony\Component\String\Exception\InvalidArgumentException: Invalid "UTF-8" string. in phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/string/ByteString.php:370 Stack trace: #0 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(247): _PHPStan_e7febc360\Symfony\Component\String\ByteString->toCodePointString() #1 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(225): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->addLineBreaks() #2 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(160): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->applyCurrentStyle() #3 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Helper/Table.php(514): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->formatAndWrap() #4 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Helper/Table.php(325): _PHPStan_e7febc360\Symfony\Component\Console\Helper\Table->buildTableRows() #5 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/ErrorsConsoleStyle.php(69): _PHPStan_e7febc360\Symfony\Component\Console\Helper\Table->render() #6 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/Symfony/SymfonyStyle.php(52): PHPStan\Command\ErrorsConsoleStyle->table() #7 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/ErrorFormatter/TableErrorFormatter.php(120): PHPStan\Command\Symfony\SymfonyStyle->table() #8 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/AnalyseCommand.php(388): PHPStan\Command\ErrorFormatter\TableErrorFormatter->formatErrors() #9 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute() #10 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(868): _PHPStan_e7febc360\Symfony\Component\Console\Command\Command->run() #11 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(261): _PHPStan_e7febc360\Symfony\Component\Console\Application->doRunCommand() #12 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(157): _PHPStan_e7febc360\Symfony\Component\Console\Application->doRun() #13 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan(93): _PHPStan_e7febc360\Symfony\Component\Console\Application->run() #14 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan(94): {closure:phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan:14}() #15 /home/shad/Work/bug-phpstan/phpstan-2.1.19.phar(7): require('...') #16 {main} thrown in phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/string/ByteString.php on line 370 Fatal error: Uncaught _PHPStan_e7febc360\Symfony\Component\String\Exception\InvalidArgumentException: Invalid "UTF-8" string. in phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/string/ByteString.php:370 Stack trace: #0 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(247): _PHPStan_e7febc360\Symfony\Component\String\ByteString->toCodePointString() #1 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(225): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->addLineBreaks() #2 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Formatter/OutputFormatter.php(160): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->applyCurrentStyle() #3 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Helper/Table.php(514): _PHPStan_e7febc360\Symfony\Component\Console\Formatter\OutputFormatter->formatAndWrap() #4 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Helper/Table.php(325): _PHPStan_e7febc360\Symfony\Component\Console\Helper\Table->buildTableRows() #5 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/ErrorsConsoleStyle.php(69): _PHPStan_e7febc360\Symfony\Component\Console\Helper\Table->render() #6 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/Symfony/SymfonyStyle.php(52): PHPStan\Command\ErrorsConsoleStyle->table() #7 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/ErrorFormatter/TableErrorFormatter.php(120): PHPStan\Command\Symfony\SymfonyStyle->table() #8 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/src/Command/AnalyseCommand.php(388): PHPStan\Command\ErrorFormatter\TableErrorFormatter->formatErrors() #9 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute() #10 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(868): _PHPStan_e7febc360\Symfony\Component\Console\Command\Command->run() #11 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(261): _PHPStan_e7febc360\Symfony\Component\Console\Application->doRunCommand() #12 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/console/Application.php(157): _PHPStan_e7febc360\Symfony\Component\Console\Application->doRun() #13 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan(93): _PHPStan_e7febc360\Symfony\Component\Console\Application->run() #14 phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan(94): {closure:phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/bin/phpstan:14}() #15 /home/shad/Work/bug-phpstan/phpstan-2.1.19.phar(7): require('...') #16 {main} thrown in phar:///home/shad/Work/bug-phpstan/phpstan-2.1.19.phar/vendor/symfony/string/ByteString.php on line 370 More surprising, if I reduce the name of the class, translatemethod or array parameter (for instance translateAbcdefg instead of translateAbcdefgh), phpstan does not crash anymore and got the same error than with phpstan 2.1.18
$ ./phpstan-2.1.19.phar analyze --level=7 bug-phpstan-2.1.19.php 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Line bug-phpstan-2.1.19.php ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5 Property Abcdefghijklmnopqrstuvwxyzabcdefghijk::$data has no type specified. 🪪 missingType.property 5 Property Abcdefghijklmnopqrstuvwxyzabcdefghijk::$data is never written, only read. 🪪 property.onlyRead 💡 See: https://phpstan.org/developing-extensions/always-read-written-properties 10 Method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefg() has no return type specified. 🪪 missingType.return 14 Method Abcdefghijklmnopqrstuvwxyzabcdefghijk::method() is unused. 🪪 method.unused 17 Call to method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefg() on a separate line has no effect. 🪪 method.resultUnused 17 Parameter #1 $arrayabc of method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefg() expects array{status: int, error: string, date?: string}, non-empty-array<mixed, mixed> give n. 🪪 argument.type ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Code snippet that reproduces the problem
https://phpstan.org/r/186e4914-c656-4109-9f7d-e20fae022cf3
Expected output
$ ./phpstan-2.1.19.phar analyze --level=7 bug-phpstan-2.1.19.php 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Line bug-phpstan-2.1.19.php ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5 Property Abcdefghijklmnopqrstuvwxyzabcdefghijk::$data has no type specified. 🪪 missingType.property 5 Property Abcdefghijklmnopqrstuvwxyzabcdefghijk::$data is never written, only read. 🪪 property.onlyRead 💡 See: https://phpstan.org/developing-extensions/always-read-written-properties 10 Method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefgh() has no return type specified. 🪪 missingType.return 14 Method Abcdefghijklmnopqrstuvwxyzabcdefghijk::method() is unused. 🪪 method.unused 17 Call to method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefgh() on a separate line has no effect. 🪪 method.resultUnused 17 Parameter #1 $arrayabc of method Abcdefghijklmnopqrstuvwxyzabcdefghijk::translateAbcdefgh() expects array{status: int, error: string, date?: string}, non-empty-array<mixed, mixed> give n. 🪪 argument.type ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Did PHPStan help you today? Did it make you happy in any way?
PHPStan does not help me only today but every days of the year