Neos\Flow\Reflection\ReflectionService::getMethodParameters PHP Method

getMethodParameters() public method

Returns an array of parameters of the given method. Each entry contains additional information about the parameter position, type hint etc.
public getMethodParameters ( string $className, string $methodName ) : array
$className string Name of the class containing the method
$methodName string Name of the method to return parameter information of
return array An array of parameter names and additional information or an empty array of no parameters were found
    public function getMethodParameters($className, $methodName)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_METHODS][$methodName][self::DATA_METHOD_PARAMETERS])) {
            return [];
        }
        return $this->convertParameterDataToArray($this->classReflectionData[$className][self::DATA_CLASS_METHODS][$methodName][self::DATA_METHOD_PARAMETERS]);
    }

Usage Example

 /**
  * Only convert if the given target class has a constructor with one argument being of type given type
  *
  * @param string $source
  * @param string $targetType
  * @return bool
  */
 public function canConvertFrom($source, $targetType)
 {
     $methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
     if (count($methodParameters) !== 1) {
         return false;
     }
     $methodParameter = array_shift($methodParameters);
     return $methodParameter['type'] === gettype($source);
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::getMethodParameters
ReflectionService