-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Handle anonymous and arrow function uses in RemoveJustProp…
…ertyFetchRector (#2592) * Add failing test cases for rectorphp/rector#7263 * Fix phpstan crash rectorphp/rector#7263 * Fix testcase * Skip usages in anonymous static functions * Remove no longer needed closure uses * Add arrow functions to test cases * Add arrow functions to test cases * Don't throw exceptions * Fix phpstan and code style * Import used classes * Remove work-around * Remove phpstan error ignore * Remove unused import
- Loading branch information
1 parent
09df9d0
commit 82b2467
Showing
3 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...rface/RemoveJustPropertyFetchRector/Fixture/skip_use_in_static_anonymous_function.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\RemoveJustPropertyFetchRector\Fixture; | ||
|
||
final class SkipUseInStaticFunction | ||
{ | ||
private $id; | ||
|
||
public function run() | ||
{ | ||
$id = $this->id; | ||
|
||
static function () use ($id) { | ||
$id(); | ||
}; | ||
static fn () => $id(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...mtsAwareInterface/RemoveJustPropertyFetchRector/Fixture/use_in_anonymous_function.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\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchRector\Fixture; | ||
|
||
final class SkipUseInStaticFunction | ||
{ | ||
private $id; | ||
|
||
public function run() | ||
{ | ||
$id = $this->id; | ||
|
||
function () use ($id) { | ||
$id(); | ||
}; | ||
fn () => $id(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchRector\Fixture; | ||
|
||
final class SkipUseInStaticFunction | ||
{ | ||
private $id; | ||
|
||
public function run() | ||
{ | ||
function () { | ||
($this->id)(); | ||
}; | ||
fn () => ($this->id)(); | ||
} | ||
} | ||
|
||
?> |
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