Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Skip global and static variable on RemoveJustVariableAssig…
…nRector (#2641) * [DeadCode] Skip global var on RemoveJustVariableAssignRector * update * skip static as well * skip static as well * skip static as well * s * Fixed 🎉 * eol
- Loading branch information
1 parent
b67bf64
commit bf92b9c
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...Rector/StmtsAwareInterface/RemoveJustVariableAssignRector/Fixture/skip_global_var.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,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\StmtsAwareInterface\RemoveJustVariableAssignRector\Fixture; | ||
|
||
$result = 1; | ||
|
||
function run() | ||
{ | ||
global $result; | ||
$result = 100; | ||
|
||
$temporaryValue = $result; | ||
} |
18 changes: 18 additions & 0 deletions
18
...Rector/StmtsAwareInterface/RemoveJustVariableAssignRector/Fixture/skip_static_var.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,18 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\StmtsAwareInterface\RemoveJustVariableAssignRector\Fixture; | ||
|
||
class SkipStaticVar | ||
{ | ||
private $property; | ||
|
||
function init($value) | ||
{ | ||
static $result = null; | ||
|
||
if (! isset($result)) { | ||
$result = $value; | ||
$this->property = $result; | ||
} | ||
} | ||
} |
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