Skip to content

Commit 99d6757

Browse files
committed
Added checking for syntax errors
1 parent cf655b4 commit 99d6757

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Files/File.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,9 +1321,19 @@ public function getMethodParameters($stackPtr)
13211321
throw new RuntimeException('$stackPtr was not a valid T_USE');
13221322
}
13231323
} else {
1324+
if (isset($this->tokens[$stackPtr]['parenthesis_opener']) === false) {
1325+
// Live coding or syntax error, so no params to find.
1326+
return [];
1327+
}
1328+
13241329
$opener = $this->tokens[$stackPtr]['parenthesis_opener'];
13251330
}
13261331

1332+
if (isset($this->tokens[$opener]['parenthesis_closer']) === false) {
1333+
// Live coding or syntax error, so no params to find.
1334+
return [];
1335+
}
1336+
13271337
$closer = $this->tokens[$opener]['parenthesis_closer'];
13281338

13291339
$vars = [];

src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ $closure = function ($arg1, $arg2='hello') {};
9797

9898
// Invalid closure
9999
$closure = function(array $arg2=array(), array $arg1) {}
100+
101+
// Intentional syntax error. Must be last thing in the file.
102+
function

0 commit comments

Comments
 (0)