Skip to content

Commit 153312c

Browse files
authored
[CodeQuality] Do not use FullyQualified on "self" on WithCallbackIdenticalToStandaloneAssertsRector (#587)
* [CodeQuality] Do not use FullyQualified on "self" on WithCallbackIdenticalToStandaloneAssertsRector * fix
1 parent 501b76b commit 153312c

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector\Fixture;
6+
7+
use PHPUnit\Framework\TestCase;
8+
9+
final class OnSelf extends TestCase
10+
{
11+
public function test()
12+
{
13+
$someMock = $this->getMockBuilder('AnyType')->getMock();
14+
15+
$someMock->expects($this->any())
16+
->method('trans')
17+
->with($this->callback(fn ($arg) => $arg instanceof self && $arg->isReady()));
18+
}
19+
}
20+
21+
?>
22+
-----
23+
<?php
24+
25+
declare(strict_types=1);
26+
27+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector\Fixture;
28+
29+
use PHPUnit\Framework\TestCase;
30+
31+
final class OnSelf extends TestCase
32+
{
33+
public function test()
34+
{
35+
$someMock = $this->getMockBuilder('AnyType')->getMock();
36+
37+
$someMock->expects($this->any())
38+
->method('trans')
39+
->with($this->callback(function ($arg): bool {
40+
$this->assertInstanceOf(self::class, $arg);
41+
$this->assertTrue($arg->isReady());
42+
return true;
43+
}));
44+
}
45+
}
46+
47+
?>

rules/CodeQuality/NodeFactory/FromBinaryAndAssertExpressionsFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ public function create(array $exprs): array
7878
}
7979

8080
if ($expr instanceof Instanceof_) {
81-
if ($expr->class instanceof Name) {
81+
if ($expr->class instanceof FullyQualified) {
8282
$classNameExpr = new ClassConstFetch(new FullyQualified($expr->class->name), 'class');
83+
} elseif ($expr->class instanceof Name) {
84+
$classNameExpr = new ClassConstFetch(new Name($expr->class->name), 'class');
8385
} else {
8486
$classNameExpr = $expr->class;
8587
}

0 commit comments

Comments
 (0)