Skip to content

Commit 20b2479

Browse files
committed
fix #9493
1 parent 8e15aad commit 20b2479

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

rules-tests/CodingStyle/Rector/FuncCall/ClosureFromCallableToFirstClassCallableRector/Fixture/class_callable_array.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use Closure;
2323
\SomeClass::staticMethod(...);
2424
\Foo\SomeClass::staticMethod(...);
2525

26-
\Rector\Tests\CodingStyle\Rector\FuncCall\ClosureFromCallableToFirstClassCallableRector\Fixture\SomeClass::staticMethod(...);
27-
\SomeNamespace\Foo\SomeClass::staticMethod(...);
26+
Rector\Tests\CodingStyle\Rector\FuncCall\ClosureFromCallableToFirstClassCallableRector\Fixture\SomeClass::staticMethod(...);
27+
SomeNamespace\Foo\SomeClass::staticMethod(...);
2828

2929
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
class Foo
4+
{
5+
public static function bar(): void
6+
{
7+
set_exception_handler(Closure::fromCallable([self::class, 'baz']));
8+
}
9+
10+
public static function baz(): void
11+
{
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
class Foo
20+
{
21+
public static function bar(): void
22+
{
23+
set_exception_handler(self::baz(...));
24+
}
25+
26+
public static function baz(): void
27+
{
28+
}
29+
}
30+
31+
?>

rules/CodingStyle/Rector/FuncCall/ClosureFromCallableToFirstClassCallableRector.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ public function refactor(Node $node): ?Node
9797
return null;
9898
}
9999

100-
$classNode = new FullyQualified($array->items[0]->value->class->name);
100+
if ($array->items[0]->value->class instanceof Name) {
101+
$classNode = new Name($array->items[0]->value->class->name);
102+
} else {
103+
$classNode = new FullyQualified($array->items[0]->value->class->name);
104+
}
105+
101106
} elseif ($array->items[0]->value instanceof FullyQualified) {
102107
$classNode = new FullyQualified($array->items[0]->value->name);
103108
} else {

0 commit comments

Comments
 (0)