Skip to content

Commit 31e3a4c

Browse files
committed
[Php81] Skip as Arg value on ArrayToFirstClassCallableRector
1 parent 6a31016 commit 31e3a4c

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;
4+
5+
final class SkipAsArgValueWithCallerParamTypeArray
6+
{
7+
public function run(array $data)
8+
{
9+
}
10+
11+
public function execute()
12+
{
13+
return $this->run([$this, 'some']);
14+
}
15+
16+
public function some()
17+
{}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;
4+
5+
use Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\Source\stdClass;
6+
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;
7+
8+
return static function (stdClass $container): void {
9+
$container->services()
10+
->factory([SomeExternalObject::class, 'sleepStatic']);
11+
};

src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public function match(
7272
return null;
7373
}
7474

75+
if ($array->getAttribute(AttributeKey::IS_ARG_VALUE) === true) {
76+
return null;
77+
}
78+
7579
$values = $this->valueResolver->getValue($array);
7680
$className = $callerType->getClassName();
7781
$secondItemValue = $items[1]->value;

0 commit comments

Comments
 (0)