PHPStan\Reflection\Php\PhpMethodReflectionFactory::create PHP Method

create() public method

public create ( ClassReflection $declaringClass, ReflectionMethod $reflection, array $phpDocParameterTypes, PHPStan\Type\Type $phpDocReturnType = null ) : PhpMethodReflection
$declaringClass PHPStan\Reflection\ClassReflection
$reflection ReflectionMethod
$phpDocParameterTypes array
$phpDocReturnType PHPStan\Type\Type
return PhpMethodReflection
    public function create(ClassReflection $declaringClass, \ReflectionMethod $reflection, array $phpDocParameterTypes, Type $phpDocReturnType = null) : PhpMethodReflection;

Usage Example

 /**
  * @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;
 }
All Usage Examples Of PHPStan\Reflection\Php\PhpMethodReflectionFactory::create
PhpMethodReflectionFactory