diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index 8a49a5ae1..af76d50e0 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -157,10 +157,10 @@ class ParseTreeCreator $default = ''; if ($current_token[0] === '&') { - throw new TypeParseTreeException('Magic args cannot be passed by reference'); - } - - if ($current_token[0] === '...') { + $byref = true; + ++$this->t; + $current_token = $this->t < $this->type_token_count ? $this->type_tokens[$this->t] : null; + } elseif ($current_token[0] === '...') { $variadic = true; ++$this->t; @@ -648,7 +648,7 @@ class ParseTreeCreator $current_parent = $this->current_leaf->parent; - if ($this->current_leaf instanceof ParseTree\MethodTree && $current_parent) { + if ($current_parent && $current_parent instanceof ParseTree\MethodTree) { $this->createMethodParam($this->type_tokens[$this->t], $current_parent); return; } diff --git a/tests/MagicMethodAnnotationTest.php b/tests/MagicMethodAnnotationTest.php index c521c4930..a41efeac4 100644 --- a/tests/MagicMethodAnnotationTest.php +++ b/tests/MagicMethodAnnotationTest.php @@ -204,6 +204,26 @@ class MagicMethodAnnotationTest extends TestCase $child->setArray(["boo"]); $child->setArray(["boo"], 8);', ], + 'validAnnotationWithByRefParam' => [ + 'configure("foo", $array);', + ], 'validAnnotationWithNonEmptyDefaultArray' => [ '