[remove] Remove deprecated NewInInitializerRector - #8328
Merged
Conversation
Deprecated since 2026-04 in #7913. The rewrite is not equivalent: a promoted default only applies when the argument is omitted, so an explicit null argument lands as null instead of the coalesced fallback object.
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.
Removes
NewInInitializerRector, deprecated since 2026-04 in #7913. Follows the same cleanup as #8094.The rule collapsed an optional dependency into a promoted property with a
newdefault:class SomeClass { - private Logger $logger; - public function __construct( - ?Logger $logger = null, + private ?Logger $logger = new NullLogger, ) { - $this->logger = $logger ?? new NullLogger; } }The two forms are not equivalent. A default value applies only when the argument is omitted, so an explicit
nullstill lands asnull:The property could never hold null before and can now, and Rector cannot see whether any caller passes
nullexplicitly. That is the "depends on context" from the original deprecation.It took six rounds of edge-case patching before it was given up on: #1737, #1740, #5971, #6599, #7545, #7546.
The rule was in no set and its tests were already removed with the deprecation, so this only drops the class plus its two now-obsolete
phpstan.neonignore entries.