-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Remove RectifiedNode value object for RectifiedAnalyzer (#3079)
* [Core] Remove RectifiedNode value object for RectifiedAnalyzer * clean up * Final touch: apply @var class-string<RectorInterface>[] and @param class-string<RectorInterface> for created by rule attribute * Really Final touch: handle consecutive return null; with phpstan cache printer exists * Really Really Final touch: early create by rule, no need to loop when $node === $originalNode * Really Really Final touch: clean up: re-use if * Really Final touch: different if to easiser to read * Final touch: better method name * Final touch: Move comment to method, more description for future note * Really final touch: clarify comment * Really Really Really final touch: verify comment * Really Final touch: remove unnecessary array_key_first and array_key_last * Final touch: phpstan_cache_printer attribute is always on Expr Node * Final touch: Fix range line can be -1 on if Next Node moved up * Final touch: comment * Final touch: comment * [ci-review] Rector Rectify * Final touch: clean up * Final touch: clean up * only verify against Expr * final touch: decorate the Node as well * Finally: Real solution, immediate connect existing Node after refactor * Really Really Really Final touch: Fix PHPStan notice * Final touch: remove unrelated change * Final touch: clean up unrelated change * Final touch: test to prove that existing addNodeBeforeNode() usage keep working * add test for fixture for keep working with addNodeAfterNode() on Next Stmt * Final touch: better fixture content * [ci-review] Rector Rectify Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
23c2282
commit eddc376
Showing
9 changed files
with
195 additions
and
106 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...tor/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/has_prev_next_stmt.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,26 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector\Fixture; | ||
|
||
function hasPrevNextStmt() | ||
{ | ||
echo 'prev stmt'; | ||
reset($var = []); | ||
echo 'next stmt'; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector\Fixture; | ||
|
||
function hasPrevNextStmt() | ||
{ | ||
echo 'prev stmt'; | ||
$var = []; | ||
reset($var); | ||
echo 'next stmt'; | ||
} | ||
|
||
?> |
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
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
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
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNodeStmtTest.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\AddNodeAfterNodeStmt; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class AddNodeAfterNodeStmtTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.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,32 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AddNodeAfterNodeStmt\Fixture; | ||
|
||
final class Fixture | ||
{ | ||
public function run() | ||
{ | ||
if ($a === 1) { | ||
} | ||
echo 'existing next stmt after if'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AddNodeAfterNodeStmt\Fixture; | ||
|
||
final class Fixture | ||
{ | ||
public function run() | ||
{ | ||
if ($a === 1) { | ||
} | ||
echo 'this is new stmt after if'; | ||
echo 'existing next stmt after if'; | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.