Skip to content

Commit 08149e6

Browse files
authored
Revert "[Downgrade][Php81][Php80] Handle nullable downgrade initialization on…" (#244)
This reverts commit 590e1ba.
1 parent 590e1ba commit 08149e6

File tree

6 files changed

+6
-76
lines changed

6 files changed

+6
-76
lines changed

rules-tests/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector/Fixture/new_not_promoted.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ final class NewNotPromoted
2222
{
2323
public stdClass $obj;
2424

25-
public function __construct(?stdClass $obj = null)
25+
public function __construct(stdClass $obj = null)
2626
{
27-
$this->obj = $obj ?? new stdClass;
27+
$obj ??= new stdClass;
2828
$this->obj = $obj;
2929
}
3030
}

rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ private function replaceNewInParams(ClassMethod|Closure|Function_ $functionLike)
162162
/** @var Variable $paramVar */
163163
$paramVar = $param->var;
164164

165-
if ($isConstructor) {
165+
// check for property promotion
166+
if ($isConstructor && $param->flags > 0) {
166167
$propertyFetch = new PropertyFetch(new Variable('this'), $paramVar->name);
167168
$coalesce = new Coalesce($param->var, $default);
168169
$assign = new Assign($propertyFetch, $coalesce);

tests/Issues/DowngradeNewInArrayInitializerPromotion/Fixture/new_in_array.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class NewInArray
3333
/**
3434
* @param array<string, object> $property
3535
*/
36-
public function __construct(?array $property = null)
36+
public function __construct(array $property = null)
3737
{
38-
$this->property = $property ?? [
38+
$property ??= [
3939
'a' => new stdClass()
4040
];
4141
$this->property = $property;

tests/Issues/DowngradeNullableInitialization/DowngradeNullableInitializationTest.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/Issues/DowngradeNullableInitialization/Fixture/add_nullable_initialization.php.inc

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/Issues/DowngradeNullableInitialization/config/configured_rule.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)