public create ( |
||
$declaringClass | ||
$reflection | ReflectionMethod | |
$phpDocParameterTypes | array | |
$phpDocReturnType | PHPStan\Type\Type | |
return |
/** * @param \PHPStan\Reflection\ClassReflection $classReflection * @return \PHPStan\Reflection\MethodReflection[] */ private function createMethods(ClassReflection $classReflection) : array { $methods = []; foreach ($classReflection->getNativeReflection()->getMethods() as $methodReflection) { $declaringClass = $this->broker->getClass($methodReflection->getDeclaringClass()->getName()); $phpDocParameters = $this->getPhpDocParamsFromMethod($methodReflection); $phpDocParameterTypes = []; if (!$declaringClass->getNativeReflection()->isAnonymous() && $declaringClass->getNativeReflection()->getFileName() !== false) { $typeMap = $this->fileTypeMapper->getTypeMap($declaringClass->getNativeReflection()->getFileName()); foreach ($methodReflection->getParameters() as $parameterReflection) { $typeString = $this->getMethodParameterAnnotationTypeString($phpDocParameters, $parameterReflection); if ($typeString === null || !isset($typeMap[$typeString])) { continue; } $type = $typeMap[$typeString]; $phpDocParameterTypes[$parameterReflection->getName()] = $type; } } $phpDocReturnType = null; $returnTypeString = $this->getReturnTypeStringFromMethod($methodReflection); if ($returnTypeString !== null && isset($typeMap[$returnTypeString])) { $phpDocReturnType = $typeMap[$returnTypeString]; } $methods[strtolower($methodReflection->getName())] = $this->methodReflectionFactory->create($declaringClass, $methodReflection, $phpDocParameterTypes, $phpDocReturnType); } return $methods; }
/** * @param \PHPStan\Reflection\ClassReflection $classReflection * @return \PHPStan\Reflection\MethodReflection[] */ private function createMethods(ClassReflection $classReflection) : array { $methods = []; foreach ($classReflection->getNativeReflection()->getMethods() as $methodReflection) { $declaringClass = $this->broker->getClass($methodReflection->getDeclaringClass()->getName()); $phpDocParameterTypes = []; $phpDocReturnType = null; if (!$declaringClass->getNativeReflection()->isAnonymous() && $declaringClass->getNativeReflection()->getFileName() !== false) { $typeMap = $this->fileTypeMapper->getTypeMap($declaringClass->getNativeReflection()->getFileName()); if ($methodReflection->getDocComment() !== false) { $phpDocParameterTypes = TypehintHelper::getPhpDocParameterTypesFromMethod($typeMap, array_map(function (\ReflectionParameter $parameterReflection) : string { return $parameterReflection->getName(); }, $methodReflection->getParameters()), $methodReflection->getDocComment()); } if ($methodReflection->getDocComment() !== false) { $phpDocReturnType = TypehintHelper::getPhpDocReturnTypeFromMethod($typeMap, $methodReflection->getDocComment()); } } $methods[strtolower($methodReflection->getName())] = $this->methodReflectionFactory->create($declaringClass, $methodReflection, $phpDocParameterTypes, $phpDocReturnType); } return $methods; }