Skip to content

Commit b654c47

Browse files
committed
added TagParser::consumeCommaBeforeArguments()
1 parent c454d1c commit b654c47

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/Latte/Compiler/TagParser.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ public function isEnd(): bool
160160
}
161161

162162

163+
/**
164+
* Consumes the comma separating the tag name from its arguments.
165+
* When $strict is false, a missing comma only triggers E_USER_DEPRECATED,
166+
* which allows tags to phase in the required comma without breaking BC.
167+
*/
168+
public function consumeCommaBeforeArguments(bool $strict = true): void
169+
{
170+
if ($this->isEnd() || $this->stream->is(Token::Php_FilterPipe)) {
171+
return;
172+
} elseif ($strict) {
173+
$this->stream->consume(',');
174+
} elseif (!$this->stream->tryConsume(',')) {
175+
trigger_error("Missing comma before tag arguments {$this->stream->peek()->position}.", E_USER_DEPRECATED);
176+
}
177+
}
178+
179+
163180
/** @throws Latte\CompileException */
164181
private function parse(string $schema, bool $recovery = false): mixed
165182
{

0 commit comments

Comments
 (0)