How to fix: weird phpstan internal errors from class loading when running analyse

Lets say you use phpstan and you bootstrap the symfony application for phpstan (or doctrine-extension of phpstan). You can get errors like this:

Internal error: Internal error: The autoloader expected class “Hoa\Zformat\Parameter” to be defined in file “phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/composer/../hoa/zformat/Parameter.php”. The file was found but the class was not in it, the class name or namespace probably has a typo. in file
/app/src/php/WebsiteBundle/Model/StoryBlok/Story.php
Run PHPStan with — debug option and post the stack trace to:
https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Child process error (exit code 1):
The autoloader expected class "Stringable" to be defined in file "/home/joris/vhosts/wachtrij/backend/vendor/composer/../symfony/polyfill-php80/Resources/stubs/Stringable.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
Debug::enable();

Senior Web Developer — Entrepreneur — yaymemories.com