-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php81] Skip static call in right expr of Coalesce on NewInInitialize…
…rRector (#1670) * [Php81] Skip static call on NewInInitializerRector * Fixed 🎉 * final touch: restructure fixtures * final touch: eol * use not instanceof New_ check
- Loading branch information
1 parent
6ea0032
commit c931954
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...lassMethod/NewInInitializerRector/Fixture/skip_static_call_null_coalesce_operator.php.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\Fixture; | ||
|
||
use Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\Source\InstantiableViaNamedConstructor; | ||
|
||
final class SkipStaticCallNullCoalesceOperator | ||
{ | ||
public function __construct(private ?InstantiableViaNamedConstructor $foo = null) | ||
{ | ||
$this->foo ??= InstantiableViaNamedConstructor::make(100); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...Rector/ClassMethod/NewInInitializerRector/Fixture/skip_static_call_right_coalesce.php.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\Fixture; | ||
|
||
use Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\Source\InstantiableViaNamedConstructor; | ||
|
||
final class SkipStaticCallRightCoalesce | ||
{ | ||
private InstantiableViaNamedConstructor $foo; | ||
|
||
public function __construct(?InstantiableViaNamedConstructor $foo = null) | ||
{ | ||
$this->foo = $foo ?? InstantiableViaNamedConstructor::make(100); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...hp81/Rector/ClassMethod/NewInInitializerRector/Source/InstantiableViaNamedConstructor.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\Source; | ||
|
||
final class InstantiableViaNamedConstructor | ||
{ | ||
public static function make(int $value): InstantiableViaNamedConstructor | ||
{ | ||
return new InstantiableViaNamedConstructor($value); | ||
} | ||
|
||
public function __construct(public int $value) | ||
{ | ||
} | ||
} |
This file contains 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