Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa22c2f

Browse files
fix issues found by phpstan
1 parent 0a3911f commit aa22c2f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎src/Lexer/Lexer.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ class Lexer
8383

8484
public function tokenize(string $s): array
8585
{
86-
if ($this->regexp === null) {
86+
if ($this->regexp === null || $this->types === null) {
8787
$this->initialize();
8888
}
8989

90+
assert($this->regexp !== null);
91+
assert($this->types !== null);
92+
9093
preg_match_all($this->regexp, $s, $tokens, PREG_SET_ORDER);
9194

92-
assert($this->types !== null);
9395
$count = count($this->types);
94-
9596
foreach ($tokens as &$match) {
9697
for ($i = 1; $i <= $count; $i++) {
9798
if ($match[$i] !== null && $match[$i] !== '') {

‎src/Parser/ParserException.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ public function __construct(
3131
$this->currentOffset = $currentOffset;
3232
$this->expectedTokenType = $expectedTokenType;
3333

34+
$json = json_encode($currentTokenValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
35+
assert($json !== false);
36+
3437
parent::__construct(sprintf(
3538
'Unexpected token %s, expected %s at offset %d',
36-
json_encode($currentTokenValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
39+
$json,
3740
Lexer::TOKEN_LABELS[$expectedTokenType],
3841
$currentOffset
3942
));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /