Skip to content

Commit 6d75639

Browse files
committed
update
1 parent 94b663b commit 6d75639

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

performance/Shopify/Database.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function (array $product) use ($database) {
4848
$tables['collection'] = Arr::first($database['collections']);
4949
$tables['product'] = Arr::first($database['products']);
5050
$tables['blog'] = Arr::first($database['blogs']);
51-
$tables['article'] = Arr::first($tables['blog']['articles'] ?? []);
51+
$articles = $tables['blog']['articles'] ?? [];
52+
assert(is_array($articles));
53+
$tables['article'] = Arr::first($articles);
5254

5355
$tables['cart'] = [
5456
'total_price' => array_reduce($tables['line_items'], fn (int $total, array $item) => $total + $item['line_price'] * $item['quantity'], 0),

src/Parse/Lexer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected function lexBlock(): void
209209
protected function lexExpression(): void
210210
{
211211
if (preg_match('/\G\s+/A', $this->source, $matches, offset: $this->cursor) === 1) {
212-
$this->moveCursor($matches[0] ?? '');
212+
$this->moveCursor($matches[0]);
213213
}
214214

215215
$this->ensureStreamNotEnded();
@@ -221,10 +221,10 @@ protected function lexExpression(): void
221221
}
222222

223223
$token = match (true) {
224-
preg_match(LexerOptions::comparisonOperatorRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Comparison, $matches[0]],
225-
preg_match(LexerOptions::identifierRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Identifier, $matches[0]],
226-
preg_match(LexerOptions::stringLiteralRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::String, $matches[0]],
227-
preg_match(LexerOptions::numberLiteralRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Number, $matches[0]],
224+
preg_match(LexerOptions::comparisonOperatorRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Comparison, $matches[0] ?? ''],
225+
preg_match(LexerOptions::identifierRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Identifier, $matches[0] ?? ''],
226+
preg_match(LexerOptions::stringLiteralRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::String, $matches[0] ?? ''],
227+
preg_match(LexerOptions::numberLiteralRegex(), $this->source, $matches, offset: $this->cursor) === 1 => [TokenType::Number, $matches[0] ?? ''],
228228
$this->cursor + 1 < $this->end && $this->source[$this->cursor] === '.' && $this->source[$this->cursor + 1] === '.' => [TokenType::DotDot, '..'],
229229
array_key_exists($this->source[$this->cursor], LexerOptions::specialCharacters()) => [LexerOptions::specialCharacters()[$this->source[$this->cursor]], $this->source[$this->cursor]],
230230
default => throw SyntaxException::unexpectedCharacter($this->source[$this->cursor]),

src/Tags/CycleTag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function render(RenderContext $context): string
7171
$register = $context->getRegister('cycle') ?? [];
7272
assert(is_array($register));
7373
$key = $context->evaluate($this->name);
74+
assert(is_string($key) || is_int($key));
7475

7576
$iteration = match (true) {
7677
isset($register[$key]) && is_int($register[$key]) => $register[$key],

0 commit comments

Comments
 (0)