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
Expand Up @@ -46,7 +46,7 @@ final class AddInstanceOnlyOnce extends TestCase
public function test(): void
{
$someObject = $this->getSomeObject();
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$value = $someObject->getSomeMethod();

$this->assertSame(123, $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class CallOnNullable extends TestCase
public function test(): void
{
$someObject = $this->getSomeObject();
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$value = $someObject->getSomeMethod();

$this->assertSame(123, $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ final class MultipleAssert extends TestCase
public function test(): void
{
$someObject = $this->getSomeObject();
$this->assertInstanceof(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject);
$value = $someObject->getSomeMethod();

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

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

$this->assertSame(123, $value2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ final class SomeTest extends TestCase
public function test()
{
$someObject = $this->getSomeObject();
$this->assertInstanceof(SomeClass::class, $someObject);
$this->assertInstanceOf(SomeClass::class, $someObject);

$value = $someObject->getSomeMethod();
}
Expand Down Expand Up @@ -130,8 +130,8 @@ public function refactor(Node $node): ?Node
}

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

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

private function createAssertInstanceof(VariableNameToType $variableNameToType): Expression
private function createAssertInstanceOf(VariableNameToType $variableNameToType): Expression
{
$args = [
new Arg(new ClassConstFetch(new FullyQualified($variableNameToType->getObjectType()), 'class')),
new Arg(new Variable($variableNameToType->getVariableName())),
];

$methodCall = new MethodCall(new Variable('this'), 'assertInstanceof', $args);
$methodCall = new MethodCall(new Variable('this'), 'assertInstanceOf', $args);

return new Expression($methodCall);
}
Expand Down
Loading