Skip to content

Commit

Permalink
Revert "Fixed ObjectType to be assignable from the PHP "object" type"
Browse files Browse the repository at this point in the history
This reverts commit 917ac8d.
  • Loading branch information
sebastianbergmann committed Jun 19, 2019
1 parent b2a7f9a commit d2b10e3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
4 changes: 0 additions & 4 deletions src/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function isAssignable(Type $other): bool
if (\is_subclass_of($other->className->getQualifiedName(), $this->className->getQualifiedName(), true)) {
return true;
}

if ($other->className->getQualifiedName() === 'object') {
return true;
}
}

return false;
Expand Down
55 changes: 0 additions & 55 deletions tests/unit/ObjectTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,59 +119,4 @@ public function testPreservesNullAllowed(): void

$this->assertTrue($someClass->allowsNull());
}

public function testObjectTypeIsAssignableToObjects(): void
{
$objectType = new ObjectType(
TypeName::fromQualifiedName('object'),
true
);

$someObject = new class() {
};

$this->assertTrue(Type::fromValue($someObject, false)->isAssignable($objectType));
}

public function testObjectTypeIsNotAssignableToNonObjects(): void
{
$objectType = new ObjectType(
TypeName::fromQualifiedName('object'),
true
);

$someNonObject = 123;

$this->assertFalse(Type::fromValue($someNonObject, false)->isAssignable($objectType));
}

public function testReturnTypeDeclarationIsGeneratedCorrectly(): void
{
$objectType = new ObjectType(
TypeName::fromQualifiedName('object'),
false
);

$this->assertSame(': object', $objectType->getReturnTypeDeclaration());
}

public function testNullableReturnTypeDeclarationIsGeneratedCorrectly(): void
{
$objectType = new ObjectType(
TypeName::fromQualifiedName('object'),
true
);

$this->assertSame(': ?object', $objectType->getReturnTypeDeclaration());
}

public function testHasClassName(): void
{
$someClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
false
);

$this->assertSame(ParentClass::class, $someClass->className()->getQualifiedName());
}
}

0 comments on commit d2b10e3

Please sign in to comment.