示例#1
0
 /**
  * Returns an <b>array</b> with all aliases for the given method. If no
  * alias exists for the given method, this method will simply return the
  * an <b>array</b> with the original method.
  *
  * @param  \PDepend\Source\AST\ASTMethod $method
  * @return \PDepend\Source\AST\ASTMethod[]
  */
 private function getAliasesFor(ASTMethod $method)
 {
     $name = strtolower($method->getName());
     $newNames = array();
     foreach ($this->getAliases() as $alias) {
         $name2 = strtolower($alias->getImage());
         if ($name2 !== $name) {
             continue;
         }
         $modifier = $method->getModifiers();
         if (-1 < $alias->getNewModifier()) {
             $modifier &= ~(State::IS_PUBLIC | State::IS_PROTECTED | State::IS_PRIVATE);
             $modifier |= $alias->getNewModifier();
         }
         $newName = $method->getName();
         if ($alias->getNewName()) {
             $newName = $alias->getNewName();
         }
         if (0 === count($alias->getChildren())) {
             $newMethod = clone $method;
             $newMethod->setName($newName);
             $newMethod->setModifiers($modifier);
             $newNames[] = $newMethod;
             continue;
         }
         if ($alias->getChild(0)->getType() !== $method->getParent()) {
             continue;
         }
         $newMethod = clone $method;
         $newMethod->setName($newName);
         $newMethod->setModifiers($modifier);
         $newNames[] = $newMethod;
     }
     if (count($newNames) > 0) {
         return $newNames;
     }
     return array($method);
 }
示例#2
0
 /**
  * Generates an identifier for the given method instance.
  *
  * @param  \PDepend\Source\AST\ASTMethod $method
  * @return string
  */
 public function forMethod(ASTMethod $method)
 {
     return sprintf('%s-%s', $method->getParent()->getId(), $this->hash(strtolower($method->getName())));
 }
 /**
  * Tests that the {@link \PDepend\Source\AST\ASTMethod::getParent()} returns as
  * default value <b>null</b> and that the package could be set and unset.
  *
  * @return void
  */
 public function testGetSetParent()
 {
     $class = new ASTClass('clazz');
     $method = new ASTMethod('method');
     $method->setParent($class);
     $this->assertSame($class, $method->getParent());
 }