From 001719245c7757225f6adbc57a19fd1334c1082c Mon Sep 17 00:00:00 2001 From: Jeppe Knockaert Date: Wed, 12 Dec 2018 14:42:03 +0100 Subject: [PATCH] bugfix - Prevent redeclaring methods inside Aliases The getMethods function gets called both in the removeDuplicateMethodsFromPhpDoc function and in helper.php, which causes the method detection to be performed twice. Parts of the method detection includes a check for duplicate methods, but Macro methods for example, aren't checked for duplicates. Instead of checking everywhere if we're not adding duplicates, I've included a check in the getMethods call to just use the already generated methods if they have been generated already. --- src/Alias.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Alias.php b/src/Alias.php index f14bb12..c06e414 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -176,6 +176,10 @@ class Alias */ public function getMethods() { + if (count($this->methods) > 0) { + return $this->methods; + } + $this->addMagicMethods(); $this->detectMethods(); return $this->methods; @@ -411,10 +415,9 @@ class Alias */ protected function removeDuplicateMethodsFromPhpDoc() { - $methods = count($this->methods) > 0 ? $this->methods : $this->getMethods(); $methodNames = array_map(function (Method $method) { return $method->getName(); - }, $methods); + }, $this->getMethods()); foreach ($this->phpdoc->getTags() as $tag) { if ($tag instanceof MethodTag && in_array($tag->getMethodName(), $methodNames)) {