Fix phpstan magento2 narrowed type#4243
Merged
antonmedv merged 2 commits intoJul 13, 2026
Merged
Conversation
added 2 commits
July 13, 2026 15:01
The @phpstan-param docblock narrowed $area to 'frontend'|'backend', making the runtime in_array() guard always true according to phpstan 2.2.3. The runtime check is intentional since callers can pass any string, so drop the docblock narrowing instead of the check.
dominik-matic
approved these changes
Jul 13, 2026
antonmedv
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
phpstan 2.2.3 (released June 30) extended the
alreadyNarrowedTypecheck to flag always-truein_array(..., true)calls when the needle is a finite union fully covered by the haystack. Since CI installs the latest phpstan on every run (nocomposer.lock), master now fails thecheckworkflow - and so does every PR branched from it, even without touching the affected code (example run).The offender is
magentoDeployAssetsSplit()inrecipe/magento2.php: the@phpstan-param 'frontend'|'backend' $areadocblock narrows the needle so the runtimein_array()guard looks always true. But callers can pass any string, so the guard is the part worth keeping - this PR drops the docblock narrowing instead. SettingtreatPhpDocTypesAsCertain: falsewould also silence it, but that changes analysis repo-wide for one false positive.Bug fix #…?
New feature?
BC breaks?
Tests added?
Docs added?