Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use ReflectionMethod;

class SkipInReflectionMethodAsArgumentUnpack
{
function methodInjection()
{}

public function get()
{
return new ReflectionMethod(...[$this, 'methodInjection']);
}
}
4 changes: 4 additions & 0 deletions rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public function refactor(Node $node): StaticCall|MethodCall|null
return null;
}

if ($node->getAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE)) {
return null;
}

$args = [new VariadicPlaceholder()];
if ($callerExpr instanceof ClassConstFetch) {
$type = $this->getType($callerExpr->class);
Expand Down
2 changes: 2 additions & 0 deletions src/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ final class AttributeKey

public const string IS_ARG_VALUE = 'is_arg_value';

public const string IS_UNPACKED_ARG_VALUE = 'is_unpacked_arg_value';

public const string IS_PARAM_VAR = 'is_param_var';

public const string IS_PARAM_DEFAULT = 'is_param_default';
Expand Down
4 changes: 4 additions & 0 deletions src/PhpParser/NodeVisitor/ContextNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public function enterNode(Node $node): ?Node

if ($node instanceof Arg) {
$node->value->setAttribute(AttributeKey::IS_ARG_VALUE, true);
if ($node->unpack) {
$node->value->setAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE, true);
}

return null;
}

Expand Down
Loading