Example #1
0
 /**
  * testBuilderCreatesCaseInSensitiveMethodIdentifiers
  *
  * @return void
  */
 public function testBuilderCreatesCaseInSensitiveMethodIdentifiers()
 {
     $file = new PHP_Depend_Code_File(__FILE__);
     $file->setUuid(__FUNCTION__);
     $class = new PHP_Depend_Code_Class(__FUNCTION__);
     $class->setSourceFile($file);
     $method0 = new PHP_Depend_Code_Method(__FUNCTION__);
     $method0->setParent($class);
     $method1 = new PHP_Depend_Code_Method(strtolower(__FUNCTION__));
     $method1->setParent($class);
     $builder0 = new PHP_Depend_Util_UuidBuilder();
     $builder1 = new PHP_Depend_Util_UuidBuilder();
     self::assertEquals($builder0->forMethod($method0), $builder1->forMethod($method1));
 }
Example #2
0
 /**
  * This method will parse a list of modifiers and a following property or
  * method.
  *
  * @param integer $modifiers Optional default modifiers for the property
  *        or method node that will be parsed.
  *
  * @return PHP_Depend_Code_Method|PHP_Depend_Code_ASTFieldDeclaration
  * @since 0.9.6
  */
 private function _parseMethodOrFieldDeclaration($modifiers = 0)
 {
     $this->_tokenStack->push();
     $tokenType = $this->tokenizer->peek();
     while ($tokenType !== self::T_EOF) {
         switch ($tokenType) {
             case self::T_PRIVATE:
                 $modifiers |= self::IS_PRIVATE;
                 $modifiers = $modifiers & ~self::IS_PUBLIC;
                 break;
             case self::T_PROTECTED:
                 $modifiers |= self::IS_PROTECTED;
                 $modifiers = $modifiers & ~self::IS_PUBLIC;
                 break;
             case self::T_VAR:
             case self::T_PUBLIC:
                 $modifiers |= self::IS_PUBLIC;
                 break;
             case self::T_STATIC:
                 $modifiers |= self::IS_STATIC;
                 break;
             case self::T_ABSTRACT:
                 $modifiers |= self::IS_ABSTRACT;
                 break;
             case self::T_FINAL:
                 $modifiers |= self::IS_FINAL;
                 break;
             case self::T_FUNCTION:
                 $method = $this->_parseMethodDeclaration();
                 $method->setModifiers($modifiers);
                 $method->setSourceFile($this->_sourceFile);
                 $method->setUUID($this->_uuidBuilder->forMethod($method));
                 $method->setTokens($this->_tokenStack->pop());
                 return $method;
             case self::T_VARIABLE:
                 $declaration = $this->_parseFieldDeclaration();
                 $declaration->setModifiers($modifiers);
                 return $declaration;
             default:
                 break 2;
         }
         $this->consumeToken($tokenType);
         $this->consumeComments();
         $tokenType = $this->tokenizer->peek();
     }
     throw new PHP_Depend_Parser_UnexpectedTokenException($this->tokenizer->next(), $this->tokenizer->getSourceFile());
 }
Example #3
0
 /**
  * testBuilderCreatesExpectedIdentifierForMethod
  *
  * @return void
  * @covers PHP_Depend_Util_UuidBuilder
  * @group pdepend
  * @group pdepend::util
  * @group unittest
  */
 public function testBuilderCreatesExpectedIdentifierForMethod()
 {
     $class = new PHP_Depend_Code_Class(__CLASS__);
     $class->setUUID('FooBar');
     $method = new PHP_Depend_Code_Method(__FUNCTION__);
     $method->setParent($class);
     $builder = new PHP_Depend_Util_UuidBuilder();
     $this->assertRegExp('/^FooBar\\-[a-z0-9]{11}$/', $builder->forMethod($method));
 }