/**
  * @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;
 }