psalm
psalm copied to clipboard
Psalter crashes on trying to fix MissingThrowsDocBlock
With this exception:
Target PHP version: 8.1 (set by config file) Extensions enabled: apcu, dom, pdo, redis, simplexml, soap (unsupported extensions: bcmath, ctype, curl, fileinfo, ftp, gd, iconv, intl, json, mbstring, openssl, pcntl, pcre, pdo_mysql, posix, session, sodium, sqlite3, zend-opcache, zip, zlib)
Scanning files...
Analyzing files...
Uncaught ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) in /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php:156
Stack trace:
#0 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php(156): strpos('<?php\n\nnamespac...', ')', 788)
#1 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php(105): Psalm\Internal\FileManipulation\FunctionDocblockManipulator->__construct('/home/aszen/Des...', Object(Psalm\Node\Stmt\VirtualClassMethod), Object(Psalm\Internal\Analyzer\ProjectAnalyzer))
#2 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(746): Psalm\Internal\FileManipulation\FunctionDocblockManipulator::getForFunction(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), '/home/aszen/Des...', Object(Psalm\Node\Stmt\VirtualClassMethod))
#3 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1798): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Internal\Provider\NodeDataProvider), Object(Psalm\Context))
#4 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1225): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod(Object(Psalm\Node\Stmt\VirtualClassMethod), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Internal\Analyzer\ClassAnalyzer), Object(Psalm\Context), Object(Psalm\Context), true)
#5 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(550): Psalm\Internal\Analyzer\ClassAnalyzer->checkPropertyInitialization(Object(Psalm\Codebase), Object(Psalm\Config), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Context), Object(Psalm\Context), NULL)
#6 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(203): Psalm\Internal\Analyzer\ClassAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Context))
#7 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(1581): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#8 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(522): Psalm\Internal\Codebase\Analyzer->analysisWorker(249, '/home/aszen/Des...')
#9 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(272): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1)
#10 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(651): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1, true, true)
#11 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalter.php(425): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/home/aszen/Des...')
#12 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(935): Psalm\Internal\Cli\Psalter::run(Array)
#13 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(182): Psalm\Internal\Cli\Psalm::forwardCliCall(Array, Array)
#14 /home/aszen/Desktop/project-test/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run(Array)
#15 /home/aszen/Desktop/project-test/vendor/bin/psalm(120): include('/home/aszen/Des...')
#16 {main}
(Psalm 5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863 crashed due to an uncaught Throwable)
Hey @aszenz, can you reproduce the issue on https://psalm.dev ?
A reproducer would be helpful, it may be a mismatch between string length between utf8 chars and ascii chars but I'm not sure where
I'm getting this issue as well. It appears to happen for any class that extends laravel/framework/src/Illuminate/Support/ServiceProvider.php (laravel/framework v11.21.0)
This also appeared to cause it in another file:
public const UPDATED_AT = null;
private float $executionStartTime;
not sure which of the two lines though.