Skip to content

Commit

Permalink
[Performance] Remove unused AttributeKey::ARGUMENT_POSITION (#5469)
Browse files Browse the repository at this point in the history
* [Performance] Remove unused AttributeKey::ARGUMENT_POSITION

* [Performance] Remove unused AttributeKey::ARGUMENT_POSITION
  • Loading branch information
samsonasik committed Jan 15, 2024
1 parent 2ed1e94 commit 34ab8dc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
\Rector\NodeTypeResolver\Node\AttributeKey::RAW_VALUE,
);

Expand All @@ -75,6 +74,5 @@
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
\Rector\NodeTypeResolver\Node\AttributeKey::RAW_VALUE,
);
5 changes: 0 additions & 5 deletions src/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ final class AttributeKey
*/
public const PARAMETER_POSITION = 'parameter_position';

/**
* @var string
*/
public const ARGUMENT_POSITION = 'argument_position';

/**
* @var string
*/
Expand Down
6 changes: 3 additions & 3 deletions src/NodeTypeResolver/NodeScopeAndMetadataDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PhpParser\Node\Stmt;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\CloningVisitor;
use Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamArgPositionNodeVisitor;
use Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamPositionNodeVisitor;
use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver;
use Rector\NodeTypeResolver\PHPStan\Scope\ScopeFactory;
use Rector\PhpParser\NodeTraverser\FileWithoutNamespaceNodeTraverser;
Expand All @@ -20,15 +20,15 @@ final class NodeScopeAndMetadataDecorator
public function __construct(
CloningVisitor $cloningVisitor,
private readonly PHPStanNodeScopeResolver $phpStanNodeScopeResolver,
FunctionLikeParamArgPositionNodeVisitor $functionLikeParamArgPositionNodeVisitor,
FunctionLikeParamPositionNodeVisitor $functionLikeParamPositionNodeVisitor,
private readonly ScopeFactory $scopeFactory,
private readonly FileWithoutNamespaceNodeTraverser $fileWithoutNamespaceNodeTraverser
) {
$this->nodeTraverser = new NodeTraverser();

// needed for format preserving printing
$this->nodeTraverser->addVisitor($cloningVisitor);
$this->nodeTraverser->addVisitor($functionLikeParamArgPositionNodeVisitor);
$this->nodeTraverser->addVisitor($functionLikeParamPositionNodeVisitor);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
namespace Rector\NodeTypeResolver\NodeVisitor;

use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\FunctionLike;
use PhpParser\NodeVisitorAbstract;
use Rector\NodeTypeResolver\Node\AttributeKey;

final class FunctionLikeParamArgPositionNodeVisitor extends NodeVisitorAbstract
final class FunctionLikeParamPositionNodeVisitor extends NodeVisitorAbstract
{
public function enterNode(Node $node): ?Node
{
Expand All @@ -23,12 +19,6 @@ public function enterNode(Node $node): ?Node
}
}

if ($node instanceof MethodCall || $node instanceof StaticCall || $node instanceof FuncCall || $node instanceof New_) {
foreach ($node->args as $position => $arg) {
$arg->setAttribute(AttributeKey::ARGUMENT_POSITION, $position);
}
}

return $node;
}
}

0 comments on commit 34ab8dc

Please sign in to comment.