protected function assertEqualTypes(IType $expected, IType $actual, $message = '') { $this->assertSame($expected->getIdentifier(), $actual->getIdentifier(), $message); $this->assertTrue($expected->isEqualTo($actual), $message); $this->assertTrue($actual->isEqualTo($expected), $message); $this->assertSame($expected, $actual, $message); }
public function getCommonAncestorType(IType $type, IType $otherType) { if ($type->isEqualTo($otherType)) { return $type; } elseif ($type->isParentTypeOf($otherType)) { return $type; } elseif ($otherType->isParentTypeOf($type)) { return $otherType; } $parentTypes = $this->getAncestorTypes($type); $otherParentTypes = $this->getAncestorTypes($otherType); /** @var $commonParentTypes IType[] */ $commonParentTypes = array_intersect_key($parentTypes, $otherParentTypes); return $this->getCompositeType($commonParentTypes); }