-
-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle throw after if on ConsecutiveNullCompareReturnsT…
…oNullCoalesceQueueRector (#4107) * [CodeQuality] Handle throw after if on ConsecutiveNullCompareReturnsToNullCoalesceQueueRector * Fixed 🎉 * skip instead * clean up * Use throw expr * [ci-review] Rector Rectify * ensure has index removed before removal * Fix phsptan * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
71dc336
commit 63816c0
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...If_/ConsecutiveNullCompareReturnsToNullCoalesceQueueRector/Fixture/throw_after_if.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,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector\Fixture; | ||
|
||
final class ThrowAfterIf | ||
{ | ||
protected ?\stdClass $prop1 = null; | ||
protected ?\stdClass $prop2 = null; | ||
|
||
public function getProp(): \stdClass | ||
{ | ||
if ($this->prop1 !== null) { | ||
return $this->prop1; | ||
} | ||
if ($this->prop2 !== null) { | ||
return $this->prop2; | ||
} | ||
throw new \RuntimeException('No prop is set'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector\Fixture; | ||
|
||
final class ThrowAfterIf | ||
{ | ||
protected ?\stdClass $prop1 = null; | ||
protected ?\stdClass $prop2 = null; | ||
|
||
public function getProp(): \stdClass | ||
{ | ||
return ($this->prop1 ?? $this->prop2) ?? throw new \RuntimeException('No prop is set'); | ||
} | ||
} | ||
|
||
?> |
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