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