Skip to content

Commit

Permalink
Symbol discovery - fixed looking for functions returning references
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 19, 2021
1 parent 0f64ca7 commit ec26a00
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private function findSymbols(string $file): array

preg_match_all('{
(?:
\b(?<![\$:>])(?P<type>class|interface|trait|function) \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
\b(?<![\$:>])(?P<type>class|interface|trait|function) \s++ (?P<byref>&\s*)? (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
| \b(?<![\$:>])(?P<ns>namespace) (?P<nsname>\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\s*+\\\\\s*+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+)? \s*+ [\{;]
)
}ix', $contents, $matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public function dataFunctionExists(): array
'doBaz',
'b.php',
],
[
'get_smarty',
'get_smarty',
'b.php',
],
[
'get_smarty2',
'get_smarty2',
'b.php',
],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ function doBaz()
{

}

function &get_smarty()
{
global $smarty;

return $smarty;
}

function & get_smarty2()
{
global $smarty;

return $smarty;
}

0 comments on commit ec26a00

Please sign in to comment.