*/
public function processCallback($input, $index, $info = array())
{
- $line = substr($info['line_buffer'], 0, $info['end']);
+ // Some (Windows?) systems provide incomplete `readline_info`, so let's
+ // try to work around it.
+ $line = $info['line_buffer'];
+ if (isset($info['end'])) {
+ $line = substr($line, 0, $info['end']);
+ }
+ if ($line === '' && $input !== '') {
+ $line = $input;
+ }
+
$tokens = token_get_all('<?php ' . $line);
+
// remove whitespaces
$tokens = array_filter($tokens, function ($token) {
return !AbstractMatcher::tokenIs($token, AbstractMatcher::T_WHITESPACE);