Skip to content

Remove NullToStrictStringFuncCallArgRector from the PHP 8.1 set - #8234

Merged
TomasVotruba merged 2 commits into
mainfrom
remove-null-to-strict-string-from-php81-set
Jul 30, 2026
Merged

Remove NullToStrictStringFuncCallArgRector from the PHP 8.1 set#8234
TomasVotruba merged 2 commits into
mainfrom
remove-null-to-strict-string-from-php81-set

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

NullToStrictStringFuncCallArgRector fires on a lot of call sites, and in practice it is commonly skipped rather than applied — so in the set it mostly generates withSkip() entries.

 return static function (RectorConfig $rectorConfig): void {
     $rectorConfig->rules([
         ...
         SpatieEnumMethodCallToEnumConstRector::class,
-        NullToStrictStringFuncCallArgRector::class,
         NullToStrictIntPregSlitFuncCallLimitArgRector::class,

The rule and its 39 fixtures stay in place, so anyone who wants it can still opt in:

->withRules([NullToStrictStringFuncCallArgRector::class])

Two things worth deciding on before merge

1. withPhpLevel() positions shift. withPhpLevel(N) takes the first N + 1 rules in set-file order, so removing an entry from php81.php shifts every later rule down by one. A config pinned at a given level will silently pick up whichever rule previously sat just past its cutoff. That is inherent to level-as-array-prefix and not specific to this rule, but it does mean this is not a no-op for level users.

2. It still covers a real 8.1 deprecation. Passing null to a non-nullable internal function parameter is deprecated in 8.1, so dropping it from the set means an upgrade run no longer flags those call sites at all. If the goal is "stop applying it by default" rather than "stop offering it", an alternative is to leave it in the set but let it be skipped more easily — happy to switch to that if you prefer.

I went with the straight removal since that is what was asked for.

Checks

ECS and PHPStan clean. The rule's own test suite still passes (39 tests) — nothing about the rule changed, only its set membership. Full suite matches the pre-existing baseline on main.

The rule fires on a lot of call sites and is commonly skipped, so it costs more
in withSkip() noise than it pays back when applied automatically.

The rule itself and its 39 fixtures stay, so anyone who wants it can register it
directly with withRules().
@TomasVotruba
TomasVotruba enabled auto-merge (squash) July 30, 2026 21:24
rector.upgradeDowngradeRegisteredInSet requires every Php8x rule to be listed in
its matching config set. Keeping this rule out of php81.php is deliberate, so
scope the ignore to that one file rather than relaxing the rule.
@TomasVotruba
TomasVotruba merged commit fb1218d into main Jul 30, 2026
65 checks passed
@TomasVotruba
TomasVotruba deleted the remove-null-to-strict-string-from-php81-set branch July 30, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant