Psalm Static Analyzer fails with Symfony’s builtin preloading file

So i updated a symfony app the other day to version 5.1.6 and suddenly the static code analyzer psalm ran appearently in an hangup loop and never terminated.

After some investigation it showed that symfony added a .preload.php file to the src directory to enable the new PHP7.4 preloading feature.

Unfortunatly psalm parsed this file and followed all includes.
This took it so long that i took it for an endless loop.

There is some discussion in symfony github issues about this and the conclusion was to replace src/.preload.php with config/preload.php which happens now in a recipe.

So best remove the old preload file

rm src/.preload.php

and rerun the framework bundle recipe:

composer recipes:install symfony/framework-bundle --force -v

Caution: this will override your current config and Kernel.php, make a careful diff on the change and revert changes that are unwanted.

The new preload file is now in config/preload.php and only available for prod env.
So psalm wont pick it up anymore and it will work again as usual.


Without updating the recipe, the fix would be to tell psalm to ignore this file in psalm.xml.

    <projectFiles>
        <directory name="./src"/>
        <ignoreFiles>
            <file name="./src/.preload.php"/>
        </ignoreFiles>
    </projectFiles>Code language: HTML, XML (xml)

:)