-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support NullSafeProperty fetches in unused-code analysis (#5839)
* Support NullSafeProperty fetches in unused-code analysis * fix build
- Loading branch information
Showing
6 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
.../Rector/Property/RemoveUnusedPrivatePropertyRector/Fixture/skip_nullsafe_property.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
final class SkipNullSafePropertyFetch | ||
{ | ||
private $myProp; | ||
|
||
public function pubMethod() { | ||
echo $this->getX()?->myProp; | ||
} | ||
|
||
public function getX(): SkipNullSafePropertyFetch|null { | ||
return rand(0,1) ? new SkipNullSafePropertyFetch() : null; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ode/Rector/Property/RemoveUnusedPrivatePropertyRector/Fixture/skip_other_property.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
final class SkipPrivateOtherProperty | ||
{ | ||
private $myProp; | ||
|
||
public function pubMethod() { | ||
echo $this->getX()->myProp; | ||
} | ||
|
||
public function getX(): self { | ||
return new self(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...or/Property/RemoveUnusedPrivatePropertyRector/Fixture/skip_self_nullsafe_property.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
final class SkipNullSafeSelfPropertyFetch | ||
{ | ||
private $myProp; | ||
|
||
public function pubMethod() { | ||
echo $this->getX()?->myProp; | ||
} | ||
|
||
public function getX(): self|null { | ||
return rand(0,1) ? new self() : null; | ||
} | ||
} |
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