private function inferTypesForFunction(AbstractFunction $function) { // Infer types for parameters. foreach ($function->getParameters() as $param) { if (!$param->getPhpType()->isUnknownType()) { continue; } $this->inferTypeForParameter($function, $param); } }
private function inferTypesForMethodOrFunction(AbstractFunction $function, Clazz $clazz = null) { if ($function instanceof GlobalFunction) { $this->parser->setImportedNamespaces($function->getImportedNamespaces()); } foreach ($function->getParameters() as $param) { $this->inferTypesForParameter($param, $function, $clazz); } if (($type = $function->getReturnType()) && !$type->isUnknownType()) { return; } if (null !== ($node = $function->getAstNode())) { $type = $this->parser->getTypeFromReturnAnnotation($node); if (null === $type && $function instanceof Method && null !== $clazz) { foreach ($this->findOverriddenMethodsForDocInheritance($function->getName(), $clazz) as $parentMethod) { if (null !== ($docType = $parentMethod->getReturnDocType())) { $type = $this->parser->getType($docType); break; } } } } if (null === $type) { $type = $this->registry->getNativeType('unknown'); } $function->setReturnType($type); if ($node) { $node->setAttribute('type', $type); } }