public function process(): void
    {
        /** @var \Closure|object $closure */
        $closure = include $this->file;

        if (!\is_callable($closure)) {
            throw new ComponentException("There is no callable structure in file `{$this->file}`");
        }

        $reflection = new \ReflectionFunction($closure);

        // check and normalize params by doc comment
        $docComment = $reflection->getDocComment();

        // get all options by one regular expression
        if (preg_match_all('/\s*\*\s*\@([a-z0-9-_]+)\s+(.*).*\s+/i', $docComment, $matches)) {
            foreach ($matches[1] as $i => $key) {
                $this->setOption($key, trim($matches[2][$i]));
            }
        }

        // init routes
        $this->initRoute();

        // get params and convert it to simple array
        $reflectionParams = $reflection->getParameters();
        // setup params and optional params
        foreach ($reflectionParams as $param) {
            $name = $param->getName();
            // if some function params is missed in description
            if (!isset($this->params[$name])) {
                $this->params[$name] = null;
            }
            if ($param->isOptional()) {
                $this->values[$name] = $param->getDefaultValue();
            }
        }
    }
public function process(): void
    {
        /** @var \Closure|object $closure */
        $closure = include $this->file;

        if (!\is_callable($closure)) {
            throw new ComponentException("There is no callable structure in file `{$this->file}`");
        }

        $reflection = new \ReflectionFunction($closure);

        // check and normalize params by doc comment
        $docComment = $reflection->getDocComment();

        // get all options by one regular expression
        if (preg_match_all('/\s*\*\s*\@([a-z0-9-_]+)\s+(.*).*\s+/i', $docComment, $matches)) {
            foreach ($matches[1] as $i => $key) {
                $this->setOption($key, trim($matches[2][$i]));
            }
        }

        // init routes
        $this->initRoute();

        // get params and convert it to simple array
        $reflectionParams = $reflection->getParameters();
        // setup params and optional params
        foreach ($reflectionParams as $param) {
            $name = $param->getName();
            // if some function params is missed in description
            if (!isset($this->params[$name])) {
                $this->params[$name] = null;
            }
            if ($param->isOptional()) {
                $this->values[$name] = $param->getDefaultValue();
            }
        }
    }
public function process ( ) : void { /** @var \Closure|object $closure */ $ closure = include $ this -> file ; if ( ! \ is_callable ( $ closure ) ) { throw new ComponentException ( "There is no callable structure in file `{$this->file}`" ) ; } $ reflection = new \ ReflectionFunction ( $ closure ) ; // check and normalize params by doc comment $ docComment = $ reflection -> getDocComment ( ) ; // get all options by one regular expression if ( preg_match_all ( '/\s*\*\s*\@([a-z0-9-_]+)\s+(.*).*\s+/i' , $ docComment , $ matches ) ) { foreach ( $ matches [ 1 ] as $ i => $ key ) { $ this -> setOption ( $ key , trim ( $ matches [ 2 ] [ $ i ] ) ) ; } } // init routes $ this -> initRoute ( ) ; // get params and convert it to simple array $ reflectionParams = $ reflection -> getParameters ( ) ; // setup params and optional params foreach ( $ reflectionParams as $ param ) { $ name = $ param -> getName ( ) ; // if some function params is missed in description if ( ! isset ( $ this -> params [ $ name ] ) ) { $ this -> params [ $ name ] = null ; } if ( $ param -> isOptional ( ) ) { $ this -> values [ $ name ] = $ param -> getDefaultValue ( ) ; } } }
Process to get reflection from file

@return void
@throws ComponentException
@throws \ReflectionException
Process to get reflection from file