-
-
Notifications
You must be signed in to change notification settings - Fork 417
[dead-code] Add RemoveUnusedClosureVariableUseRector #7430
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
Conversation
| continue; | ||
| } | ||
|
|
||
| $isUseUsed = (bool) $this->betterNodeFinder->findVariableOfName($node->stmts, $useVariableName); |
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.
this should verify compact use as well, better use ExprUsedInNodeAnalyzer for it, I will create new PR for it.
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.
I created new PR to skip used via compact()
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\DeadCode\Rector\Concat; |
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.
this should under Closure namespace:
-namespace Rector\DeadCode\Rector\Concat;
+namespace Rector\DeadCode\Rector\Closure;I will create new PR for it.
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.
I create new PR to fix namespace to Closure
| // reset keys, to keep as expected | ||
| $node->uses = array_values($node->uses); |
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.
this is not needed, already covered at NodeAttributeReIndexer, see
rector-src/src/Application/NodeAttributeReIndexer.php
Lines 69 to 71 in d948383
| if ($node instanceof Closure) { | |
| $node->uses = array_values($node->uses); | |
| } |
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.
I created new PR for it:
Reported by PHPStan, now fixed by Rector 👍
class Fixture { public function run($value) { - return function () use ($value) { + return function () { return 'value'; }; } }