Через рефлексию получаем список и порядок параметров с дефолтными значениями

@param $class
@param $method

@return string
961816
function getMethodParams($class, $method) {
        if(!is_callable([$class, $method])){
            return self::NOT_CALLABLE;
        }
        $reflectMethod = new \ReflectionMethod($class, $method);
        $params        = [];
        foreach ($reflectMethod->getParameters() as $param) {
            $_param = '$' . $param->getName();
            if ($param->isDefaultValueAvailable()) {
                $default = $param->getDefaultValue();
                switch (mb_strtolower(gettype($default))) {
                    case 'null':
                        $default = 'null';
                        break;
                    case 'array':
                        $default = '[]';
                        break;
                    case 'string':
                        $default = '\'' . $default . '\'';
                        break;
                    case 'boolean':
                        $default = $default ? 'true' : 'false';
                        break;
                    default:
                        $default = $default;
                        break;
                }
                $_param .= ' = ' . $default;
            }
            $params[] = $_param;
        }
        return implode(', ', $params);

    }
986518
public static function getCommments( $method ){

		//split para el nombre de la clase y m�todo.
		$clazzAndMethod = explode("::", $method);
		
		$reflectionMethod = new \ReflectionMethod( $clazzAndMethod[0] , $clazzAndMethod[1]);
		
		$comments = $reflectionMethod->getDocComment();
			
		return $comments;
	}
1031067
private static function getCalledMethod($method)
    {
        if (strpos($method, '::') !== false) {
            $methodChunks = explode('::', $method);
            $method = $methodChunks[1];
        }

        return $method;
    }
1373376
public function byClassMethod($class, $method)
    {
        $this->controller = new $class();
        $this->controller = is_object($class) ? $class : new $class();
        if ($this->hasContainer() && method_exists($this->controller, 'raikiri'))
            $this->controller->setContainer($this->raikiri());

        $this->action = function() use($method)
        {
            $args = func_get_args();
            return call_user_func_array([$this->controller, $method], $args);
        };
    }
287220
protected function createQueuedHandlerCallable($class, $method)
    {
        return function () use ($class, $method) {
            $arguments = array_map(function ($a) {
                return is_object($a) ? clone $a : $a;
            }, func_get_args());

            if ($this->handlerWantsToBeQueued($class, $arguments)) {
                $this->queueHandler($class, $method, $arguments);
            }
        };
    }
822184
static public function instance($class,$method='') {
        $identify   =   $class.$method;
        if(!isset(self::$_instance[$identify])) {
            if(class_exists($class)){
                $o = new $class();
                if(!empty($method) && method_exists($o,$method))
                    self::$_instance[$identify] = call_user_func(array(&$o, $method));
                else
                    self::$_instance[$identify] = $o;
            }
            else
                self::halt(L('_CLASS_NOT_EXIST_').':'.$class);
        }
        return self::$_instance[$identify];
    }
1023681
protected function classMethod(&$class = NULL, &$method = NULL, $command)
    {
        $commandEx = explode(':', $command);
        $class     = $commandEx[0];
        $method    = $commandEx[1] ?? NULL;
    }
251841
protected function getMethodCode($method)
    {
        $reflection = new \ReflectionMethod($this->model, $method);

        $file = new \SplFileObject($reflection->getFileName());
        $file->seek($reflection->getStartLine() - 1);

        $methodCode = '';

        while ($file->key() < $reflection->getEndLine()) {
            $methodCode .= $file->current();

            $file->next();
        }

        $methodCode = trim(preg_replace('/\s\s+/', '', $methodCode));

        $start = strpos($methodCode, 'function(');
        $length = strrpos($methodCode, '}') - $start + 1;

        return substr($methodCode, $start, $length);
    }
234519
private static function getMethodsTpl($ref, $class)
    {
        $tpl = '';
        foreach($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $method)
        {
            if($method->isStatic() || '__construct' === $method->name || $method->isFinal() || !static::hasAop($ref, $method))
            {
                continue;
            }
            $paramsTpls = static::getMethodParamTpls($method);
            $methodReturnType = static::getMethodReturnType($method);
            $returnsReference = $method->returnsReference() ? '&' : '';
            $tpl .= <<<TPL
    public function {$returnsReference}{$method->name}({$paramsTpls['define']}){$methodReturnType}
    {
        \$__args__ = func_get_args();
        {$paramsTpls['set_args']}
        \$__result__ = \$this->beanProxy->call(
            '{$method->name}',
            function({$paramsTpls['define']}){
                \$__args__ = func_get_args();
                {$paramsTpls['set_args']}
                return parent::{$method->name}(...\$__args__);
            },
            \$__args__
        );
        return \$__result__;
    }

TPL;
        }
        return $tpl;
    }
