TheSeer\Autoload\Parser::processClass PHP Method

processClass() private method

private processClass ( $pos )
    private function processClass($pos)
    {
        $list = array('{');
        $stack = $this->getTokensTill($pos, $list);
        $stackSize = count($stack);
        $classname = $this->inNamespace != '' ? $this->inNamespace . '\\' : '';
        $extends = '';
        $extendsFound = false;
        $implementsFound = false;
        $implementsList = array();
        $implements = '';
        $mode = 'classname';
        foreach (array_slice($stack, 1, -1) as $tok) {
            switch ($tok[0]) {
                case T_COMMENT:
                case T_DOC_COMMENT:
                case T_WHITESPACE:
                    continue;
                case T_STRING:
                    ${$mode} .= $tok[1];
                    continue;
                case T_NS_SEPARATOR:
                    ${$mode} .= '\\';
                    continue;
                case T_EXTENDS:
                    $extendsFound = true;
                    $mode = 'extends';
                    continue;
                case T_IMPLEMENTS:
                    $implementsFound = true;
                    $mode = 'implements';
                    continue;
                case ',':
                    if ($mode == 'implements') {
                        $implementsList[] = $this->resolveDependencyName($implements);
                        $implements = '';
                    }
                    continue;
                default:
                    throw new ParserException(sprintf("Parse error while trying to process class definition (unexpected token in name)."), ParserException::ParseError);
            }
        }
        if ($implements != '') {
            $implementsList[] = $this->resolveDependencyName($implements);
        }
        if ($implementsFound && count($implementsList) == 0) {
            throw new ParserException(sprintf("Parse error while trying to process class definition (extends or implements)."), ParserException::ParseError);
        }
        $classname = $this->registerUnit($classname, $stack[0][0]);
        $this->dependencies[$classname] = $implementsList;
        if ($extendsFound) {
            $this->dependencies[$classname][] = $this->resolveDependencyName($extends);
        }
        $this->inUnit = $classname;
        $this->classBracket = $this->bracketLevel + 1;
        return $pos + $stackSize - 1;
    }