Пример #1
0
 /**
  * This method parses a function declaration.
  *
  * @return \PDepend\Source\AST\ASTFunction
  * @since  0.9.5
  */
 private function parseFunctionDeclaration()
 {
     $this->consumeComments();
     // Next token must be the function identifier
     $functionName = $this->parseFunctionName();
     $function = $this->builder->buildFunction($functionName);
     $function->setCompilationUnit($this->compilationUnit);
     $function->setId($this->idBuilder->forFunction($function));
     $this->parseCallableDeclaration($function);
     // First check for an existing namespace
     if ($this->namespaceName !== null) {
         $packageName = $this->namespaceName;
     } elseif ($this->packageName !== Builder::DEFAULT_NAMESPACE) {
         $packageName = $this->packageName;
     } else {
         $packageName = $this->globalPackageName;
     }
     $this->builder->buildNamespace($packageName)->addFunction($function);
     // Store function in source file, because we need them during the file's
     // __wakeup() phase for function declarations within another function or
     // method declaration.
     $this->compilationUnit->addChild($function);
     return $function;
 }
 /**
  * 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));
 }