vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.57k stars 661 forks source link

Psalm crashes after start on PhpParser\Lexer\Emulative::__construct() :( #11095

Open DocFX opened 2 months ago

DocFX commented 2 months ago

Env: Docker container with debian-slim, PHP 8.4a, installed via Composer, trying to use a custom config file.

Psalm 5.26.1.

Attached log:

Target PHP version: 8.4 (inferred from current PHP version).
Scanning files...
Uncaught TypeError: PhpParser\Lexer\Emulative::__construct(): Argument #1 ($phpVersion) must be of type ?PhpParser\PhpVersion, array given, called in /[...]/vendor/vimeo/psalm/src/Psalm/Internal/Provider/StatementsProvider.php on line 400 and defined in [...]/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php:38
Stack trace:
#0 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Provider/StatementsProvider.php(400): PhpParser\Lexer\Emulative->__construct()
#1 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Provider/StatementsProvider.php(136): Psalm\Internal\Provider\StatementsProvider::parseStatements()
#2 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(51): Psalm\Internal\Provider\StatementsProvider->getStatementsForFile()
#3 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(550): Psalm\Internal\Scanner\FileScanner->scan()
#4 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(778): Psalm\Internal\Codebase\Scanner->scanFile()
#5 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(424): Psalm\Internal\Codebase\Scanner->scanAPath()
#6 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(280): Psalm\Internal\Codebase\Scanner->scanFilePaths()
#7 [...]/vendor/vimeo/psalm/src/Psalm/Config.php(2588): Psalm\Internal\Codebase\Scanner->scanFiles()
#8 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(358): Psalm\Config->visitComposerAutoloadFiles()
#9 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(488): Psalm\Internal\Analyzer\ProjectAnalyzer->visitAutoloadFiles()
#10 [...]/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(379): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#11 [...]/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run()
#12 [...]/vendor/bin/psalm(119): include('...')
#13 {main}
(Psalm 5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0 crashed due to an uncaught Throwable)

Config file (if relevant):

<?xml version="1.0"?>
<psalm
        errorLevel="8"
        resolveFromConfigFile="true"
        runTaintAnalysis="true"
        autoloader="../../../../../backend-generated/vendor/autoload.php"
        findUnusedBaselineEntry="true"
        findUnusedCode="true"
>
    <fileExtensions>
        <extension name=".php" />
        <extension name=".module" />
        <extension name=".theme" />
        <extension name=".inc" />
    </fileExtensions>
    <projectFiles>
        <directory name="../../../../../backend-sources"/>
    </projectFiles>
</psalm>

Note: paths are hidden for privacy, but all of them are correct.

psalm-github-bot[bot] commented 2 months ago

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