Changeset View
Changeset View
Standalone View
Standalone View
externals/jsonlint/src/Seld/JsonLint/Lexer.php
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function getPastInput() | ||||
$past = substr($this->matched, 0, strlen($this->matched) - strlen($this->match)); | $past = substr($this->matched, 0, strlen($this->matched) - strlen($this->match)); | ||||
return (strlen($past) > 20 ? '...' : '') . substr($past, -20); | return (strlen($past) > 20 ? '...' : '') . substr($past, -20); | ||||
} | } | ||||
public function getUpcomingInput() | public function getUpcomingInput() | ||||
{ | { | ||||
$next = $this->match; | $next = $this->match; | ||||
if (strlen($next) < 20) { | if ($this->input && strlen($next) < 20) { | ||||
valerio.bozzolan: 🔶 This involves the PHP pitfall "zero string" that is evaluated as falsy so it's skipped. Can… | |||||
$next .= substr($this->input, 0, 20 - strlen($next)); | $next .= substr($this->input, 0, 20 - strlen($next)); | ||||
} | } | ||||
return substr($next, 0, 20) . (strlen($next) > 20 ? '...' : ''); | return substr($next, 0, 20) . (strlen($next) > 20 ? '...' : ''); | ||||
} | } | ||||
protected function parseError($str, $hash) | protected function parseError($str, $hash) | ||||
{ | { | ||||
Show All 18 Lines | private function next() | ||||
$this->yytext = ''; | $this->yytext = ''; | ||||
$this->match = ''; | $this->match = ''; | ||||
} | } | ||||
$rules = $this->getCurrentRules(); | $rules = $this->getCurrentRules(); | ||||
$rulesLen = count($rules); | $rulesLen = count($rules); | ||||
for ($i=0; $i < $rulesLen; $i++) { | for ($i=0; $i < $rulesLen; $i++) { | ||||
if (preg_match($this->rules[$rules[$i]], $this->input, $match)) { | if ($this->input && $match && preg_match($this->rules[$rules[$i]], $this->input, $match)) { | ||||
valerio.bozzolanUnsubmitted Not Done Inline ActionsThanks for this patch 🔴 The $match should be removed from the condition. valerio.bozzolan: Thanks for this patch
🔴 The `$match` should be removed from the condition.
| |||||
valerio.bozzolanUnsubmitted Not Done Inline ActionsNOTE: already fixed in: D25250 valerio.bozzolan: NOTE: already fixed in: D25250 | |||||
preg_match_all('/\n.*/', $match[0], $lines); | preg_match_all('/\n.*/', $match[0], $lines); | ||||
$lines = $lines[0]; | $lines = $lines[0]; | ||||
if ($lines) { | if ($lines) { | ||||
$this->yylineno += count($lines); | $this->yylineno += count($lines); | ||||
} | } | ||||
$this->yylloc = array( | $this->yylloc = array( | ||||
'first_line' => $this->yylloc['last_line'], | 'first_line' => $this->yylloc['last_line'], | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | private function performAction($avoiding_name_collisions, $YY_START) | ||||
case 11: | case 11: | ||||
return 8; | return 8; | ||||
case 12: | case 12: | ||||
return 14; | return 14; | ||||
case 13: | case 13: | ||||
return 'INVALID'; | return 'INVALID'; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
No newline at end of file |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
🔶 This involves the PHP pitfall "zero string" that is evaluated as falsy so it's skipped. Can be a problem here.