/** * Visits a method node. * * @param PHP_Depend_Code_Class $method The method class node. * * @return void * @see PHP_Depend_VisitorI::visitMethod() */ public function visitMethod(PHP_Depend_Code_Method $method) { $this->visits[] = $method->getName(); parent::visitMethod($method); }
/** * Visits a method node. * * @param PHP_Depend_Code_Class $method The method class node. * * @return void * @see PHP_Depend_VisitorI::visitMethod() */ public function visitMethod(PHP_Depend_Code_Method $method) { $classXml = end($this->_xmlStack); $document = $classXml->ownerDocument; $methodXml = $document->createElement('method'); $methodXml->setAttribute('name', $method->getName()); $this->_appendMetrics($methodXml, $method); $classXml->appendChild($methodXml); }
/** * 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 PHP_Depend_Code_Method $method The imported trait method. * * @return PHP_Depend_Code_Method[] */ private function getAliasesFor(PHP_Depend_Code_Method $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 &= ~(PHP_Depend_ConstantsI::IS_PUBLIC | PHP_Depend_ConstantsI::IS_PROTECTED | PHP_Depend_ConstantsI::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); }
/** * Generates an identifier for the given method instance. * * @param PHP_Depend_Code_Method $method A method instance. * * @return string */ public function forMethod(PHP_Depend_Code_Method $method) { return sprintf('%s-%s', $method->getParent()->getUUID(), $this->hash(strtolower($method->getName()))); }
/** * Constructs a new exception instance. * * @param PHP_Depend_Code_Method $method The method that could not be * applied to the given <b>$type</b>. * @param PHP_Depend_Code_AbstractType $type The class or trait that cannot * resolve the imported methods. */ public function __construct(PHP_Depend_Code_Method $method, PHP_Depend_Code_AbstractType $type) { parent::__construct(sprintf('Trait method %s has not been applied, because there are ' . 'collisions with other trait methods on %s\\%s.', $method->getName(), preg_replace('(\\W+)', '\\', $type->getPackage()->getName()), $type->getName())); }