Skip to content

Commit ebe48bb

Browse files
committed
TASK: Ensure that StructType instances are considered equivalents of themselves
1 parent e699682 commit ebe48bb

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/TypeSystem/Type/StructType/StructType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public static function fromStructDeclarationNode(StructDeclarationNode $structDe
4040

4141
public function is(TypeInterface $other): bool
4242
{
43-
return false;
43+
return $other === $this;
4444
}
4545
}

test/Unit/TypeSystem/Type/StructType/StructTypeTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,20 @@ public function providesNameOfTheStruct(): void
5757

5858
$this->assertEquals('SomeStruct', $structStaticType->structName);
5959
}
60+
61+
/**
62+
* @test
63+
* @return void
64+
*/
65+
public function isEquivalentToItself(): void
66+
{
67+
$structDeclarationNode = StructDeclarationNode::fromString(
68+
'struct SomeStruct {}'
69+
);
70+
$structStaticType = StructType::fromStructDeclarationNode(
71+
$structDeclarationNode
72+
);
73+
74+
$this->assertTrue($structStaticType->is($structStaticType));
75+
}
6076
}

0 commit comments

Comments
 (0)