Example #1
0
 /**
  * This method will parse a list of modifiers and a following property or
  * method.
  *
  * @param  integer $modifiers
  * @return \PDepend\Source\AST\ASTMethod|\PDepend\Source\AST\ASTFieldDeclaration
  * @since  0.9.6
  */
 private function parseMethodOrFieldDeclaration($modifiers = 0)
 {
     $this->tokenStack->push();
     $tokenType = $this->tokenizer->peek();
     while ($tokenType !== Tokenizer::T_EOF) {
         switch ($tokenType) {
             case Tokens::T_PRIVATE:
                 $modifiers |= State::IS_PRIVATE;
                 $modifiers = $modifiers & ~State::IS_PUBLIC;
                 break;
             case Tokens::T_PROTECTED:
                 $modifiers |= State::IS_PROTECTED;
                 $modifiers = $modifiers & ~State::IS_PUBLIC;
                 break;
             case Tokens::T_VAR:
             case Tokens::T_PUBLIC:
                 $modifiers |= State::IS_PUBLIC;
                 break;
             case Tokens::T_STATIC:
                 $modifiers |= State::IS_STATIC;
                 break;
             case Tokens::T_ABSTRACT:
                 $modifiers |= State::IS_ABSTRACT;
                 break;
             case Tokens::T_FINAL:
                 $modifiers |= State::IS_FINAL;
                 break;
             case Tokens::T_FUNCTION:
                 $method = $this->parseMethodDeclaration();
                 $method->setModifiers($modifiers);
                 $method->setCompilationUnit($this->compilationUnit);
                 $method->setId($this->idBuilder->forMethod($method));
                 $method->setTokens($this->tokenStack->pop());
                 return $method;
             case Tokens::T_VARIABLE:
                 $declaration = $this->parseFieldDeclaration();
                 $declaration->setModifiers($modifiers);
                 return $declaration;
             default:
                 break 2;
         }
         $this->consumeToken($tokenType);
         $this->consumeComments();
         $tokenType = $this->tokenizer->peek();
     }
     throw new UnexpectedTokenException($this->tokenizer->next(), $this->tokenizer->getSourceFile());
 }
 /**
  * testBuilderCreatesCaseInSensitiveMethodIdentifiers
  *
  * @return void
  */
 public function testBuilderCreatesCaseInSensitiveMethodIdentifiers()
 {
     $compilationUnit = new ASTCompilationUnit(__FILE__);
     $compilationUnit->setId(__FUNCTION__);
     $class = new ASTClass(__FUNCTION__);
     $class->setCompilationUnit($compilationUnit);
     $method0 = new ASTMethod(__FUNCTION__);
     $method0->setParent($class);
     $method1 = new ASTMethod(strtolower(__FUNCTION__));
     $method1->setParent($class);
     $builder0 = new IdBuilder();
     $builder1 = new IdBuilder();
     $this->assertEquals($builder0->forMethod($method0), $builder1->forMethod($method1));
 }