425064
public function getMethod($class, $method, $extraMappings = []) {
		if (isset($this->aliases[$class])) {
			$class = $this->aliases[$class];
		}

		return [
			$this->getSingleton($class),
			$this->resolveArgs($class, $method, " when resolving method $class::$method", $extraMappings)
		];
	}
892926
public static function getMethodAnnotations($class, $method)
    {
        $annotationBag = Bridge\Loader::getInstance()->getMethodAnnotations($class, $method);
        $annotationBag = self::explodeNamespaces($annotationBag);

        return new ConfigObject($annotationBag);
    }
847577
protected function getPhpdoc($method)
    {

        $reflect = false;
        
        foreach($this->served_classes as $class){
            if (\method_exists($class, $method)) {
                $reflect = new \ReflectionMethod($class, $method);
                break;
            }
        
        }
        
        $response = new \stdClass();
        
         if(!$reflect){
            $response->error = new \sb\JSON\RPC2\Error();
            $response->error->code = -32602;
            $response->error->message = "Invalid method parameters";
            return $response;
        }

        $response->phpdoc = $reflect->getDocComment();

        if (\preg_match("~@return (.*?) (.*?)\*/$~s", $response->phpdoc, $match)) {
            $response->return_type = $match[1];
        } else {
            $response->return_type = 'n/a';
        }

        return $response;
    }
1305936
public function inspect($class, $method = '__construct')
    {
        if (is_string($class) && !class_exists($class)) {
            throw new ClassNotFoundException($class);
        }
        $dependencies = [];

        $r = new ReflectionClass($class);

        if (!$r->hasMethod($method)) {
            if ($method === '__construct') {
                return $dependencies;
            }
            throw new MethodNotFoundException($r->getName(), $method);
        }

        $rp = $r->getMethod($method)->getParameters();

        foreach ($rp as $p) {
            $prop = $p->name;

            $dependencies[$prop] = [];
            $dependencies[$prop]['optional'] = $p->isOptional();

            try {
                $class = $p->getClass();
                if (isset($class)) {
                    $dependencies[$prop]['class'] = $class->name;
                }
            } catch (\Exception $e) {
                $dependencies[$prop]['error'] = $e->getMessage();
            }
        }

        return $dependencies;
    }
1301995
protected function _getClassName($class)
    {
        $class = Str::low($class);
        list ($plugin, $className) = pluginSplit($class);
        $return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX;
        if ($plugin !== null) {
            return Inflector::camelize($plugin) . '\\' . $return;
        }

        return Configure::read('App.namespace') . '\\' . $return;
    }
664495
protected function _resolveClassName($class)
    {
        $result = App::className($class, 'FormParameter', 'Parameter');
        if ($result || strpos($class, '.') !== false) {
            return $result;
        }

        return App::className('PlumSearch.' . $class, 'FormParameter', 'Parameter');
    }
787910
protected function dumpMethod(Method $method)
    {
        $builder = new MethodBuilder();

        $documentation = $method->getDescription()."\n\n";
        $signature = array();

        foreach ($method->getParameters() as $parameter) {
            $builder->addParameter($parameter->getName());
            $documentation .= "@param string $".$parameter->getName()." ".$parameter->getDescription()."\n\n";
            $signature[] = '$'.$parameter->getName();
        }

        $signature = implode(', ', $signature);

        if ($method->isAction()) {
            $documentation .= '@return \Selenium\Browser Fluid interface';

            $body  = '$this->driver->action("'.$method->getName().'"'. ($signature ? ', '.$signature : '') . ');'."\n";
            $body .= "\n";
            $body .= "return \$this;";

        } else {
            $returnType = $method->getReturnType();

            if ($returnType === 'boolean') {
                $getMethod = 'getBoolean';
            } elseif ($returnType === 'string') {
                $getMethod = 'getString';
            } elseif ($returnType === 'string[]') {
                $getMethod = 'getStringArray';
            } elseif ($returnType === 'number') {
                $getMethod = 'getNumber';
                $returnType = 'integer';

                if (0 === strpos($method->getReturnDescription(), 'of ')) {
                    $returnType .= ' number';
                }
            }

            $documentation .= '@return '.$returnType.' '.$method->getReturnDescription();

            $body = 'return $this->driver->'.$getMethod.'("'.$method->getName().'"'.($signature ? ', '.$signature : '').');';
        }

        $builder->setName($method->getName());
        $builder->setBody($body);
        $builder->setDocumentation($documentation);

        return $builder->buildCode();
    }
1307919
protected static function _ref($context, $method)
    {
        if (is_string($context)) {
            return $context . "::{$method}";
        }
        return get_class($context) . '#' . spl_object_hash($context) . "::{$method}";
    }