[DeadCode] Add RemoveNullPropertyInitializationRector to dead-code set#1880
[DeadCode] Add RemoveNullPropertyInitializationRector to dead-code set#1880TomasVotruba merged 1 commit intomasterfrom
Conversation
|
Ref #1870 |
|
Maybe this is the wrong place to ask this, but why are nulls on property declarations considered bad? I know I can remove the rector from applying if I don't like, but I was hoping to get a better understanding of why it's considered bad first. I don't typically use them, but with PHP 7.4 there is a difference between not initialized and null, so for some properties I do initialize them to null so you don't get the accessing an uninitialized field error. |
|
They're not bad at all. They're as useful as first line here: $value = [];
$value = [
$this->getSome();
]; |
|
For typed properties it's a different case, see: https://github.com/rectorphp/rector/blob/master/rules/php74/src/Rector/Property/TypedPropertyRector.php If they're in conflict and this rule breaks PHP 7.4 code, please open an issue. That's a bug. |
rectorphp/rector-src@2604c76 Fixing rules return values (take 2) (#1880)
(before
RemoveDeadInitializationRector)