diff --git a/src/Analysers/TokenScanner.php b/src/Analysers/TokenScanner.php index 8d916e2cf..126eb00a7 100644 --- a/src/Analysers/TokenScanner.php +++ b/src/Analysers/TokenScanner.php @@ -144,6 +144,10 @@ protected function scanTokens(array $tokens): array case T_FUNCTION: $token = $this->nextToken($tokens); + if ((!is_array($token) && '&' == $token) + || (defined('T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG') && T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG == $token[0])) { + $token = $this->nextToken($tokens); + } if (($unitLevel + 1) == count($stack) && $currentName) { $units[$currentName]['methods'][] = $token[1]; diff --git a/tests/Analysers/TokenScannerTest.php b/tests/Analysers/TokenScannerTest.php index 7e5bdfd3b..63004b9af 100644 --- a/tests/Analysers/TokenScannerTest.php +++ b/tests/Analysers/TokenScannerTest.php @@ -77,6 +77,24 @@ public function scanCases() ]; } + yield 'references' => [ + 'PHP/References.php', + [ + 'OpenApi\Tests\Fixtures\PHP\References' => [ + 'uses' => [ + 'OA' => 'OpenApi\Annotations', + ], + 'interfaces' => [], + 'traits' => [], + 'enums' => [], + 'methods' => [ + 'return_ref', + ], + 'properties' => [], + ], + ], + ]; + yield 'php7' => [ 'PHP/php7.php', [], diff --git a/tests/Fixtures/PHP/References.php b/tests/Fixtures/PHP/References.php new file mode 100644 index 000000000..a313da236 --- /dev/null +++ b/tests/Fixtures/PHP/References.php @@ -0,0 +1,25 @@ +