You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Property does not accept type on Level 6 but on Level 8 it's ok with Bleeding edge turn on #9096
I m using the latest currently available phpstan version 1.10.8
When I run project on Level 6 with Bleeding edge turn on property with phpdoc /** @var Option<string|null> */ throw error like this Property Test::$name (Option<string|null>) does not accept Option<string|null>. when i change it to /** @var Option<string> */ it's pass.
But next when i change Level to 8 option phpdoc with /** @var Option<string|null> */ is good one?
I found that in php-option library is some similar/connected issue about that -> schmittjoh/php-option#63 but phpstan probably shouldn't throw error on level 6 and at level 8 every things is ok?
Sadly I cannot change to level 8 😞 because this project has to many legacy errors.
The acceptedType Option<string|null> is transformed into Option<string> and then Option<string|null> does not accepts Option<string>.
I thought a smart way to fix this (and maybe other similar issue) is to use an early accepts check.
If the accepting type is already accepting the accepted type, there is nothing to transform but it doesn't work for stricter analysis which need to transform BenevolentUnionTypes into Union...
Activity
VincentLanglet commentedon Aug 1, 2025
The issue come from
https://github.com/phpstan/phpstan-src/blob/9dbff97c175250fec9dae1ab12cf0052991ce485/src/Rules/RuleLevelHelper.php#L128-L142
The acceptedType
Option<string|null>is transformed intoOption<string>and thenOption<string|null>does not acceptsOption<string>.I thought a smart way to fix this (and maybe other similar issue) is to use an early
acceptscheck.If the accepting type is already accepting the accepted type, there is nothing to transform but it doesn't work for stricter analysis which need to transform BenevolentUnionTypes into Union...
phpstan-bot commentedon Sep 10, 2026
Closed via merging phpstan/phpstan-src#6392
github-actions commentedon Oct 12, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.