[DeadCode] Skip Array Callable dynamic method using __CLASS__ with constructor (no default args) on RemoveUnusedPrivateMethodRector#5774
Merged
samsonasik merged 2 commits intorectorphp:mainfrom Mar 28, 2024
Conversation
…nstructor (no default args) on RemoveUnusedPrivateMethodRector
hogejiro
commented
Mar 26, 2024
| $callerType = $this->resolveClassConstFetchType($expr, $scope, $classMethodName); | ||
| if ($expr instanceof ClassConstFetch || $expr instanceof Class_) { | ||
| // class context means self|static ::class or __CLASS__ | ||
| $callerType = $this->resolveClassContextType($expr, $scope, $classMethodName); |
Contributor
Author
There was a problem hiding this comment.
(note)
I wanted to avoid using the abstract term 'context'.
But I couldn't think of a better way to express it...
hogejiro
commented
Mar 26, 2024
| @@ -0,0 +1,27 @@ | |||
| <?php | |||
Contributor
Author
There was a problem hiding this comment.
(note)
This code case showed me unexpected result.
rectorphp/rector skip
rectorphp/rector-src do not skip
- Remove the used method. ( State of commit ff0705b )
PHPUnit result
$ vendor/bin/phpunit -d --enable-pretty-print rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/RemoveUnusedPrivateMethodRectorTest.php
PHPUnit 10.5.15 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.3
Configuration: /path/to/rector-src/phpunit.xml
....................F.................. 39 / 39 (100%)
Time: 00:01.575, Memory: 90.00 MB
There was 1 failure:
1) Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\RemoveUnusedPrivateMethodRectorTest::test with data set #20 ('...')
Failed on fixture file "skip_array_callables_magic_constant_with_constructor.php.inc"
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
return $array;
}
-
- private function sort($a, $b)
- {
- return $a <=> $b;
- }
}
/path/to/rector-src/src/Testing/PHPUnit/AbstractRectorTestCase.php:248
/path/to/rector-src/src/Testing/PHPUnit/AbstractRectorTestCase.php:164
/path/to/rector-src/rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/RemoveUnusedPrivateMethodRectorTest.php:16
samsonasik
reviewed
Mar 28, 2024
Member
|
Thank you @hogejiro |
Member
|
@hogejiro it seems cause running rector on rules got error: I will take a look :) |
Member
Contributor
Author
|
@samsonasik |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix rectorphp/rector#8577