-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHPStan ^2.1.1] Handle next unreachable statement via UnreachableSta…
…tementNode->getNextUnreachableStatements() (#6642) * [PHPStan 2.1.x-dev] Handle next unreachable statement via UnreachableStatementNode->getNextUnreachableStatements() * [PHPStan 2.1.x-dev] Handle next unreachable statement via UnreachableStatementNode->getNextUnreachableStatements() * temporary use composer update on packages_tests * temporary use composer update on packages_tests * temporary use composer update on packages_tests * rollback * fix test * fix * add more fixture * more fixture * fix * [ci-review] Rector Rectify * remove unused flag IS_UNREACHABLE attribute * add unreachable statement test on UnnecessaryTernaryExpressionRector * add unreachable statement test on UnnecessaryTernaryExpressionRector * fixture name conflict fix --------- Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
92b4999
commit 2e82ab4
Showing
9 changed files
with
207 additions
and
88 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
...ity/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.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,59 @@ | ||
<?php | ||
|
||
if (true) { | ||
return; | ||
} | ||
|
||
echo 'test'; | ||
|
||
class FixtureUnreachableA | ||
{ | ||
public function run($order, $oldOrder) | ||
{ | ||
return $order || $oldOrder ? true : false; | ||
} | ||
} | ||
|
||
$order || $oldOrder ? true : false; | ||
|
||
class FixtureUnreachableB | ||
{ | ||
public function run($order, $oldOrder) | ||
{ | ||
return $order || $oldOrder ? true : false; | ||
} | ||
} | ||
|
||
$order || $oldOrder ? true : false; | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
if (true) { | ||
return; | ||
} | ||
|
||
echo 'test'; | ||
|
||
class FixtureUnreachableA | ||
{ | ||
public function run($order, $oldOrder) | ||
{ | ||
return $order || $oldOrder; | ||
} | ||
} | ||
|
||
$order || $oldOrder; | ||
|
||
class FixtureUnreachableB | ||
{ | ||
public function run($order, $oldOrder) | ||
{ | ||
return $order || $oldOrder; | ||
} | ||
} | ||
|
||
$order || $oldOrder; | ||
|
||
?> |
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
64 changes: 0 additions & 64 deletions
64
src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php
This file was deleted.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
...e/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
class NonExactValueAfterUnreachableStmts | ||
{ | ||
/** | ||
* @param 'foo' $foo | ||
*/ | ||
public static function run($foo) | ||
{ | ||
if ($foo === 'foo') { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
echo(json_encode($foo)); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
class NonExactValueAfterUnreachableStmts | ||
{ | ||
/** | ||
* @param 'foo' $foo | ||
*/ | ||
public static function run($foo) | ||
{ | ||
if ($foo === 'foo') { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
echo(json_encode($foo, JSON_THROW_ON_ERROR)); | ||
} | ||
} | ||
|
||
?> |
51 changes: 51 additions & 0 deletions
51
.../FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts2.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,51 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
class NonExactValueAfterUnreachableStmts | ||
{ | ||
/** | ||
* @param 'foo' $foo | ||
*/ | ||
public static function run($foo) | ||
{ | ||
if ($foo === 'foo') { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
|
||
function foo($foo) { | ||
echo(json_encode($foo)); | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
class NonExactValueAfterUnreachableStmts | ||
{ | ||
/** | ||
* @param 'foo' $foo | ||
*/ | ||
public static function run($foo) | ||
{ | ||
if ($foo === 'foo') { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
|
||
function foo($foo) { | ||
echo(json_encode($foo, JSON_THROW_ON_ERROR)); | ||
} | ||
} | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
...ThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts_on_top_level.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,33 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
if (true) { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
|
||
function foo($foo) { | ||
echo(json_encode($foo)); | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureJsonThrowCaseSensitiveConstFetch; | ||
|
||
if (true) { | ||
return; | ||
} | ||
|
||
echo 'some statement 1'; | ||
echo 'some statement 2'; | ||
|
||
function foo($foo) { | ||
echo(json_encode($foo, JSON_THROW_ON_ERROR)); | ||
} | ||
|
||
?> |