/** * Parses the signature of a class. * * The signature of a class consists of optional class modifiers like, final * or abstract, the T_CLASS token, the class name, an optional parent class * and an optional list of implemented interfaces. * * @return PHP_Depend_Code_Class * @since 1.0.0 */ private function _parseClassSignature() { $this->_parseClassModifiers(); $this->consumeToken(self::T_CLASS); $this->consumeComments(); $qualifiedName = $this->_createQualifiedTypeName($this->parseClassName()); $class = $this->builder->buildClass($qualifiedName); $class->setSourceFile($this->_sourceFile); $class->setModifiers($this->_modifiers); $class->setDocComment($this->_docComment); $class->setUUID($this->_uuidBuilder->forClassOrInterface($class)); $class->setUserDefined(); $this->consumeComments(); $tokenType = $this->tokenizer->peek(); if ($tokenType === self::T_EXTENDS) { $class = $this->_parseClassExtends($class); $this->consumeComments(); $tokenType = $this->tokenizer->peek(); } if ($tokenType === self::T_IMPLEMENTS) { $this->consumeToken(self::T_IMPLEMENTS); $this->_parseInterfaceList($class); } return $class; }
/** * Parses the dependencies in a class signature. * * @return PHP_Depend_Code_Class */ private function _parseClassDeclaration() { $this->_tokenStack->push(); // Parse optional class modifiers $startLine = $this->_parseClassModifiers(); // Consume class keyword and read class start line $token = $this->_consumeToken(self::T_CLASS); // Check for previous read start line if ($startLine === -1) { $startLine = $token->startLine; } // Remove leading comments and get class name $this->_consumeComments(); $localName = $this->_consumeToken(self::T_STRING)->image; $qualifiedName = $this->_createQualifiedTypeName($localName); $class = $this->_builder->buildClass($qualifiedName); $class->setSourceFile($this->_sourceFile); $class->setModifiers($this->_modifiers); $class->setDocComment($this->_docComment); $class->setUUID($this->_uuidBuilder->forClassOrInterface($class)); $class->setUserDefined(); $this->_consumeComments(); $tokenType = $this->_tokenizer->peek(); if ($tokenType === self::T_EXTENDS) { $this->_consumeToken(self::T_EXTENDS); $class->setParentClassReference($this->_builder->buildASTClassReference($this->_parseQualifiedName())); $this->_consumeComments(); $tokenType = $this->_tokenizer->peek(); } if ($tokenType === self::T_IMPLEMENTS) { $this->_consumeToken(self::T_IMPLEMENTS); $this->_parseInterfaceList($class); } $this->_parseClassOrInterfaceBody($class); $class->setTokens($this->_tokenStack->pop()); $this->reset(); return $class; }