private function isSubtype(PhpType $a, PhpType $b) { if ($a->isUnknownType()) { return false; } if (null === ($objType = $a->toMaybeObjectType())) { return false; } return $objType->isSubtypeOf($b); }
/** * @param string $type * * @return null|PhpType */ private function tryGettingMoreSpecificType(PhpType $docType = null, PhpType $actualType, AbstractFunction $function, array $importedNamespaces, MethodContainer $container = null, $type) { if (!$docType) { if (!$actualType->isUnknownType() && !$actualType->isAllType()) { return null; } return $this->{'infer' . $type . 'TypeForFunction'}($function, $container); } // If the type defined by the comment is an object (and not the NoObjectType), // and a super type of the actual type, we keep it. if (null !== $docType->toMaybeObjectType() && $actualType->isSubtypeOf($docType)) { return $docType; } // If the type defined by the comment is a nullable object type (excluding the // NoObject type), we keep the comment that is currently in place. if ($this->isNullableObjectType($docType) && $actualType->isSubtypeOf($docType)) { return $docType; } if ($docType->getDocType($importedNamespaces) !== $actualType->getDocType($importedNamespaces)) { return $actualType; } if ($actualType === $this->registry->getNativeType('array')) { $inferredType = $this->{'infer' . $type . 'TypeForFunction'}($function, $container); if ($inferredType && $inferredType->isArrayType()) { return $inferredType; } } return null; }
public function equals(PhpType $type) { if ($type->isInterface() && strtolower($type->toMaybeObjectType()->getName()) === strtolower($this->getName())) { return true; } if ($type instanceof ProxyObjectType && strtolower($type->getReferenceName()) === strtolower($this->getName())) { return true; } return false; }
private function getClassName(PhpType $type) { if ($type instanceof NamedType) { return $type->getReferenceName(); } $methodContainer = $type->toMaybeObjectType(); if ($methodContainer instanceof Clazz) { return $methodContainer->getName(); } return null; }