-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DeadCode] Skip clone and new self on RemoveUnusedPrivatePropertyRector #1215
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f7d9ae0
[DeadCode] Skip clone and new self on RemoveUnusedPrivatePropertyRector
samsonasik 6b2b205
more example
samsonasik 94000e3
extract
samsonasik 3bd9c91
extract
samsonasik 089d5ff
Fixed :tada:
samsonasik 2ef2517
reduce complexity
samsonasik 8e3bd1a
phpstan
samsonasik 97787b9
final touch: clean up
samsonasik 8dd06d2
final touch: clean up
samsonasik 098b6c7
final touch: cleanup
samsonasik 12bf694
move check to ForbiddenPropertyRemovalAnalyzer service
samsonasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...r/Property/RemoveUnusedPrivatePropertyRector/Fixture/sip_new_same_classname_usage.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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
class SkipNewSameClassNameUsage | ||
{ | ||
private $var; | ||
|
||
public function __construct($var) | ||
{ | ||
$this->var = $var; | ||
} | ||
|
||
public function run($var) | ||
{ | ||
$obj = new SkipNewSameClassNameUsage($var); | ||
echo $obj->var; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...adCode/Rector/Property/RemoveUnusedPrivatePropertyRector/Fixture/skip_clone_usage.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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
class SkipCloneUsage | ||
{ | ||
private $var; | ||
|
||
public function __construct($var) | ||
{ | ||
$this->var = $var; | ||
} | ||
|
||
public function run() | ||
{ | ||
$obj = clone $this; | ||
echo $obj->var; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ode/Rector/Property/RemoveUnusedPrivatePropertyRector/Fixture/skip_new_self_usage.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture; | ||
|
||
class SkipNewSelfUsage | ||
{ | ||
private $var; | ||
private static $var2; | ||
|
||
public function __construct($var, $var2) | ||
{ | ||
$this->var = $var; | ||
self::$var2 = $var2; | ||
} | ||
|
||
public function run() | ||
{ | ||
$obj = new self('a', 'b'); | ||
echo $obj->var; | ||
echo $obj::$var2; | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract this to own service? The logic seems quite complex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented, I moved to new service
ForbiddenPropertyRemovalAnalyzer
12bf694