Skip to content

Commit

Permalink
Added checking for syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Sep 26, 2019
1 parent cf655b4 commit 99d6757
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,9 +1321,19 @@ public function getMethodParameters($stackPtr)
throw new RuntimeException('$stackPtr was not a valid T_USE');
}
} else {
if (isset($this->tokens[$stackPtr]['parenthesis_opener']) === false) {
// Live coding or syntax error, so no params to find.
return [];
}

$opener = $this->tokens[$stackPtr]['parenthesis_opener'];
}

if (isset($this->tokens[$opener]['parenthesis_closer']) === false) {
// Live coding or syntax error, so no params to find.
return [];
}

$closer = $this->tokens[$opener]['parenthesis_closer'];

$vars = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ $closure = function ($arg1, $arg2='hello') {};

// Invalid closure
$closure = function(array $arg2=array(), array $arg1) {}

// Intentional syntax error. Must be last thing in the file.
function

0 comments on commit 99d6757

Please sign in to comment.