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
Incorrect behaviour of MatchAssertSameExpectedTypeRector (rector-phpunit) #9857
The rule ships in PHPUnitSetList::PHPUNIT_NARROW_ASSERTS and PHPUnitSetList::PHPUNIT_CODE_QUALITY, which is applied set-wide, and the failure mode is a green suite turning red with an assertion that looks deliberate (Failed asserting that 100 is identical to '100'). It silently broke 4 tests across 4 files in our codebase.
PHPStan memoizes the narrowing against the call expression, and the next, possibly-impure setTypeId() does not invalidate it (rememberPossiblyImpureFunctionValues, on by default). So getNativeType() answers string, isString()->yes() passes, and the literal is rewritten. The declared type int|string|null would have answered maybe and correctly bailed.
The single preceding assertSame() is the entire trigger, so a byte-identical assertion in a method without it is left alone.
Activity
TomasVotruba commentedon Aug 20, 2026
Thank you for reporting and the fix 👍
Closed in #9857