public function getMethods()
{
$this->scan();
if (!empty($this->methods)) {
return $this->methods;
}
foreach ($this->infos as $info) {
if ($info['type'] !== 'method' && $info['type'] !== 'use') {
continue;
}
// Merge in trait methods
if ($info['type'] === "use") {
$traitMethods = [];
$traits = $this->getTraits();
$insteadof = $this->getBlockedTraitMethods();
$aliases = $this->getTraitAliases();
foreach ($traits as $trait) {
$tempMethods = $trait->getMethods();
foreach ($tempMethods as $tempMethod) {
$methodFullName = $trait->getName() . '::' . $tempMethod->getName();
$methodAlias = array_search($methodFullName, $aliases);
if (false !== $methodAlias) {
// trait::method is aliased
// clone the tempMethod as we need to change
// the name and possibly the visibility of the
// scanned method.
//
// @todo setName and setVisibility were added to
// MethodScanner to accomplish this, may not be the
// best option, could use ReflectionClass instead?
$newMethod = clone $tempMethod;
$newMethod->setName($methodAlias);
// if visibility exists, change it on the MethodScanner
$visibility = $this->getVisibilityForAlias($methodAlias);
if (null !== $visibility) {
$newMethod->setVisibility($visibility);
}
$traitMethods[$methodAlias] = $newMethod;
} elseif (in_array($methodFullName, $insteadof)) {
// ignore overridden methods
continue;
} else {
if (array_key_exists($tempMethod->getName(), $traitMethods)) {
throw new Exception\RuntimeException(sprintf('Trait method %s has not been applied because there are' . ' collisions with other trait methods see: (insteadof OR as)', $tempMethod->getName()));
}
$traitMethods[$tempMethod->getName()] = $tempMethod;
}
}
}
$this->methods = array_merge($this->methods, array_values($traitMethods));
continue;
}
$m = new MethodScanner(array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart'] + 1), $this->nameInformation);
$m->setClass($this->name);
$m->setScannerClass($this);
$this->methods[] = $m;
}
return $this->methods;
}