-
-
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.
[CodeQuality] Skip method call on else on TernaryFalseExpressionToIfR…
…ector (#5373) * [CodeQuality] Skip method call on else on TernaryFalseExpressionToIfRector * Fixed 🎉 * add assign in else * add else check * use both * fix
- Loading branch information
1 parent
02a30d4
commit 4283bef
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ctor/Expression/TernaryFalseExpressionToIfRector/Fixture/skip_method_call_on_else.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Expression\TernaryFalseExpressionToIfRector\Fixture; | ||
|
||
final class SkipMethodCallOnElse | ||
{ | ||
public function run(bool $param): void | ||
{ | ||
$param ? $this->a() : $this->b(); | ||
} | ||
|
||
public function a(): void | ||
{ | ||
new HeavyObject1(); | ||
} | ||
|
||
public function b(): null | ||
{ | ||
new HeavyObject2(); | ||
return 'b'; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ion/TernaryFalseExpressionToIfRector/Fixture/skip_method_call_with_assign_on_else.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Expression\TernaryFalseExpressionToIfRector\Fixture; | ||
|
||
final class SkipMethodCallWithAssignOnElse | ||
{ | ||
public function run(bool $param): void | ||
{ | ||
$param ? $this->a() : $x = $this->b(); | ||
} | ||
|
||
public function a(): void | ||
{ | ||
new HeavyObject1(); | ||
} | ||
|
||
public function b(): null | ||
{ | ||
new HeavyObject2(); | ||
return 'b'; | ||
} | ||
} |
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