mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-21 02:23:09 +00:00
Add not refactorable testCases; clearify recursion
This commit is contained in:
parent
0196d1efee
commit
3f509a2dd4
|
@ -84,7 +84,11 @@ PHP
|
|||
return null;
|
||||
}
|
||||
|
||||
$if = $this->refactor($if) ?? $if;
|
||||
$refactored = $this->refactor($if);
|
||||
|
||||
if ($refactored) {
|
||||
$if = $refactored;
|
||||
}
|
||||
|
||||
$node->elseifs[] = new ElseIf_(
|
||||
$if->cond,
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\If_\ShortenElseIfRector\Fixture;
|
||||
|
||||
class MultipleStmtsClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond1;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond2;
|
||||
|
||||
public function run()
|
||||
{
|
||||
if ($this->cond1) {
|
||||
$this->doSomething();
|
||||
} else {
|
||||
if ($this->cond2) {
|
||||
$this->doSomething();
|
||||
}
|
||||
$this->doSomething();
|
||||
}
|
||||
}
|
||||
|
||||
public function doSomething()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\If_\ShortenElseIfRector\Fixture;
|
||||
|
||||
class MultipleStmtsClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond1;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond2;
|
||||
|
||||
public function run()
|
||||
{
|
||||
if ($this->cond1) {
|
||||
$this->doSomething();
|
||||
} else {
|
||||
if ($this->cond2) {
|
||||
$this->doSomething();
|
||||
}
|
||||
$this->doSomething();
|
||||
}
|
||||
}
|
||||
|
||||
public function doSomething()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\If_\ShortenElseIfRector\Fixture;
|
||||
|
||||
class NoElseIfClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond1;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond2;
|
||||
|
||||
public function run()
|
||||
{
|
||||
if ($this->cond1) {
|
||||
$this->doSomething();
|
||||
} else {
|
||||
$this->doSomething();
|
||||
}
|
||||
}
|
||||
|
||||
public function doSomething()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\If_\ShortenElseIfRector\Fixture;
|
||||
|
||||
class NoElseIfClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond1;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $cond2;
|
||||
|
||||
public function run()
|
||||
{
|
||||
if ($this->cond1) {
|
||||
$this->doSomething();
|
||||
} else {
|
||||
$this->doSomething();
|
||||
}
|
||||
}
|
||||
|
||||
public function doSomething()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -22,6 +22,8 @@ final class ShortenElseIfRectorTest extends AbstractRectorTestCase
|
|||
yield [__DIR__ . '/Fixture/nested-else.php.inc'];
|
||||
yield [__DIR__ . '/Fixture/nested-elseif.php.inc'];
|
||||
yield [__DIR__ . '/Fixture/recursive.php.inc'];
|
||||
yield [__DIR__ . '/Fixture/no-else-if.php.inc'];
|
||||
yield [__DIR__ . '/Fixture/multiple-stmts.php.inc'];
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
|
|
Loading…
Reference in New Issue
Block a user