Skip to content

Commit bdc4ec8

Browse files
authored
[CodeQuality] fix assertInstanceOf casing (#471)
* [CodeQuality] fix assertInstanceOf casing * fix tests
1 parent 67632c0 commit bdc4ec8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

rules-tests/CodeQuality/Rector/ClassMethod/AddInstanceofAssertForNullableInstanceRector/Fixture/add_instance_only_once.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class AddInstanceOnlyOnce extends TestCase
4646
public function test(): void
4747
{
4848
$someObject = $this->getSomeObject();
49-
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
49+
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
5050
$value = $someObject->getSomeMethod();
5151

5252
$this->assertSame(123, $value);

rules-tests/CodeQuality/Rector/ClassMethod/AddInstanceofAssertForNullableInstanceRector/Fixture/call_on_nullable.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class CallOnNullable extends TestCase
4343
public function test(): void
4444
{
4545
$someObject = $this->getSomeObject();
46-
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
46+
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
4747
$value = $someObject->getSomeMethod();
4848

4949
$this->assertSame(123, $value);

rules-tests/CodeQuality/Rector/ClassMethod/AddInstanceofAssertForNullableInstanceRector/Fixture/multiple_assert.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ final class MultipleAssert extends TestCase
5757
public function test(): void
5858
{
5959
$someObject = $this->getSomeObject();
60-
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
60+
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
6161
$value = $someObject->getSomeMethod();
6262

6363
$this->assertSame(123, $value);
6464

6565
$someObject2 = $this->getSomeObject2();
66-
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject2);
66+
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject2);
6767
$value2 = $someObject2->getSomeMethod();
6868

6969
$this->assertSame(123, $value2);

rules/CodeQuality/Rector/ClassMethod/AddInstanceofAssertForNullableInstanceRector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ final class SomeTest extends TestCase
7474
public function test()
7575
{
7676
$someObject = $this->getSomeObject();
77-
$this->assertInstanceof(SomeClass::class, $someObject);
77+
$this->assertInstanceOf(SomeClass::class, $someObject);
7878
7979
$value = $someObject->getSomeMethod();
8080
}
@@ -130,8 +130,8 @@ public function refactor(Node $node): ?Node
130130
}
131131

132132
// adding type here + popping the variable name out
133-
$assertInstanceofExpression = $this->createAssertInstanceof($matchedNullableVariableNameToType);
134-
array_splice($node->stmts, $key + $next, 0, [$assertInstanceofExpression]);
133+
$assertInstanceOfExpression = $this->createAssertInstanceOf($matchedNullableVariableNameToType);
134+
array_splice($node->stmts, $key + $next, 0, [$assertInstanceOfExpression]);
135135

136136
// remove variable name from nullable ones
137137
$hasChanged = true;
@@ -162,14 +162,14 @@ private function isNullableType(Type $type): bool
162162
return count($type->getTypes()) === 2;
163163
}
164164

165-
private function createAssertInstanceof(VariableNameToType $variableNameToType): Expression
165+
private function createAssertInstanceOf(VariableNameToType $variableNameToType): Expression
166166
{
167167
$args = [
168168
new Arg(new ClassConstFetch(new FullyQualified($variableNameToType->getObjectType()), 'class')),
169169
new Arg(new Variable($variableNameToType->getVariableName())),
170170
];
171171

172-
$methodCall = new MethodCall(new Variable('this'), 'assertInstanceof', $args);
172+
$methodCall = new MethodCall(new Variable('this'), 'assertInstanceOf', $args);
173173

174174
return new Expression($methodCall);
175175
}

0 commit comments

Comments
 (0)