psalm: ParseError in (ignored) vendor symfony/polyfill-mbstring/bootstrap80.php
In two symfony 4.4 projects we use PHP 7.2. After updating to the newest release 1.22.0 of symfony/polyfill-mbstring wo got the following new error after running psalm
ERROR: ParseError - vendor/symfony/polyfill-mbstring/bootstrap80.php:125:86 - Syntax error, unexpected '=' on line 125 (see https://psalm.dev/173)
function mb_scrub(string $string, string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding($string, $encoding, $encoding); }
The vendor folder itself is ignored.
While I understand this cannot be parsed by PHP 7.2, I do not understand why the PHP 8 bootstrap file is analysed at all. The only reference is in symfony packages with a PHP version check.
if (\PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}
Do I miss something or is this a problem in psalm?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 27 (3 by maintainers)
Commits related to this issue
- Skip conditional includes when registering autoload files This should allow analysis of forward-compatible polyfills used in codebases targeting older PHP versions. The following previously problema... — committed to weirdan/psalm by weirdan 3 years ago
- Skip conditional includes when registering autoload files (#4967) This should allow analysis of forward-compatible polyfills used in codebases targeting older PHP versions. The following previous... — committed to vimeo/psalm by weirdan 3 years ago
- Add PHPCS, Psalm, CI configs. Fix Psalm error https://github.com/vimeo/psalm/issues/4961 — committed to Dhii/validation-interface by XedinUnknown 3 years ago
- Downgrade symfony/polyfill-mbstring because of a PHP8 related Psalm issue https://github.com/vimeo/psalm/issues/4961 — committed to pawel-slowik/psalm-move-bug-repro by pawel-slowik 3 years ago
- Adjust mbstring polyfill for PHP 8 — committed to symfony/polyfill by derrabus 4 years ago
- Skip conditional includes when registering autoload files (#4967) This should allow analysis of forward-compatible polyfills used in codebases targeting older PHP versions. The following previous... — committed to danog/psalm by weirdan 3 years ago
- Ignore symfony polyfill in Psalm https://github.com/vimeo/psalm/issues/4961 — committed to Dhii/stringable-interface by XedinUnknown 3 years ago
- Update to Psalm v4 This resolves a bug where it would complain about parsing a file in vendor/, see https://github.com/vimeo/psalm/issues/4961 — committed to dxw/cidr by RobjS 3 years ago
- Update Psalm to resolve CI issues with symfony/polyfill-mbstring Detailed in https://github.com/vimeo/psalm/issues/4961 — committed to relayphp/Relay.Relay by kevinsmith 3 years ago
- fix version of polyfill-mbstring due to psalm bug https://github.com/vimeo/psalm/issues/4961#issuecomment-758477682 TODO remove when vimeo/psalm && webmozart/assert can be upgraded — committed to ebln/psr7-symfony1-adapter by ebln 3 years ago
- fix version of polyfill-mbstring due to psalm bug https://github.com/vimeo/psalm/issues/4961#issuecomment-758477682 TODO remove when vimeo/psalm && webmozart/assert can be upgraded — committed to ebln/psr7-symfony1-adapter by ebln 3 years ago
- Upgrade psalm to 4.x Hopefully avoids https://github.com/vimeo/psalm/issues/4961. — committed to amphp/cache by kelunik 3 years ago
- require newer psalm version We hit https://github.com/vimeo/psalm/issues/4961 otherwise — committed to mmoll/mo4-coding-standard by mmoll 3 years ago
- require newer psalm version We hit https://github.com/vimeo/psalm/issues/4961 otherwise — committed to mmoll/mo4-coding-standard by mmoll 3 years ago
- require newer psalm version We hit https://github.com/vimeo/psalm/issues/4961 otherwise — committed to mmoll/mo4-coding-standard by mmoll 3 years ago
- Upgrade Psalm to version 4 This resolves a bug where Psalm tries to check code in vendor/ See: https://github.com/vimeo/psalm/issues/4961 — committed to dxw/result by snim2 2 years ago
- Upgrade Psalm to version 4 This resolves a bug where Psalm tries to check code in vendor/ See: https://github.com/vimeo/psalm/issues/4961 — committed to dxw/result by snim2 2 years ago
- Upgrade Psalm to version 4 This resolves a bug where Psalm tries to check code in vendor/ See: https://github.com/vimeo/psalm/issues/4961 — committed to dxw/result by snim2 2 years ago
- Upgrade Psalm to version 4 This resolves a bug where Psalm tries to check code in vendor/ See: https://github.com/vimeo/psalm/issues/4961 — committed to dxw/result by snim2 2 years ago
<ignoreFiles><directory name="vendor" /></ignoreFiles>
doesn’t work in this case. I tried add ignore directly<ignoreFiles><file name="vendor/symfony/polyfill-mbstring/bootstrap80.php"</ignoreFiles>
, but it doesn’t work too. Someone tried fix this issue insymfony/polyfill-mbstring
, but looks like problem isvimeo/psalm
site. https://github.com/symfony/polyfill/pull/327@klebann you can also require
dev-master
to get the fix.I’m going to propose a PR that would avoid scanning files that are conditionally included based on
PHP_VERSION_ID
(as is the case with multiple symfony polyfills).For anyone not wanting to use the master branch of psalm, you can explicitly specify a version of
symfony/polyfill-mbstring
without the offending file:you can use
composer require --dev vimeo/psalm:master
to use directly the last commit made here. Beware of stability though, it may break at any moment and does not necessarily reflect what will be in the next release. I’d advise going back to a named release as soon as the fix is released if you can.