From 9dba784306fe52a971fb2bae8654368c3573f200 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 24 Mar 2026 16:29:59 +0100 Subject: [PATCH 1/5] |limit accepts strings --- src/Latte/Essential/CoreExtension.php | 2 +- tests/filters/limit.phpt | 64 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/filters/limit.phpt diff --git a/src/Latte/Essential/CoreExtension.php b/src/Latte/Essential/CoreExtension.php index 3e1f729de..2ad7a7361 100644 --- a/src/Latte/Essential/CoreExtension.php +++ b/src/Latte/Essential/CoreExtension.php @@ -152,7 +152,7 @@ public function getFilters(): array 'join' => $this->filters->implode(...), 'last' => $this->filters->last(...), 'length' => $this->filters->length(...), - 'limit' => fn(iterable $value, int $length, int $offset = 0) => Filters::slice($value, $offset, $length, preserveKeys: true), + 'limit' => fn(string|iterable $value, int $length) => Filters::slice($value, 0, $length, preserveKeys: true), 'localDate' => $this->filters->localDate(...), 'lower' => extension_loaded('mbstring') ? $this->filters->lower(...) diff --git a/tests/filters/limit.phpt b/tests/filters/limit.phpt new file mode 100644 index 000000000..9662d56ee --- /dev/null +++ b/tests/filters/limit.phpt @@ -0,0 +1,64 @@ + 'a', 1 => 'b'], limit(['a', 'b', 'c', 'd'], 2)); + Assert::same([0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'], limit(['a', 'b', 'c', 'd'], 99)); + Assert::same([], limit(['a', 'b', 'c'], 0)); +}); + + +test('arrays preserve keys', function () { + $arr = ['a', 'b', 10 => 'c', 'd']; + Assert::same([0 => 'a', 1 => 'b'], limit($arr, 2)); + Assert::same([0 => 'a', 1 => 'b', 10 => 'c'], limit($arr, 3)); +}); + + +test('iterators', function () { + $gen = function () { + yield 'a' => 1; + yield 'b' => 2; + yield 'c' => 3; + yield 'd' => 4; + }; + + Assert::same(['a' => 1, 'b' => 2], iterator_to_array(limit($gen(), 2))); + Assert::same(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4], iterator_to_array(limit($gen(), 99))); + Assert::same([], iterator_to_array(limit($gen(), 0))); +}); + + +test('strings (UTF-8)', function () { + Assert::same('Příl', limit('Příliš', 4)); + Assert::same('Příliš', limit('Příliš', 99)); + Assert::same('', limit('Příliš', 0)); + Assert::same('', limit('', 5)); + Assert::same('ř', limit('řeč', 1)); +}); + + +test('via Latte', function () { + $latte = new Latte\Engine; + $latte->setLoader(new Latte\Loaders\StringLoader); + $latte->setTempDirectory(sys_get_temp_dir()); + + Assert::same('ab', $latte->renderToString('{$s|limit:2}', ['s' => 'abcdef'])); + Assert::same('Př', $latte->renderToString('{$s|limit:2}', ['s' => 'Příliš'])); + Assert::same('a, b', $latte->renderToString('{$arr|limit:2|implode:", "}', ['arr' => ['a', 'b', 'c']])); +}); From 36cf38dd01eebae6b922d20674b89f770fe73458 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 25 Mar 2026 16:55:33 +0100 Subject: [PATCH 2/5] Dedent: fixed inline content and atLineStart tracking [Closes #412, #413] --- src/Latte/Compiler/TemplateParser.php | 23 +++++++++++++++-------- tests/common/dedent.phpt | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/Latte/Compiler/TemplateParser.php b/src/Latte/Compiler/TemplateParser.php index a20379f39..38c12d21d 100644 --- a/src/Latte/Compiler/TemplateParser.php +++ b/src/Latte/Compiler/TemplateParser.php @@ -214,7 +214,7 @@ public function parseLatteStatement(?\Closure $resolver = null): ?Node $this->lookFor[$startTag] = $res->current() ?: null; $content = $this->parseFragment($resolver ?? $this->lastResolver); if ($this->dedent) { - $this->applyDedent($content); + $this->applyDedent($content, $startTag); } if (!$this->stream->is(Token::Latte_TagOpen)) { @@ -496,19 +496,29 @@ public function isTagAllowed(string $name): bool } - private function applyDedent(FragmentNode $fragment): void + private function applyDedent(FragmentNode $fragment, Tag $startTag): void { $baseIndent = null; $atLineStart = true; + $inlineChecked = false; foreach ($fragment->children as $i => $child) { + if ($child instanceof Nodes\TextNode && $child->content === '') { + continue; + + } elseif (!$inlineChecked) { + $inlineChecked = true; + if ($child->position?->line === $startTag->position->line) { + return; + } + } if (!$child instanceof Nodes\TextNode) { - $atLineStart = false; continue; } $lines = explode("\n", $child->content); $lineCount = count($lines); + $lastContinues = !str_ends_with($child->content, "\n") && $i + 1 < count($fragment->children); foreach ($lines as $j => &$line) { $isLineStart = $j === 0 ? $atLineStart : true; @@ -517,10 +527,7 @@ private function applyDedent(FragmentNode $fragment): void } $hasContent = trim($line) !== ''; - $continuesWithExpr = !$hasContent - && $j === $lineCount - 1 - && !str_ends_with($child->content, "\n") - && $i + 1 < count($fragment->children); + $continuesWithExpr = !$hasContent && $j === $lineCount - 1 && $lastContinues; if ($baseIndent === null) { if ($hasContent) { @@ -542,7 +549,7 @@ private function applyDedent(FragmentNode $fragment): void throw new CompileException('Inconsistent indentation.', $child->position ? new Position($child->position->line + $j, 1) : null); } - continue; // blank line — strip silently + continue; // blank line, strip silently } $line = substr($line, strlen((string) $baseIndent)); diff --git a/tests/common/dedent.phpt b/tests/common/dedent.phpt index f106d06d6..736de7479 100644 --- a/tests/common/dedent.phpt +++ b/tests/common/dedent.phpt @@ -93,6 +93,28 @@ test('capture tag', function () { }); +test('inline block content not dedented (issue #412)', function () { + $result = dedent('
stuff
'); + Assert::same('
stuff
', $result); +}); + + +test('expressions with OutputKeepIndentation and varying indent (issue #413)', function () { + $template = <<<'LATTE' + {define test} + {var $a = 1} + {var $b = 2} + {=$a} + {=$b} + {=$a} + {/define} + {include test} + LATTE; + $result = dedent($template); + Assert::same("1\n\t2\n1\n", $result); +}); + + test('inconsistent indentation throws exception', function () { Assert::exception( fn() => dedent("{if true}\n\tHello\nWorld\n{/if}"), From d3273d70ee0ecc0aa2aaccb85474ed80cfc08fb7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 22 Mar 2026 23:59:48 +0100 Subject: [PATCH 3/5] added length to Position --- phpstan.neon | 3 +- src/Latte/Compiler/Position.php | 15 + src/Latte/Compiler/TagParser.php | 19 +- src/Latte/Compiler/TagParserData.php | 300 ++++++++------- src/Latte/Compiler/TemplateParser.php | 16 +- src/Latte/Compiler/TemplateParserHtml.php | 61 +-- src/Latte/Compiler/Token.php | 6 +- tests/common/TemplateParser.nodes.phpt | 92 ++--- tests/helpers.php | 2 +- tests/phpParser/args.phpt | 105 +++--- tests/phpParser/arrayDef.phpt | 181 +++++---- tests/phpParser/arrayDeref.phpt | 147 ++++---- tests/phpParser/arrayDestructuring.phpt | 133 ++++--- tests/phpParser/arraySpread.phpt | 249 +++++++------ tests/phpParser/arrowFunction.phpt | 149 ++++---- tests/phpParser/assign.phpt | 259 +++++++------ tests/phpParser/cast.phpt | 89 +++-- tests/phpParser/clone.phpt | 289 ++++++++------- tests/phpParser/closure.phpt | 131 ++++--- tests/phpParser/comparison.phpt | 151 ++++---- tests/phpParser/constantDeref.phpt | 279 +++++++------- tests/phpParser/constantFetch.phpt | 113 +++--- tests/phpParser/defaultValues.phpt | 155 ++++---- tests/phpParser/docString.phpt | 125 ++++--- tests/phpParser/errorSuppress.phpt | 49 ++- tests/phpParser/explicitOctal.phpt | 65 ++-- tests/phpParser/exprInIsset.phpt | 51 ++- tests/phpParser/exprInList.phpt | 59 ++- tests/phpParser/filters.phpt | 211 ++++++----- tests/phpParser/filtersNullsafe.phpt | 189 +++++----- tests/phpParser/firstClassCallables.phpt | 75 ++-- tests/phpParser/float.phpt | 131 ++++--- tests/phpParser/funcCall.phpt | 113 +++--- tests/phpParser/in.phpt | 87 +++-- tests/phpParser/indirectCall.phpt | 347 +++++++++--------- tests/phpParser/int.phpt | 83 +++-- tests/phpParser/interpolatedNegVarOffset.phpt | 89 +++-- tests/phpParser/interpolatedString.phpt | 249 +++++++------ tests/phpParser/isset.phpt | 95 +++-- tests/phpParser/issetAndEmpty.phpt | 101 +++-- tests/phpParser/listAssign.phpt | 211 ++++++----- tests/phpParser/listReferences.phpt | 101 +++-- tests/phpParser/listWithKeys.phpt | 91 +++-- tests/phpParser/literals.phpt | 99 +++-- tests/phpParser/logic.phpt | 185 +++++----- tests/phpParser/match.phpt | 173 +++++---- tests/phpParser/math.phpt | 287 ++++++++------- tests/phpParser/misc.phpt | 123 +++---- tests/phpParser/modifier.phpt | 79 ++-- tests/phpParser/modifierNullsafe.phpt | 79 ++-- tests/phpParser/namedArgs.phpt | 75 ++-- tests/phpParser/new.phpt | 321 ++++++++-------- tests/phpParser/newDeref.phpt | 93 +++-- tests/phpParser/newInstanceofExpr.phpt | 83 +++-- tests/phpParser/nullsafe.phpt | 101 +++-- tests/phpParser/numberSeparators.phpt | 71 ++-- tests/phpParser/objectAccess.phpt | 135 ++++--- tests/phpParser/pipe.phpt | 101 +++-- tests/phpParser/simpleArrayAccess.phpt | 89 +++-- tests/phpParser/staticCall.phpt | 177 +++++---- tests/phpParser/staticProperty.phpt | 113 +++--- tests/phpParser/staticPropertyFetch.phpt | 81 ++-- tests/phpParser/string.phpt | 83 +++-- tests/phpParser/stringDeref.phpt | 69 ++-- tests/phpParser/ternaryAndCoalesce.phpt | 191 +++++----- tests/phpParser/trailingCommas.phpt | 135 ++++--- tests/phpParser/typeDeclarations.phpt | 139 ++++--- tests/phpParser/undefinedsafe.phpt | 121 +++--- tests/phpParser/unicodeEscape.phpt | 59 ++- tests/phpParser/unquotedStrings.phpt | 71 ++-- tests/phpParser/variable.phpt | 65 ++-- tests/phpParser/variadic.phpt | 109 +++--- tests/rewriter/Position.length.phpt | 118 ++++++ 73 files changed, 4594 insertions(+), 4497 deletions(-) create mode 100644 tests/rewriter/Position.length.phpt diff --git a/phpstan.neon b/phpstan.neon index 2c59414e3..c595acd52 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -45,6 +45,7 @@ parameters: paths: - src/Latte/Compiler/TagParser.php - src/Latte/Compiler/TemplateParser.php + - src/Latte/Compiler/TemplateParserHtml.php - # TemplateParser: nullable Tag when processing nested tags message: '#on Latte\\Compiler\\Tag\|null#' @@ -65,7 +66,7 @@ parameters: # --- TagParser: generated trait TagParserData --- - # Methods called from generated trait TagParserData (excluded from analysis) - message: '#^(Static method|Method) Latte\\Compiler\\TagParser::(checkFunctionName|handleBuiltinTypes|parseOffset|parseDocString)\(\) is unused\.$#' + message: '#^(Static method|Method) Latte\\Compiler\\TagParser::(checkFunctionName|handleBuiltinTypes|parseOffset|parseDocString|createPosition)\(\) is unused\.$#' path: src/Latte/Compiler/TagParser.php - # Internal parser state machine — types from regex results and token operations diff --git a/src/Latte/Compiler/Position.php b/src/Latte/Compiler/Position.php index 54e745a15..2d9a722a8 100644 --- a/src/Latte/Compiler/Position.php +++ b/src/Latte/Compiler/Position.php @@ -15,14 +15,29 @@ */ final readonly class Position { + public static function range(?self $start, ?self $end): ?self + { + return $start && $end + ? $start->withLength($end->offset + $end->length - $start->offset) + : $start; + } + + public function __construct( public int $line = 1, public int $column = 1, public int $offset = 0, + public ?int $length = null, ) { } + public function withLength(int $length): self + { + return new self($this->line, $this->column, $this->offset, $length); + } + + /** * Returns a new position advanced by the length of the given string. */ diff --git a/src/Latte/Compiler/TagParser.php b/src/Latte/Compiler/TagParser.php index af95d4da1..93eab17e6 100644 --- a/src/Latte/Compiler/TagParser.php +++ b/src/Latte/Compiler/TagParser.php @@ -139,7 +139,7 @@ public function tryConsumeTokenBeforeUnquotedString(string ...$kind): ?Token { $token = $this->stream->peek(); return $token->is(...$kind) // is followed by whitespace - && $this->stream->peek(1)->position->offset > $token->position->offset + strlen($token->text) + && $this->stream->peek(1)->position->offset > $token->position->offset + $token->position->length ? $this->stream->consume() : null; } @@ -164,6 +164,7 @@ private function parse(string $schema, bool $recovery = false): mixed { $symbol = self::SymbolNone; // We start off with no lookahead-token $this->startTokenStack = []; // Keep stack of start token + $this->endTokenStack = []; // Keep stack of end token $token = null; $state = 0; // Start off in the initial state and keep a stack of previous states $stateStack = [$state]; @@ -177,7 +178,7 @@ private function parse(string $schema, bool $recovery = false): mixed } else { if ($symbol === self::SymbolNone) { $recovery = $recovery - ? [$this->stream->getIndex(), $state, $stateStack, $stackPos, $this->semValue, $this->semStack, $this->startTokenStack] + ? [$this->stream->getIndex(), $state, $stateStack, $stackPos, $this->semValue, $this->semStack, $this->startTokenStack, $this->endTokenStack] : null; @@ -208,6 +209,7 @@ private function parse(string $schema, bool $recovery = false): mixed $stateStack[$stackPos] = $state = $action; $this->semStack[$stackPos] = $token->text; $this->startTokenStack[$stackPos] = $token; + $this->endTokenStack[$stackPos] = $token; $symbol = self::SymbolNone; if ($action < self::NumNonLeafStates) { continue; @@ -228,6 +230,7 @@ private function parse(string $schema, bool $recovery = false): mixed return $this->semValue; } elseif ($rule !== self::UnexpectedTokenRule) { // reduce + $lastEndToken = $this->endTokenStack[$stackPos] ?? $token; $this->reduce($rule, $stackPos); // Goto - shift nonterminal @@ -244,12 +247,13 @@ private function parse(string $schema, bool $recovery = false): mixed ++$stackPos; $stateStack[$stackPos] = $state; $this->semStack[$stackPos] = $this->semValue; + $this->endTokenStack[$stackPos] = $lastEndToken; if ($ruleLength === 0) { $this->startTokenStack[$stackPos] = $token; } } elseif ($recovery && $this->isExpectedEof($state)) { // recoverable error - [, $state, $stateStack, $stackPos, $this->semValue, $this->semStack, $this->startTokenStack] = $recovery; + [, $state, $stateStack, $stackPos, $this->semValue, $this->semStack, $this->startTokenStack, $this->endTokenStack] = $recovery; $this->stream->seek($recovery[0]); $token = new Token(Token::End, ''); goto recovery; @@ -291,6 +295,15 @@ private function isExpectedEof(int $state): bool } + private function createPosition(int $startPos, int $endPos): ?Position + { + return Position::range( + $this->startTokenStack[$startPos]->position, + $this->endTokenStack[$endPos]->position, + ); + } + + public function throwReservedKeywordException(Token $token): never { throw new Latte\CompileException("Keyword '$token->text' cannot be used in Latte.", $token->position); diff --git a/src/Latte/Compiler/TagParserData.php b/src/Latte/Compiler/TagParserData.php index b102b540c..fe1aec772 100644 --- a/src/Latte/Compiler/TagParserData.php +++ b/src/Latte/Compiler/TagParserData.php @@ -429,15 +429,18 @@ trait TagParserData /** @var array Start attribute stack */ protected array $startTokenStack; + /** @var array End attribute stack */ + protected array $endTokenStack; + protected function reduce(int $rule, int $pos): void { (match ($rule) { 0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 57, 72, 74, 87, 107, 108, 113, 114, 183, 189, 190, 200, 202, 206, 207, 209, 210, 212, 223, 228, 229, 234, 235, 237, 238, 239, 240, 241, 243, 245, 246, 247, 249, 253, 254, 258, 262, 269, 271, 272, 274, 279, 297, 309 => fn() => $this->semValue = $this->semStack[$pos], - 2 => fn() => $this->semValue = new Node\ModifierNode($this->semStack[$pos], position: $this->startTokenStack[$pos]->position), - 3 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos], position: $this->startTokenStack[$pos]->position), - 22, 23, 24, 25, 26, 62, 63, 64 => fn() => $this->semValue = new Node\IdentifierNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 27 => fn() => $this->semValue = new Expression\VariableNode(substr($this->semStack[$pos], 1), $this->startTokenStack[$pos]->position), + 2 => fn() => $this->semValue = new Node\ModifierNode($this->semStack[$pos], position: $this->createPosition($pos, $pos)), + 3 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos], position: $this->createPosition($pos, $pos)), + 22, 23, 24, 25, 26, 62, 63, 64 => fn() => $this->semValue = new Node\IdentifierNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 27 => fn() => $this->semValue = new Expression\VariableNode(substr($this->semStack[$pos], 1), $this->createPosition($pos, $pos)), 30, 40, 51, 95, 105, 106, 168, 169, 192, 193, 208, 236, 244, 270, 273, 305 => fn() => $this->semValue = $this->semStack[$pos - 1], 31, 39, 52, 75, 79, 91, 104, 191, 211 => fn() => $this->semValue = [], 32, 41, 53, 77, 84, 97, 100, 194, 278, 293 => fn() => $this->semValue = [$this->semStack[$pos]], @@ -447,185 +450,180 @@ protected function reduce(int $rule, int $pos): void }, 34, 36 => fn() => $this->semValue = false, 35, 37 => fn() => $this->semValue = true, - 38 => fn() => $this->semValue = new Expression\MatchNode($this->semStack[$pos - 4], $this->semStack[$pos - 1], $this->startTokenStack[$pos - 6]->position), - 43 => fn() => $this->semValue = new Node\MatchArmNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 44 => fn() => $this->semValue = new Node\MatchArmNode(null, $this->semStack[$pos], $this->startTokenStack[$pos - 3]->position), + 38 => fn() => $this->semValue = new Expression\MatchNode($this->semStack[$pos - 4], $this->semStack[$pos - 1], $this->createPosition($pos - 6, $pos)), + 43 => fn() => $this->semValue = new Node\MatchArmNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 44 => fn() => $this->semValue = new Node\MatchArmNode(null, $this->semStack[$pos], $this->createPosition($pos - 3, $pos)), 45 => fn() => $this->semValue = [null, ...$this->semStack[$pos]], 46 => fn() => $this->semValue = [$this->semStack[$pos - 2], ...$this->semStack[$pos]], 47, 49 => fn() => $this->semValue = [$this->semStack[$pos], false], 48 => fn() => $this->semValue = [$this->semStack[$pos], true], 50 => fn() => $this->semValue = [$this->convertArrayToList($this->semStack[$pos]), false], - 55 => fn() => $this->semValue = new Node\ParameterNode($this->semStack[$pos], null, $this->semStack[$pos - 3], $this->semStack[$pos - 2], $this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), - 56 => fn() => $this->semValue = new Node\ParameterNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->semStack[$pos - 5], $this->semStack[$pos - 4], $this->semStack[$pos - 3], $this->startTokenStack[$pos - 5]->position), - 58 => fn() => $this->semValue = new Node\NullableTypeNode($this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 59 => fn() => $this->semValue = new Node\UnionTypeNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 60 => fn() => $this->semValue = new Node\IntersectionTypeNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), + 55 => fn() => $this->semValue = new Node\ParameterNode($this->semStack[$pos], null, $this->semStack[$pos - 3], $this->semStack[$pos - 2], $this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), + 56 => fn() => $this->semValue = new Node\ParameterNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->semStack[$pos - 5], $this->semStack[$pos - 4], $this->semStack[$pos - 3], $this->createPosition($pos - 5, $pos)), + 58 => fn() => $this->semValue = new Node\NullableTypeNode($this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 59 => fn() => $this->semValue = new Node\UnionTypeNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 60 => fn() => $this->semValue = new Node\IntersectionTypeNode($this->semStack[$pos], $this->createPosition($pos, $pos)), 61 => fn() => $this->semValue = TagParser::handleBuiltinTypes($this->semStack[$pos]), 65, 67, 69 => fn() => $this->semValue = [$this->semStack[$pos - 2], $this->semStack[$pos]], 71, 73, 233 => fn() => $this->semValue = null, 76, 80, 92 => fn() => $this->semValue = $this->semStack[$pos - 2], - 81 => fn() => $this->semValue = [new Node\ArgumentNode($this->semStack[$pos - 2], false, false, null, $this->startTokenStack[$pos - 3]->position)], + 81 => fn() => $this->semValue = [new Node\ArgumentNode($this->semStack[$pos - 2], false, false, null, $this->createPosition($pos - 3, $pos))], 82, 93 => fn() => $this->semValue = [$this->semStack[$pos - 1]], - 83 => fn() => $this->semValue = [new Node\ArgumentNode($this->semStack[$pos - 2], false, false, null, $this->startTokenStack[$pos - 2]->position), $this->semStack[$pos]], - 86 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, false, null, $this->startTokenStack[$pos]->position), - 88 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], true, false, null, $this->startTokenStack[$pos - 1]->position), - 89 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, true, null, $this->startTokenStack[$pos - 1]->position), - 90 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, false, $this->semStack[$pos - 2], $this->startTokenStack[$pos - 2]->position), - 94 => fn() => $this->semValue = new Node\VariadicPlaceholderNode($this->startTokenStack[$pos]->position), - 98, 99 => fn() => $this->semValue = new Expression\FilterCallNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), + 83 => fn() => $this->semValue = [new Node\ArgumentNode($this->semStack[$pos - 2], false, false, null, $this->createPosition($pos - 2, $pos)), $this->semStack[$pos]], + 86 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, false, null, $this->createPosition($pos, $pos)), + 88 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], true, false, null, $this->createPosition($pos - 1, $pos)), + 89 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, true, null, $this->createPosition($pos - 1, $pos)), + 90 => fn() => $this->semValue = new Node\ArgumentNode($this->semStack[$pos], false, false, $this->semStack[$pos - 2], $this->createPosition($pos - 2, $pos)), + 94 => fn() => $this->semValue = new Node\VariadicPlaceholderNode($this->createPosition($pos, $pos)), + 98, 99 => fn() => $this->semValue = new Expression\FilterCallNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), 101, 291, 292 => function () use ($pos) { $this->semStack[$pos - 1][] = $this->semStack[$pos]; $this->semValue = $this->semStack[$pos - 1]; }, - 102 => fn() => $this->semValue = new Node\FilterNode($this->semStack[$pos - 1], $this->semStack[$pos], false, $this->startTokenStack[$pos - 2]->position), - 103 => fn() => $this->semValue = new Node\FilterNode($this->semStack[$pos - 1], $this->semStack[$pos], true, $this->startTokenStack[$pos - 2]->position), - 109, 111 => fn() => $this->semValue = new Expression\AssignNode($this->semStack[$pos - 2], $this->semStack[$pos], false, $this->startTokenStack[$pos - 2]->position), - 110 => fn() => $this->semValue = new Expression\AssignNode($this->convertArrayToList($this->semStack[$pos - 2]), $this->semStack[$pos], false, $this->startTokenStack[$pos - 2]->position), - 112 => fn() => $this->semValue = new Expression\AssignNode($this->semStack[$pos - 3], $this->semStack[$pos], true, $this->startTokenStack[$pos - 3]->position), - 115 => fn() => $this->semValue = new Expression\FunctionCallNode(new Node\NameNode($this->semStack[$pos - 1], Node\NameNode::KindNormal, $this->startTokenStack[$pos - 1]->position), $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 116 => fn() => $this->semValue = new Expression\CloneNode($this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 117 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '+', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 118 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '-', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 119 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '*', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 120 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '/', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 121 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '.', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 122 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '%', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 123 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '&', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 124 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '|', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 125 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '^', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 126 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '<<', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 127 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '>>', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 128 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '**', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 129 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '??', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 130 => fn() => $this->semValue = new Expression\PostOpNode($this->semStack[$pos - 1], '++', $this->startTokenStack[$pos - 1]->position), - 131 => fn() => $this->semValue = new Expression\PreOpNode($this->semStack[$pos], '++', $this->startTokenStack[$pos - 1]->position), - 132 => fn() => $this->semValue = new Expression\PostOpNode($this->semStack[$pos - 1], '--', $this->startTokenStack[$pos - 1]->position), - 133 => fn() => $this->semValue = new Expression\PreOpNode($this->semStack[$pos], '--', $this->startTokenStack[$pos - 1]->position), - 134 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '||', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 135 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '&&', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 136 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'or', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 137 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'and', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 138 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'xor', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 139 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '|', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 140, 141 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '&', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 142 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '^', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 143 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '.', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 144 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '+', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 145 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '-', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 146 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '*', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 147 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '/', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 148 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '%', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 149 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<<', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 150 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>>', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 151 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '**', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 152 => fn() => $this->semValue = new Expression\InNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 153 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '+', $this->startTokenStack[$pos - 1]->position), - 154 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '-', $this->startTokenStack[$pos - 1]->position), - 155 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '!', $this->startTokenStack[$pos - 1]->position), - 156 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '~', $this->startTokenStack[$pos - 1]->position), - 157 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '===', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 158 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '!==', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 159 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '==', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 160 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '!=', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 161 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<=>', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 162 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 163 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<=', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 164 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 165 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>=', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 166 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '|>', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 167 => fn() => $this->semValue = new Expression\InstanceofNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 170 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 4], $this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 4]->position), - 171 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 3], null, $this->semStack[$pos], $this->startTokenStack[$pos - 3]->position), - 172 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 2], $this->semStack[$pos], null, $this->startTokenStack[$pos - 2]->position), - 173 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '??', $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 174 => fn() => $this->semValue = new Expression\IssetNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), - 175 => fn() => $this->semValue = new Expression\EmptyNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), - 176 => fn() => $this->semValue = new Expression\CastNode('int', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 177 => fn() => $this->semValue = new Expression\CastNode('float', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 178 => fn() => $this->semValue = new Expression\CastNode('string', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 179 => fn() => $this->semValue = new Expression\CastNode('array', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 180 => fn() => $this->semValue = new Expression\CastNode('object', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 181 => fn() => $this->semValue = new Expression\CastNode('bool', $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), - 182 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '@', $this->startTokenStack[$pos - 1]->position), - 184 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 6], $this->semStack[$pos - 4], [], $this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 7]->position), - 185 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 10], $this->semStack[$pos - 8], $this->semStack[$pos - 6], $this->semStack[$pos - 5], $this->semStack[$pos - 2], $this->startTokenStack[$pos - 11]->position), - 186 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 7], $this->semStack[$pos - 5], $this->semStack[$pos - 3], $this->semStack[$pos - 2], null, $this->startTokenStack[$pos - 8]->position), - 187 => fn() => $this->semValue = new Expression\NewNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 188 => fn() => $this->semValue = new Expression\NewNode($this->semStack[$pos], [], $this->startTokenStack[$pos - 1]->position), - 196 => fn() => $this->semValue = new Node\ClosureUseNode($this->semStack[$pos], $this->semStack[$pos - 1], $this->startTokenStack[$pos - 1]->position), - 197, 198 => fn() => $this->semValue = $this->checkFunctionName(new Expression\FunctionCallNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position)), - 199 => fn() => $this->semValue = new Expression\StaticMethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], $this->startTokenStack[$pos - 3]->position), - 201, 204 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], Node\NameNode::KindNormal, $this->startTokenStack[$pos]->position), - 203 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], -1, $this->startTokenStack[$pos]->position), - 205 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], Node\NameNode::KindFullyQualified, $this->startTokenStack[$pos]->position), - 213 => fn() => $this->semValue = new Expression\ConstantFetchNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 214 => fn() => $this->semValue = new Expression\ClassConstantFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 215 => fn() => $this->semValue = new Expression\ClassConstantFetchNode($this->semStack[$pos - 4], $this->semStack[$pos - 1], $this->startTokenStack[$pos - 4]->position), - 216 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 2]->position), - 217 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), + 102 => fn() => $this->semValue = new Node\FilterNode($this->semStack[$pos - 1], $this->semStack[$pos], false, $this->createPosition($pos - 2, $pos)), + 103 => fn() => $this->semValue = new Node\FilterNode($this->semStack[$pos - 1], $this->semStack[$pos], true, $this->createPosition($pos - 2, $pos)), + 109, 111 => fn() => $this->semValue = new Expression\AssignNode($this->semStack[$pos - 2], $this->semStack[$pos], false, $this->createPosition($pos - 2, $pos)), + 110 => fn() => $this->semValue = new Expression\AssignNode($this->convertArrayToList($this->semStack[$pos - 2]), $this->semStack[$pos], false, $this->createPosition($pos - 2, $pos)), + 112 => fn() => $this->semValue = new Expression\AssignNode($this->semStack[$pos - 3], $this->semStack[$pos], true, $this->createPosition($pos - 3, $pos)), + 115 => fn() => $this->semValue = new Expression\FunctionCallNode(new Node\NameNode($this->semStack[$pos - 1], Node\NameNode::KindNormal, $this->createPosition($pos - 1, $pos)), $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 116 => fn() => $this->semValue = new Expression\CloneNode($this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 117 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '+', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 118 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '-', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 119 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '*', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 120 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '/', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 121 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '.', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 122 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '%', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 123 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '&', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 124 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '|', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 125 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '^', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 126 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '<<', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 127 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '>>', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 128 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '**', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 129 => fn() => $this->semValue = new Expression\AssignOpNode($this->semStack[$pos - 2], '??', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 130 => fn() => $this->semValue = new Expression\PostOpNode($this->semStack[$pos - 1], '++', $this->createPosition($pos - 1, $pos)), + 131 => fn() => $this->semValue = new Expression\PreOpNode($this->semStack[$pos], '++', $this->createPosition($pos - 1, $pos)), + 132 => fn() => $this->semValue = new Expression\PostOpNode($this->semStack[$pos - 1], '--', $this->createPosition($pos - 1, $pos)), + 133 => fn() => $this->semValue = new Expression\PreOpNode($this->semStack[$pos], '--', $this->createPosition($pos - 1, $pos)), + 134 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '||', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 135 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '&&', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 136 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'or', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 137 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'and', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 138 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], 'xor', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 139 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '|', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 140, 141 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '&', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 142 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '^', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 143 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '.', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 144 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '+', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 145 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '-', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 146 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '*', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 147 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '/', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 148 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '%', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 149 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<<', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 150 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>>', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 151 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '**', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 152 => fn() => $this->semValue = new Expression\InNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 153 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '+', $this->createPosition($pos - 1, $pos)), + 154 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '-', $this->createPosition($pos - 1, $pos)), + 155 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '!', $this->createPosition($pos - 1, $pos)), + 156 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '~', $this->createPosition($pos - 1, $pos)), + 157 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '===', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 158 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '!==', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 159 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '==', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 160 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '!=', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 161 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<=>', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 162 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 163 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '<=', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 164 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 165 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '>=', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 166 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '|>', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 167 => fn() => $this->semValue = new Expression\InstanceofNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 170 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 4], $this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 4, $pos)), + 171 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 3], null, $this->semStack[$pos], $this->createPosition($pos - 3, $pos)), + 172 => fn() => $this->semValue = new Expression\TernaryNode($this->semStack[$pos - 2], $this->semStack[$pos], null, $this->createPosition($pos - 2, $pos)), + 173 => fn() => $this->semValue = new Expression\BinaryOpNode($this->semStack[$pos - 2], '??', $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 174 => fn() => $this->semValue = new Expression\IssetNode($this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), + 175 => fn() => $this->semValue = new Expression\EmptyNode($this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), + 176 => fn() => $this->semValue = new Expression\CastNode('int', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 177 => fn() => $this->semValue = new Expression\CastNode('float', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 178 => fn() => $this->semValue = new Expression\CastNode('string', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 179 => fn() => $this->semValue = new Expression\CastNode('array', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 180 => fn() => $this->semValue = new Expression\CastNode('object', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 181 => fn() => $this->semValue = new Expression\CastNode('bool', $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), + 182 => fn() => $this->semValue = new Expression\UnaryOpNode($this->semStack[$pos], '@', $this->createPosition($pos - 1, $pos)), + 184 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 6], $this->semStack[$pos - 4], [], $this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 7, $pos)), + 185 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 10], $this->semStack[$pos - 8], $this->semStack[$pos - 6], $this->semStack[$pos - 5], $this->semStack[$pos - 2], $this->createPosition($pos - 11, $pos)), + 186 => fn() => $this->semValue = new Expression\ClosureNode((bool) $this->semStack[$pos - 7], $this->semStack[$pos - 5], $this->semStack[$pos - 3], $this->semStack[$pos - 2], null, $this->createPosition($pos - 8, $pos)), + 187 => fn() => $this->semValue = new Expression\NewNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 188 => fn() => $this->semValue = new Expression\NewNode($this->semStack[$pos], [], $this->createPosition($pos - 1, $pos)), + 196 => fn() => $this->semValue = new Node\ClosureUseNode($this->semStack[$pos], $this->semStack[$pos - 1], $this->createPosition($pos - 1, $pos)), + 197, 198 => fn() => $this->semValue = $this->checkFunctionName(new Expression\FunctionCallNode($this->semStack[$pos - 1], $this->semStack[$pos], $this->createPosition($pos - 1, $pos))), + 199 => fn() => $this->semValue = new Expression\StaticMethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], $this->createPosition($pos - 3, $pos)), + 201, 204 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], Node\NameNode::KindNormal, $this->createPosition($pos, $pos)), + 203 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], -1, $this->createPosition($pos, $pos)), + 205 => fn() => $this->semValue = new Node\NameNode($this->semStack[$pos], Node\NameNode::KindFullyQualified, $this->createPosition($pos, $pos)), + 213 => fn() => $this->semValue = new Expression\ConstantFetchNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 214 => fn() => $this->semValue = new Expression\ClassConstantFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 215 => fn() => $this->semValue = new Expression\ClassConstantFetchNode($this->semStack[$pos - 4], $this->semStack[$pos - 1], $this->createPosition($pos - 4, $pos)), + 216 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos - 1], $this->createPosition($pos - 2, $pos)), + 217 => fn() => $this->semValue = new Expression\ArrayNode($this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), 218 => function () use ($pos) { $this->semValue = $this->semStack[$pos]; $this->shortArrays->offsetSet($this->semValue); }, - 219 => fn() => $this->semValue = Scalar\StringNode::parse($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 220 => fn() => $this->semValue = Scalar\InterpolatedStringNode::parse($this->semStack[$pos - 1], $this->startTokenStack[$pos - 2]->position), - 221 => fn() => $this->semValue = Scalar\IntegerNode::parse($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 222 => fn() => $this->semValue = Scalar\FloatNode::parse($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 224, 306 => fn() => $this->semValue = new Scalar\StringNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 225 => fn() => $this->semValue = new Scalar\BooleanNode(true, $this->startTokenStack[$pos]->position), - 226 => fn() => $this->semValue = new Scalar\BooleanNode(false, $this->startTokenStack[$pos]->position), - 227 => fn() => $this->semValue = new Scalar\NullNode($this->startTokenStack[$pos]->position), - 230 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 2], [$this->semStack[$pos - 1]], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position, $this->startTokenStack[$pos]->position), - 231 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 1], [], $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position, $this->startTokenStack[$pos]->position), - 232 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 2], $this->semStack[$pos - 1], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position, $this->startTokenStack[$pos]->position), - 242 => fn() => $this->semValue = new Expression\ConstantFetchNode(new Node\NameNode($this->semStack[$pos], Node\NameNode::KindNormal, $this->startTokenStack[$pos]->position), $this->startTokenStack[$pos]->position), - 248, 263, 298 => fn() => $this->semValue = new Expression\ArrayAccessNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), - 250 => fn() => $this->semValue = new Expression\MethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], false, $this->startTokenStack[$pos - 3]->position), - 251 => fn() => $this->semValue = new Expression\MethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], true, $this->startTokenStack[$pos - 3]->position), + 219 => fn() => $this->semValue = Scalar\StringNode::parse($this->semStack[$pos], $this->createPosition($pos, $pos)), + 220 => fn() => $this->semValue = Scalar\InterpolatedStringNode::parse($this->semStack[$pos - 1], $this->createPosition($pos - 2, $pos)), + 221 => fn() => $this->semValue = Scalar\IntegerNode::parse($this->semStack[$pos], $this->createPosition($pos, $pos)), + 222 => fn() => $this->semValue = Scalar\FloatNode::parse($this->semStack[$pos], $this->createPosition($pos, $pos)), + 224, 306 => fn() => $this->semValue = new Scalar\StringNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 225 => fn() => $this->semValue = new Scalar\BooleanNode(true, $this->createPosition($pos, $pos)), + 226 => fn() => $this->semValue = new Scalar\BooleanNode(false, $this->createPosition($pos, $pos)), + 227 => fn() => $this->semValue = new Scalar\NullNode($this->createPosition($pos, $pos)), + 230 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 2], [$this->semStack[$pos - 1]], $this->semStack[$pos], $this->createPosition($pos - 2, $pos), $this->startTokenStack[$pos]->position), + 231 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 1], [], $this->semStack[$pos], $this->createPosition($pos - 1, $pos), $this->startTokenStack[$pos]->position), + 232 => fn() => $this->semValue = $this->parseDocString($this->semStack[$pos - 2], $this->semStack[$pos - 1], $this->semStack[$pos], $this->createPosition($pos - 2, $pos), $this->startTokenStack[$pos]->position), + 242 => fn() => $this->semValue = new Expression\ConstantFetchNode(new Node\NameNode($this->semStack[$pos], Node\NameNode::KindNormal, $this->createPosition($pos, $pos)), $this->createPosition($pos, $pos)), + 248, 263, 298 => fn() => $this->semValue = new Expression\ArrayAccessNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), + 250 => fn() => $this->semValue = new Expression\MethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], false, $this->createPosition($pos - 3, $pos)), + 251 => fn() => $this->semValue = new Expression\MethodCallNode($this->semStack[$pos - 3], $this->semStack[$pos - 1], $this->semStack[$pos], true, $this->createPosition($pos - 3, $pos)), 252 => function () use ($pos) { - $this->semValue = new Expression\MethodCallNode(new Expression\BinaryOpNode($this->semStack[$pos - 3], '??', new Scalar\NullNode($this->startTokenStack[$pos - 3]->position), $this->startTokenStack[$pos - 3]->position), $this->semStack[$pos - 1], $this->semStack[$pos], true, $this->startTokenStack[$pos - 3]->position); - trigger_error('Latte: undefined-nullsafe operator ??-> is deprecated, used ' . $this->startTokenStack[$pos - 3]->position); + $this->semValue = new Expression\MethodCallNode(new Expression\BinaryOpNode($this->semStack[$pos - 3], '??', new Scalar\NullNode($this->createPosition($pos - 3, $pos)), $this->createPosition($pos - 3, $pos)), $this->semStack[$pos - 1], $this->semStack[$pos], true, $this->createPosition($pos - 3, $pos)); + trigger_error('Latte: undefined-nullsafe operator ??-> is deprecated, used ' . $this->createPosition($pos - 3, $pos)); }, - 255, 264, 299 => fn() => $this->semValue = new Expression\PropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], false, $this->startTokenStack[$pos - 2]->position), - 256, 265, 300 => fn() => $this->semValue = new Expression\PropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], true, $this->startTokenStack[$pos - 2]->position), + 255, 264, 299 => fn() => $this->semValue = new Expression\PropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], false, $this->createPosition($pos - 2, $pos)), + 256, 265, 300 => fn() => $this->semValue = new Expression\PropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], true, $this->createPosition($pos - 2, $pos)), 257, 266, 301 => function () use ($pos) { - $this->semValue = new Expression\PropertyFetchNode(new Expression\BinaryOpNode($this->semStack[$pos - 2], '??', new Scalar\NullNode($this->startTokenStack[$pos - 2]->position), $this->startTokenStack[$pos - 2]->position), $this->semStack[$pos], true, $this->startTokenStack[$pos - 2]->position); - trigger_error('Latte: undefined-nullsafe operator ??-> is deprecated, used ' . $this->startTokenStack[$pos - 2]->position); + $this->semValue = new Expression\PropertyFetchNode(new Expression\BinaryOpNode($this->semStack[$pos - 2], '??', new Scalar\NullNode($this->createPosition($pos - 2, $pos)), $this->createPosition($pos - 2, $pos)), $this->semStack[$pos], true, $this->createPosition($pos - 2, $pos)); + trigger_error('Latte: undefined-nullsafe operator ??-> is deprecated, used ' . $this->createPosition($pos - 2, $pos)); }, - 259 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position), + 259 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos)), 260 => function () use ($pos) { $var = $this->semStack[$pos]->name; - $this->semValue = is_string($var) - ? new Node\VarLikeIdentifierNode($var, $this->startTokenStack[$pos]->position) - : $var; + $this->semValue = is_string($var) ? new Node\VarLikeIdentifierNode($var, $this->createPosition($pos, $pos)) : $var; }, - 261, 267, 268 => fn() => $this->semValue = new Expression\StaticPropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), - 275 => fn() => $this->semValue = $this->convertArrayToList(new Expression\ArrayNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 3]->position)), + 261, 267, 268 => fn() => $this->semValue = new Expression\StaticPropertyFetchNode($this->semStack[$pos - 2], $this->semStack[$pos], $this->createPosition($pos - 2, $pos)), + 275 => fn() => $this->semValue = $this->convertArrayToList(new Expression\ArrayNode($this->semStack[$pos - 1], $this->createPosition($pos - 3, $pos))), 276 => function () use ($pos) { $this->semValue = $this->semStack[$pos]; $end = count($this->semValue) - 1; - if ( - $this->semValue[$end]->value instanceof Expression\TemporaryNode - && !$this->semValue[$end]->value->value - ) { + if ($this->semValue[$end]->value instanceof Expression\TemporaryNode && !$this->semValue[$end]->value->value) { array_pop($this->semValue); } }, - 280 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), null, false, false, $this->startTokenStack[$pos]->position), - 281 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode($this->semStack[$pos], $this->startTokenStack[$pos - 2]->position), $this->semStack[$pos - 2], false, false, $this->startTokenStack[$pos - 2]->position), - 282 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode(null), null, false, false, $this->startTokenStack[$pos]->position), - 283 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, false, false, $this->startTokenStack[$pos]->position), - 284 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, true, false, $this->startTokenStack[$pos - 1]->position), - 285, 287 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], $this->semStack[$pos - 2], false, false, $this->startTokenStack[$pos - 2]->position), - 286, 288 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], $this->semStack[$pos - 3], true, false, $this->startTokenStack[$pos - 3]->position), - 289, 290 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, false, true, $this->startTokenStack[$pos - 1]->position), + 280 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode($this->semStack[$pos], $this->createPosition($pos, $pos)), null, false, false, $this->createPosition($pos, $pos)), + 281 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode($this->semStack[$pos], $this->createPosition($pos - 2, $pos)), $this->semStack[$pos - 2], false, false, $this->createPosition($pos - 2, $pos)), + 282 => fn() => $this->semValue = new Node\ArrayItemNode(new Expression\TemporaryNode(null), null, false, false, $this->createPosition($pos, $pos)), + 283 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, false, false, $this->createPosition($pos, $pos)), + 284 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, true, false, $this->createPosition($pos - 1, $pos)), + 285, 287 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], $this->semStack[$pos - 2], false, false, $this->createPosition($pos - 2, $pos)), + 286, 288 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], $this->semStack[$pos - 3], true, false, $this->createPosition($pos - 3, $pos)), + 289, 290 => fn() => $this->semValue = new Node\ArrayItemNode($this->semStack[$pos], null, false, true, $this->createPosition($pos - 1, $pos)), 294 => fn() => $this->semValue = [$this->semStack[$pos - 1], $this->semStack[$pos]], - 295 => fn() => $this->semValue = new Node\InterpolatedStringPartNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 296 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 302, 303 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos - 1], $this->startTokenStack[$pos - 2]->position), - 304 => fn() => $this->semValue = new Expression\ArrayAccessNode($this->semStack[$pos - 4], $this->semStack[$pos - 2], $this->startTokenStack[$pos - 5]->position), - 307 => fn() => $this->semValue = TagParser::parseOffset($this->semStack[$pos], $this->startTokenStack[$pos]->position), - 308 => fn() => $this->semValue = TagParser::parseOffset('-' . $this->semStack[$pos], $this->startTokenStack[$pos - 1]->position), + 295 => fn() => $this->semValue = new Node\InterpolatedStringPartNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 296 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos], $this->createPosition($pos, $pos)), + 302, 303 => fn() => $this->semValue = new Expression\VariableNode($this->semStack[$pos - 1], $this->createPosition($pos - 2, $pos)), + 304 => fn() => $this->semValue = new Expression\ArrayAccessNode($this->semStack[$pos - 4], $this->semStack[$pos - 2], $this->createPosition($pos - 5, $pos)), + 307 => fn() => $this->semValue = TagParser::parseOffset($this->semStack[$pos], $this->createPosition($pos, $pos)), + 308 => fn() => $this->semValue = TagParser::parseOffset('-' . $this->semStack[$pos], $this->createPosition($pos - 1, $pos)), })(); } } diff --git a/src/Latte/Compiler/TemplateParser.php b/src/Latte/Compiler/TemplateParser.php index 38c12d21d..3293df178 100644 --- a/src/Latte/Compiler/TemplateParser.php +++ b/src/Latte/Compiler/TemplateParser.php @@ -15,7 +15,7 @@ use Latte\Policy; use Latte\Runtime\Template; use Latte\SecurityViolationException; -use function array_keys, array_splice, count, end, explode, implode, in_array, preg_match, str_ends_with, str_starts_with, strlen, substr, trim, ucfirst; +use function array_keys, array_splice, count, end, in_array, preg_match, str_ends_with, str_starts_with, strlen, substr, trim, ucfirst; /** @@ -270,7 +270,9 @@ public function parseLatteStatement(?\Closure $resolver = null): ?Node $this->popTag(); - $node->position = $startTag->position; + $node->position = isset($tag) && $tag->closing + ? Position::range($startTag->position, $tag->position) + : $startTag->position; return $node; } @@ -287,17 +289,19 @@ private function parseLatteTag(): Tag $this->lexer->pushState(TemplateLexer::StateLatteTag); $closing = (bool) $stream->tryConsume(Token::Slash); $nameToken = $stream->tryConsume(Token::Latte_Name); + $tokens = $this->consumeTag(); + $void = (bool) $stream->tryConsume(Token::Slash); + $closeToken = $stream->tryConsume(Token::Latte_TagClose) ?? $stream->throwUnexpectedException([Token::Latte_TagClose], addendum: " started $openToken->position"); $tag = new Tag( - position: $openToken->position, + position: Position::range($openToken->position, $closeToken->position), closing: $closing, name: $nameToken ? $nameToken->text : ($closing ? '' : '='), - tokens: $this->consumeTag(), - void: (bool) $stream->tryConsume(Token::Slash), + tokens: $tokens, + void: $void, inHead: $this->inHead, inTag: $inTag, htmlElement: $this->html->getElement(), ); - $stream->tryConsume(Token::Latte_TagClose) || $stream->throwUnexpectedException([Token::Latte_TagClose], addendum: " started $openToken->position"); $this->lexer->popState(); return $tag; } diff --git a/src/Latte/Compiler/TemplateParserHtml.php b/src/Latte/Compiler/TemplateParserHtml.php index 3fc7b9fd9..4df0c633c 100644 --- a/src/Latte/Compiler/TemplateParserHtml.php +++ b/src/Latte/Compiler/TemplateParserHtml.php @@ -25,7 +25,7 @@ final class TemplateParserHtml { private ?Html\ElementNode $element = null; - /** @var array{string, ?Nodes\Php\ExpressionNode}|null */ + /** @var array{string, ?Nodes\Php\ExpressionNode, ?Position}|null */ private ?array $endName = null; /** @var \WeakMap}> */ @@ -91,7 +91,7 @@ private function parseTag(): ?Node && $this->parser->peekTag() === $this->elementData[$this->element]->tag // is directly in the element ) { $save = $stream->getIndex(); - $this->endName = [$endText] = $this->parseEndTag(); + $this->endName = [$endText, $endVariable, $endPosition] = $this->parseEndTag(); if ($this->element->is($endText) || $this->elementData[$this->element]->textualName === $endText) { return null; // go to parseElement() one level up to close the element } @@ -141,11 +141,12 @@ private function parseElement(): Node $this->parser->getLexer()->popState(); } - [$endText, $endVariable] = $this->endName ?? [null, null]; + [$endText, $endVariable, $endPosition] = $this->endName ?? [null, null, null]; $this->endName = null; if ($endText && ($this->element->is($endText) || $this->elementData[$this->element]->textualName === $endText)) { $elem->content = $content; $elem->content->append($this->extractIndentation()); + $elem->position = Position::range($elem->position, $endPosition); } elseif ($outerNodes || $innerNodes || $elem->dynamicTag @@ -221,13 +222,13 @@ private function parseStartTag(&$elem = null): Html\ElementNode if ($variable) { $elem->dynamicTag = new Nodes\Html\TagNode($elem, $variable); } - $stream->consume(Token::Html_TagClose); + $elem->position = Position::range($openToken->position, $stream->consume(Token::Html_TagClose)->position); $lexer->popState(); return $elem; } - /** @return array{string, ?Nodes\Php\ExpressionNode} */ + /** @return array{string, ?Nodes\Php\ExpressionNode, ?Position} */ private function parseEndTag(): array { $stream = $this->parser->getStream(); @@ -238,11 +239,11 @@ private function parseEndTag(): array if (isset($this->element->nAttributes['syntax'])) { // hardcoded $lexer->popSyntax(); } - $name = $this->parseTagName(); + [$text, $variable] = $this->parseTagName(); $stream->tryConsume(Token::Whitespace); - $stream->consume(Token::Html_TagClose); + $closeToken = $stream->consume(Token::Html_TagClose); $lexer->popState(); - return $name; + return [$text, $variable, $closeToken->position]; } @@ -297,11 +298,14 @@ private function parseBogusEndTag(): Html\BogusTagNode $lexer->pushState(TemplateLexer::StateHtmlTag); $this->parser->lastIndentation = null; $this->parser->inHead = false; + $openDelimiter = $openToken->text . $stream->consume(Token::Slash)->text . $stream->consume(Token::Html_Name)->text; + $wsToken = $stream->tryConsume(Token::Whitespace); + $closeToken = $stream->consume(Token::Html_TagClose); $node = new Html\BogusTagNode( - openDelimiter: $openToken->text . $stream->consume(Token::Slash)->text . $stream->consume(Token::Html_Name)->text, - content: new Nodes\TextNode($stream->tryConsume(Token::Whitespace)->text ?? ''), - endDelimiter: $stream->consume(Token::Html_TagClose)->text, - position: $openToken->position, + openDelimiter: $openDelimiter, + content: new Nodes\TextNode($wsToken->text ?? '', $wsToken?->position), + endDelimiter: $closeToken->text, + position: Position::range($openToken->position, $closeToken->position), ); $lexer->popState(); return $node; @@ -318,11 +322,12 @@ private function parseBogusTag(): Html\BogusTagNode $this->parser->inHead = false; $content = $this->parser->parseFragment($this->parser->inTextResolve(...)); $lexer->popState(); + $closeToken = $stream->consume(Token::Html_TagClose); return new Html\BogusTagNode( openDelimiter: $openToken->text, content: $content, - endDelimiter: $stream->consume(Token::Html_TagClose)->text, - position: $openToken->position, + endDelimiter: $closeToken->text, + position: Position::range($openToken->position, $closeToken->position), ); } @@ -370,6 +375,7 @@ private function parseAttribute(FragmentNode $fragment): ?Node } [$value, $quote] = $this->parseAttributeValue() ?? [null, null]; + $position = Position::range($name->position, $this->parser->getStream()->peek(-1)->position); if ($name instanceof Nodes\TextNode && $value instanceof Nodes\PrintNode && $value->modifier->escape) { if (($indent = end($fragment->children)) instanceof Nodes\TextNode && $indent->isWhitespace()) { array_pop($fragment->children); @@ -380,7 +386,7 @@ private function parseAttribute(FragmentNode $fragment): ?Node value: $value->expression, modifier: $value->modifier, indentation: $indent->content ?? null, - position: $name->position, + position: $position, ); } @@ -388,7 +394,7 @@ private function parseAttribute(FragmentNode $fragment): ?Node name: $name, value: $value, quote: $quote, - position: $name->position, + position: $position, ); } @@ -430,19 +436,21 @@ private function parseAttributeValue(): ?array private function parseNAttribute(): Nodes\TextNode { assert($this->element !== null); + $elem = $this->element; $stream = $this->parser->getStream(); $nameToken = $stream->consume(Token::Html_Name); $save = $stream->getIndex(); $pos = $stream->peek()->position; $name = substr($nameToken->text, strlen(TemplateLexer::NPrefix)); - if ($this->parser->peekTag() !== $this->elementData[$this->element]->tag) { + if ($this->parser->peekTag() !== $this->elementData[$elem]->tag) { throw new CompileException("Attribute n:$name must not appear inside {tags}", $nameToken->position); - } elseif (isset($this->element->nAttributes[$name])) { + } elseif (isset($elem->nAttributes[$name])) { throw new CompileException("Found multiple attributes n:$name.", $nameToken->position); } $this->consumeIgnored(); + $endToken = $nameToken; if ($stream->tryConsume(Token::Equals)) { $lexer = $this->parser->getLexer(); $this->consumeIgnored(); @@ -450,18 +458,18 @@ private function parseNAttribute(): Nodes\TextNode $lexer->pushState(TemplateLexer::StateHtmlQuotedNAttrValue, $quoteToken->text); $valueToken = $stream->tryConsume(Token::Text); $pos = $stream->peek()->position; - $stream->tryConsume(Token::Quote) || $stream->throwUnexpectedException([$quoteToken->text], addendum: ", end of n:attribute started $quoteToken->position"); + $endToken = $stream->tryConsume(Token::Quote) ?? $stream->throwUnexpectedException([$quoteToken->text], addendum: ", end of n:attribute started $quoteToken->position"); $lexer->popState(); $tokens = $valueToken ? (new TagLexer)->tokenize($valueToken->text, $valueToken->position) : null; } elseif ($openToken = $stream->tryConsume(Token::Latte_TagOpen)) { $lexer->pushState(TemplateLexer::StateLatteContent); $tokens = $this->parser->consumeTag(); - $stream->tryConsume(Token::Latte_TagClose) || $stream->throwUnexpectedException([Token::Latte_TagClose], addendum: " started $openToken->position"); + $endToken = $stream->tryConsume(Token::Latte_TagClose) ?? $stream->throwUnexpectedException([Token::Latte_TagClose], addendum: " started $openToken->position"); $lexer->popState(); } else { - $valueToken = $stream->consume(Token::Html_Name); + $endToken = $valueToken = $stream->consume(Token::Html_Name); $tokens = (new TagLexer)->tokenize($valueToken->text, $valueToken->position); } } else { @@ -469,15 +477,13 @@ private function parseNAttribute(): Nodes\TextNode } $tokens ??= [new Token(Token::End, '', $pos)]; - assert($nameToken->position !== null); - assert($this->element !== null); - $this->element->nAttributes[$name] = new Tag( + $elem->nAttributes[$name] = new Tag( name: preg_replace('~(inner-|tag-|)~', '', $name), tokens: $tokens, - position: $nameToken->position, + position: Position::range($nameToken->position, $endToken->position), prefix: $this->getPrefix($name), inTag: true, - htmlElement: $this->element, + htmlElement: $elem, nAttribute: $node = new Nodes\TextNode(''), ); return $node; @@ -496,7 +502,8 @@ private function parseComment(): Html\CommentNode position: $openToken->position, content: $this->parser->parseFragment($this->parser->inTextResolve(...)), ); - $stream->tryConsume(Token::Html_CommentClose) || $stream->throwUnexpectedException([Token::Html_CommentClose], addendum: " started $openToken->position"); + $closeToken = $stream->tryConsume(Token::Html_CommentClose) ?? $stream->throwUnexpectedException([Token::Html_CommentClose], addendum: " started $openToken->position"); + $node->position = Position::range($openToken->position, $closeToken->position); $lexer->popState(); return $node; } diff --git a/src/Latte/Compiler/Token.php b/src/Latte/Compiler/Token.php index 460ed1b36..86f52c1a5 100644 --- a/src/Latte/Compiler/Token.php +++ b/src/Latte/Compiler/Token.php @@ -236,11 +236,15 @@ ]; + public readonly ?Position $position; + + public function __construct( public int $type, public string $text, - public ?Position $position = null, + ?Position $position = null, ) { + $this->position = $position?->withLength(strlen($text)); } diff --git a/tests/common/TemplateParser.nodes.phpt b/tests/common/TemplateParser.nodes.phpt index bee785c2d..bb4a47f97 100644 --- a/tests/common/TemplateParser.nodes.phpt +++ b/tests/common/TemplateParser.nodes.phpt @@ -58,8 +58,8 @@ Assert::match(<<<'XX' | | | content: string | | | | '\n | | | | text\n' - | | | position: 1:1 - | position: 1:1 + | | | position: 1:1+6 + | position: 1:1+6 contentType: 'html' position: null XX, parse("\ntext\n")); @@ -74,14 +74,14 @@ Assert::match(<<<'XX' | children: array (3) | | 0 => Latte\Compiler\Nodes\TextNode | | | content: 'foo ' - | | | position: 1:1 + | | | position: 1:1+4 | | 1 => Latte\Compiler\Nodes\TextNode | | | content: '\n' - | | | position: 1:18 + | | | position: 1:18+1 | | 2 => Latte\Compiler\Nodes\TextNode | | | content: ' bar' - | | | position: 2:6 - | position: 1:1 + | | | position: 2:6+4 + | position: 1:1+4 contentType: 'html' position: null XX, parse("foo {* comment *}\n{* *} bar")); @@ -96,10 +96,10 @@ Assert::match(<<<'XX' | children: array (2) | | 0 => Latte\Compiler\Nodes\TextNode | | | content: '\n' - | | | position: 1:1 + | | | position: 1:1+1 | | 1 => FooNode - | | | position: 2:1 - | position: 1:1 + | | | position: 2:1+19 + | position: 1:1+1 contentType: 'html' position: null XX, parse("\n{foo\n} ... \n {/foo}")); @@ -117,51 +117,51 @@ Assert::match(<<<'XX' | | | | children: array (6) | | | | | 0 => Latte\Compiler\Nodes\TextNode | | | | | | content: ' ' - | | | | | | position: 1:4 + | | | | | | position: 1:4+1 | | | | | 1 => Latte\Compiler\Nodes\Html\AttributeNode | | | | | | name: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'attr1' - | | | | | | | position: 1:5 + | | | | | | | position: 1:5+5 | | | | | | value: null | | | | | | quote: null - | | | | | | position: 1:5 + | | | | | | position: 1:5+5 | | | | | 2 => Latte\Compiler\Nodes\TextNode | | | | | | content: ' \n' - | | | | | | position: 1:10 + | | | | | | position: 1:10+2 | | | | | 3 => Latte\Compiler\Nodes\Html\AttributeNode | | | | | | name: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'attr2' - | | | | | | | position: 2:1 + | | | | | | | position: 2:1+5 | | | | | | value: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'val' - | | | | | | | position: 2:7 + | | | | | | | position: 2:7+3 | | | | | | quote: null - | | | | | | position: 2:1 + | | | | | | position: 2:1+9 | | | | | 4 => Latte\Compiler\Nodes\TextNode | | | | | | content: string | | | | | | | '\n | | | | | | | ' - | | | | | | position: 2:10 + | | | | | | position: 2:10+2 | | | | | 5 => Latte\Compiler\Nodes\Html\AttributeNode | | | | | | name: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'attr3' - | | | | | | | position: 3:2 + | | | | | | | position: 3:2+5 | | | | | | value: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'val' - | | | | | | | position: 4:2 + | | | | | | | position: 4:2+3 | | | | | | quote: ''' - | | | | | | position: 3:2 - | | | | position: 1:4 + | | | | | | position: 3:2+12 + | | | | position: 1:4+1 | | | selfClosing: false | | | content: null | | | nAttributes: array (0) | | | dynamicTag: null | | | breakable: false | | | name: 'br' - | | | position: 1:1 + | | | position: 1:1+35 | | | parent: null | | | contentType: 'html' - | position: 1:1 + | position: 1:1+35 contentType: 'html' position: null @@ -180,51 +180,51 @@ Assert::match(<<<'XX' | | | | children: array (6) | | | | | 0 => Latte\Compiler\Nodes\TextNode | | | | | | content: ' ' - | | | | | | position: 1:4 + | | | | | | position: 1:4+1 | | | | | 1 => FooNode - | | | | | | position: 1:5 + | | | | | | position: 1:5+22 | | | | | 2 => Latte\Compiler\Nodes\TextNode | | | | | | content: ' ' - | | | | | | position: 1:27 + | | | | | | position: 1:27+1 | | | | | 3 => Latte\Compiler\Nodes\Html\AttributeNode | | | | | | name: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'attr5' - | | | | | | | position: 1:28 + | | | | | | | position: 1:28+5 | | | | | | value: FooNode - | | | | | | | position: 1:34 + | | | | | | | position: 1:34+12 | | | | | | quote: null - | | | | | | position: 1:28 + | | | | | | position: 1:28+18 | | | | | 4 => Latte\Compiler\Nodes\TextNode | | | | | | content: ' ' - | | | | | | position: 1:46 + | | | | | | position: 1:46+1 | | | | | 5 => Latte\Compiler\Nodes\Html\AttributeNode | | | | | | name: Latte\Compiler\Nodes\TextNode | | | | | | | content: 'attr6' - | | | | | | | position: 1:47 + | | | | | | | position: 1:47+5 | | | | | | value: Latte\Compiler\Nodes\FragmentNode | | | | | | | children: array (3) | | | | | | | | 0 => Latte\Compiler\Nodes\TextNode | | | | | | | | | content: 'c' - | | | | | | | | | position: 1:53 + | | | | | | | | | position: 1:53+1 | | | | | | | | 1 => FooNode - | | | | | | | | | position: 1:54 + | | | | | | | | | position: 1:54+6 | | | | | | | | 2 => Latte\Compiler\Nodes\TextNode | | | | | | | | | content: 'd' - | | | | | | | | | position: 1:60 - | | | | | | | position: 1:53 + | | | | | | | | | position: 1:60+1 + | | | | | | | position: 1:53+1 | | | | | | quote: null - | | | | | | position: 1:47 - | | | | position: 1:4 + | | | | | | position: 1:47+14 + | | | | position: 1:4+1 | | | selfClosing: false | | | content: null | | | nAttributes: array (0) | | | dynamicTag: null | | | breakable: false | | | name: 'br' - | | | position: 1:1 + | | | position: 1:1+61 | | | parent: null | | | contentType: 'html' - | position: 1:1 + | position: 1:1+61 contentType: 'html' position: null @@ -239,8 +239,8 @@ Assert::match(<<<'XX' main: Latte\Compiler\Nodes\FragmentNode | children: array (1) | | 0 => FooNode - | | | position: 1:5 - | position: 1:5 + | | | position: 1:5+5 + | position: 1:5+5 contentType: 'html' position: null XX, parse('
')); @@ -262,19 +262,19 @@ Assert::match(<<<'XX' | | | | children: array (2) | | | | | 0 => Latte\Compiler\Nodes\TextNode | | | | | | content: '\n' - | | | | | | position: 1:4 + | | | | | | position: 1:4+1 | | | | | 1 => Latte\Compiler\Nodes\TextNode | | | | | | content: '...\n' - | | | | | | position: 2:1 - | | | | position: 1:4 + | | | | | | position: 2:1+4 + | | | | position: 1:4+1 | | | nAttributes: array (0) | | | dynamicTag: null | | | breakable: false | | | name: 'p' - | | | position: 1:1 + | | | position: 1:1+12 | | | parent: null | | | contentType: 'html' - | position: 1:1 + | position: 1:1+3 contentType: 'html' position: null diff --git a/tests/helpers.php b/tests/helpers.php index acbde1c95..44c36fbfa 100644 --- a/tests/helpers.php +++ b/tests/helpers.php @@ -54,7 +54,7 @@ function exportNode(Node $node): string { $exporters = [ Position::class => function (Position $pos, Tracy\Dumper\Value $value) { - $value->value = $pos->line . ':' . $pos->column; + $value->value = $pos->line . ':' . $pos->column . (isset($pos->length) ? '+' . $pos->length : ''); }, ]; $dump = Dumper::toText($node, [Dumper::HASH => false, Dumper::DEPTH => 20, Dumper::OBJECT_EXPORTERS => $exporters]); diff --git a/tests/phpParser/args.phpt b/tests/phpParser/args.phpt index a2a647aa7..7a25c67be 100644 --- a/tests/phpParser/args.phpt +++ b/tests/phpParser/args.phpt @@ -1,135 +1,134 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'f' | | | | kind: 1 - | | | | position: 1:1 + | | | | position: 1:1+1 | | | args: array (0) - | | | position: 1:1 + | | | position: 1:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+3 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'f' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+1 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:3 + | | | | | | position: 2:3+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:3 - | | | position: 2:1 + | | | | | position: 2:3+2 + | | | position: 2:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+5 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'f' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+1 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:3 + | | | | | | position: 3:3+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:3 + | | | | | position: 3:3+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:7 + | | | | | | position: 3:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:7 - | | | position: 3:1 + | | | | | position: 3:7+2 + | | | position: 3:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+9 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'f' | | | | kind: 1 - | | | | position: 4:1 + | | | | position: 4:1+1 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:4 + | | | | | | position: 4:4+2 | | | | | byRef: true | | | | | unpack: false | | | | | name: null - | | | | | position: 4:3 - | | | position: 4:1 + | | | | | position: 4:3+3 + | | | position: 4:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+6 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'f' | | | | kind: 1 - | | | | position: 5:1 + | | | | position: 5:1+1 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 5:3 + | | | | | | position: 5:3+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:3 + | | | | | position: 5:3+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 5:10 + | | | | | | position: 5:10+2 | | | | | byRef: false | | | | | unpack: true | | | | | name: null - | | | | | position: 5:7 - | | | position: 5:1 + | | | | | position: 5:7+5 + | | | position: 5:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+12 + position: 1:1+44 diff --git a/tests/phpParser/arrayDef.phpt b/tests/phpParser/arrayDef.phpt index a848be82b..994a0800c 100644 --- a/tests/phpParser/arrayDef.phpt +++ b/tests/phpParser/arrayDef.phpt @@ -1,154 +1,153 @@ - 'd', 'e' => &$f), - - /* short array syntax */ - [], - [1, 2, 3], - ['a' => 'b'], - - /* modern syntax */ - [a: 'b', x: 3], - [y : 'c'], - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + 'd', 'e' => &$f), + + /* short array syntax */ + [], + [1, 2, 3], + ['a' => 'b'], + + /* modern syntax */ + [a: 'b', x: 3], + [y : 'c'], + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (10) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (0) - | | | position: 1:1 + | | | position: 1:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'a' - | | | | | | position: 2:7 + | | | | | | position: 2:7+3 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 2:7 - | | | position: 2:1 + | | | | | position: 2:7+3 + | | | position: 2:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+10 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'a' - | | | | | | position: 3:7 + | | | | | | position: 3:7+3 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 3:7 - | | | position: 3:1 + | | | | | position: 3:7+3 + | | | position: 3:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+12 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'a' - | | | | | | position: 4:7 + | | | | | | position: 4:7+3 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 4:7 + | | | | | position: 4:7+3 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'b' - | | | | | | position: 4:12 + | | | | | | position: 4:12+3 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 4:12 - | | | position: 4:1 + | | | | | position: 4:12+3 + | | | position: 4:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+15 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (4) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'a' - | | | | | | position: 5:7 + | | | | | | position: 5:7+3 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 5:7 + | | | | | position: 5:7+3 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 5:13 + | | | | | | position: 5:13+2 | | | | | key: null | | | | | byRef: true | | | | | unpack: false - | | | | | position: 5:12 + | | | | | position: 5:12+3 | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'd' - | | | | | | position: 5:24 + | | | | | | position: 5:24+3 | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'c' - | | | | | | position: 5:17 + | | | | | | position: 5:17+3 | | | | | byRef: false | | | | | unpack: false - | | | | | position: 5:17 + | | | | | position: 5:17+10 | | | | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'f' - | | | | | | position: 5:37 + | | | | | | position: 5:37+2 | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'e' - | | | | | | position: 5:29 + | | | | | | position: 5:29+3 | | | | | byRef: true | | | | | unpack: false - | | | | | position: 5:29 - | | | position: 5:1 + | | | | | position: 5:29+10 + | | | position: 5:1+39 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+39 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (0) - | | | position: 8:1 + | | | position: 8:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+2 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (3) @@ -156,97 +155,97 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 1 | | | | | | kind: 10 - | | | | | | position: 9:2 + | | | | | | position: 9:2+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:2 + | | | | | position: 9:2+1 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 9:5 + | | | | | | position: 9:5+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:5 + | | | | | position: 9:5+1 | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 3 | | | | | | kind: 10 - | | | | | | position: 9:8 + | | | | | | position: 9:8+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:8 - | | | position: 9:1 + | | | | | position: 9:8+1 + | | | position: 9:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+9 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'b' - | | | | | | position: 10:9 + | | | | | | position: 10:9+3 | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'a' - | | | | | | position: 10:2 + | | | | | | position: 10:2+3 | | | | | byRef: false | | | | | unpack: false - | | | | | position: 10:2 - | | | position: 10:1 + | | | | | position: 10:2+10 + | | | position: 10:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+12 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'b' - | | | | | | position: 13:5 + | | | | | | position: 13:5+3 | | | | | key: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'a' - | | | | | | position: 13:2 + | | | | | | position: 13:2+1 | | | | | byRef: false | | | | | unpack: false - | | | | | position: 13:2 + | | | | | position: 13:2+6 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 3 | | | | | | kind: 10 - | | | | | | position: 13:13 + | | | | | | position: 13:13+1 | | | | | key: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'x' - | | | | | | position: 13:10 + | | | | | | position: 13:10+1 | | | | | byRef: false | | | | | unpack: false - | | | | | position: 13:10 - | | | position: 13:1 + | | | | | position: 13:10+4 + | | | position: 13:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+14 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'c' - | | | | | | position: 14:6 + | | | | | | position: 14:6+3 | | | | | key: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'y' - | | | | | | position: 14:2 + | | | | | | position: 14:2+1 | | | | | byRef: false | | | | | unpack: false - | | | | | position: 14:2 - | | | position: 14:1 + | | | | | position: 14:2+7 + | | | position: 14:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 - position: 1:1 + | | position: 14:1+9 + position: 1:1+195 diff --git a/tests/phpParser/arrayDeref.phpt b/tests/phpParser/arrayDeref.phpt index 9ffe91496..f14dcae78 100644 --- a/tests/phpParser/arrayDeref.phpt +++ b/tests/phpParser/arrayDeref.phpt @@ -1,28 +1,27 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -32,39 +31,39 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 1:2 + | | | | | | | position: 1:2+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:2 + | | | | | | position: 1:2+1 | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 2 | | | | | | | kind: 10 - | | | | | | | position: 1:5 + | | | | | | | position: 1:5+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:5 + | | | | | | position: 1:5+1 | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 3 | | | | | | | kind: 10 - | | | | | | | position: 1:8 + | | | | | | | position: 1:8+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:8 - | | | | position: 1:1 + | | | | | | position: 1:8+1 + | | | | position: 1:1+9 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 2 | | | | kind: 10 - | | | | position: 1:11 - | | | position: 1:1 + | | | | position: 1:11+1 + | | | position: 1:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+12 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -75,49 +74,49 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 1 | | | | | | | | | kind: 10 - | | | | | | | | | position: 2:2 + | | | | | | | | | position: 2:2+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 2:2 + | | | | | | | | position: 2:2+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 2 | | | | | | | | | kind: 10 - | | | | | | | | | position: 2:5 + | | | | | | | | | position: 2:5+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 2:5 + | | | | | | | | position: 2:5+1 | | | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 3 | | | | | | | | | kind: 10 - | | | | | | | | | position: 2:8 + | | | | | | | | | position: 2:8+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 2:8 - | | | | | | position: 2:1 + | | | | | | | | position: 2:8+1 + | | | | | | position: 2:1+9 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 2:11 - | | | | | position: 2:1 + | | | | | | position: 2:11+1 + | | | | | position: 2:1+12 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 2:14 - | | | | position: 2:1 + | | | | | position: 2:14+1 + | | | | position: 2:1+15 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 2:17 - | | | position: 2:1 + | | | | position: 2:17+1 + | | | position: 2:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+18 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayNode @@ -126,39 +125,39 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 4:7 + | | | | | | | position: 4:7+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 4:7 + | | | | | | position: 4:7+1 | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 2 | | | | | | | kind: 10 - | | | | | | | position: 4:10 + | | | | | | | position: 4:10+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 4:10 + | | | | | | position: 4:10+1 | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 3 | | | | | | | kind: 10 - | | | | | | | position: 4:13 + | | | | | | | position: 4:13+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 4:13 - | | | | position: 4:1 + | | | | | | position: 4:13+1 + | | | | position: 4:1+14 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 2 | | | | kind: 10 - | | | | position: 4:16 - | | | position: 4:1 + | | | | position: 4:16+1 + | | | position: 4:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+17 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -169,47 +168,47 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 1 | | | | | | | | | kind: 10 - | | | | | | | | | position: 5:7 + | | | | | | | | | position: 5:7+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 5:7 + | | | | | | | | position: 5:7+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 2 | | | | | | | | | kind: 10 - | | | | | | | | | position: 5:10 + | | | | | | | | | position: 5:10+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 5:10 + | | | | | | | | position: 5:10+1 | | | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 3 | | | | | | | | | kind: 10 - | | | | | | | | | position: 5:13 + | | | | | | | | | position: 5:13+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 5:13 - | | | | | | position: 5:1 + | | | | | | | | position: 5:13+1 + | | | | | | position: 5:1+14 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 5:16 - | | | | | position: 5:1 + | | | | | | position: 5:16+1 + | | | | | position: 5:1+17 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 5:19 - | | | | position: 5:1 + | | | | | position: 5:19+1 + | | | | position: 5:1+20 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 5:22 - | | | position: 5:1 + | | | | position: 5:22+1 + | | | position: 5:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+23 + position: 1:1+78 diff --git a/tests/phpParser/arrayDestructuring.phpt b/tests/phpParser/arrayDestructuring.phpt index 401dd5880..25d7a1dc2 100644 --- a/tests/phpParser/arrayDestructuring.phpt +++ b/tests/phpParser/arrayDestructuring.phpt @@ -1,27 +1,26 @@ - $b, 'b' => $a] = $baz, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $b, 'b' => $a] = $baz, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (4) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode @@ -30,43 +29,43 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 1:2 + | | | | | | | position: 1:2+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 1:2 + | | | | | | position: 1:2+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 1:6 + | | | | | | | position: 1:6+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 1:6 - | | | | position: 1:1 + | | | | | | position: 1:6+2 + | | | | position: 1:1+8 | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | items: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'c' - | | | | | | | position: 1:13 + | | | | | | | position: 1:13+2 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:13 + | | | | | | position: 1:13+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'd' - | | | | | | | position: 1:17 + | | | | | | | position: 1:17+2 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:17 - | | | | position: 1:12 + | | | | | | position: 1:17+2 + | | | | position: 1:12+8 | | | byRef: false - | | | position: 1:1 + | | | position: 1:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+19 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -75,30 +74,30 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 2:4 + | | | | | | | position: 2:4+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 2:4 + | | | | | | position: 2:4+2 | | | | | 2 => null | | | | | 3 => null | | | | | 4 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 2:12 + | | | | | | | position: 2:12+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 2:12 + | | | | | | position: 2:12+2 | | | | | 5 => null - | | | | position: 2:1 + | | | | position: 2:1+17 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'foo' - | | | | position: 2:21 + | | | | position: 2:21+4 | | | byRef: false - | | | position: 2:1 + | | | position: 2:1+24 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+24 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -113,35 +112,35 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | | | name: 'a' - | | | | | | | | | | | | | position: 3:6 + | | | | | | | | | | | | | position: 3:6+2 | | | | | | | | | | | | key: null | | | | | | | | | | | | byRef: false - | | | | | | | | | | | | position: 3:6 - | | | | | | | | | | position: 3:5 + | | | | | | | | | | | | position: 3:6+2 + | | | | | | | | | | position: 3:5+4 | | | | | | | | | key: null | | | | | | | | | byRef: false - | | | | | | | | | position: 3:5 - | | | | | | | position: 3:4 + | | | | | | | | | position: 3:5+4 + | | | | | | | position: 3:4+6 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 3:4 + | | | | | | position: 3:4+6 | | | | | 2 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 3:12 + | | | | | | | position: 3:12+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 3:12 - | | | | position: 3:1 + | | | | | | position: 3:12+2 + | | | | position: 3:1+14 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'bar' - | | | | position: 3:18 + | | | | position: 3:18+4 | | | byRef: false - | | | position: 3:1 + | | | position: 3:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+21 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -149,29 +148,29 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 4:9 + | | | | | | | position: 4:9+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'a' - | | | | | | | position: 4:2 + | | | | | | | position: 4:2+3 | | | | | | byRef: false - | | | | | | position: 4:2 + | | | | | | position: 4:2+9 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 4:20 + | | | | | | | position: 4:20+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'b' - | | | | | | | position: 4:13 + | | | | | | | position: 4:13+3 | | | | | | byRef: false - | | | | | | position: 4:13 - | | | | position: 4:1 + | | | | | | position: 4:13+9 + | | | | position: 4:1+22 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'baz' - | | | | position: 4:26 + | | | | position: 4:26+4 | | | byRef: false - | | | position: 4:1 + | | | position: 4:1+29 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+29 + position: 1:1+100 diff --git a/tests/phpParser/arraySpread.phpt b/tests/phpParser/arraySpread.phpt index 0a019b1ff..52cda723c 100644 --- a/tests/phpParser/arraySpread.phpt +++ b/tests/phpParser/arraySpread.phpt @@ -1,92 +1,91 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'array' - | | | | position: 1:1 + | | | | position: 1:1+6 | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | items: array (3) | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 1:11 + | | | | | | | position: 1:11+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:11 + | | | | | | position: 1:11+1 | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 2 | | | | | | | kind: 10 - | | | | | | | position: 1:14 + | | | | | | | position: 1:14+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:14 + | | | | | | position: 1:14+1 | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 3 | | | | | | | kind: 10 - | | | | | | | position: 1:17 + | | | | | | | position: 1:17+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:17 - | | | | position: 1:10 + | | | | | | position: 1:17+1 + | | | | position: 1:10+9 | | | byRef: false - | | | position: 1:1 + | | | position: 1:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+18 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (0) - | | | | | | position: 3:5 + | | | | | | position: 3:5+2 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 3:2 - | | | position: 3:1 + | | | | | position: 3:2+5 + | | | position: 3:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+7 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) @@ -97,55 +96,55 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 1 | | | | | | | | | kind: 10 - | | | | | | | | | position: 4:6 + | | | | | | | | | position: 4:6+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 4:6 + | | | | | | | | position: 4:6+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 2 | | | | | | | | | kind: 10 - | | | | | | | | | position: 4:9 + | | | | | | | | | position: 4:9+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 4:9 + | | | | | | | | position: 4:9+1 | | | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 3 | | | | | | | | | kind: 10 - | | | | | | | | | position: 4:12 + | | | | | | | | | position: 4:12+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 4:12 - | | | | | | position: 4:5 + | | | | | | | | position: 4:12+1 + | | | | | | position: 4:5+9 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 4:2 - | | | position: 4:1 + | | | | | position: 4:2+12 + | | | position: 4:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+14 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 5:5 + | | | | | | position: 5:5+6 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 5:2 - | | | position: 5:1 + | | | | | position: 5:2+9 + | | | position: 5:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+11 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) @@ -154,18 +153,18 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'getArr' | | | | | | | kind: 1 - | | | | | | | position: 6:5 + | | | | | | | position: 6:5+6 | | | | | | args: array (0) - | | | | | | position: 6:5 + | | | | | | position: 6:5+8 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 6:2 - | | | position: 6:1 + | | | | | position: 6:2+11 + | | | position: 6:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+13 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) @@ -174,18 +173,18 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'arrGen' | | | | | | | kind: 1 - | | | | | | | position: 7:5 + | | | | | | | position: 7:5+6 | | | | | | args: array (0) - | | | | | | position: 7:5 + | | | | | | position: 7:5+8 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 7:2 - | | | position: 7:1 + | | | | | position: 7:2+11 + | | | position: 7:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+13 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) @@ -194,7 +193,7 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'ArrayIterator' | | | | | | | kind: 1 - | | | | | | | position: 8:9 + | | | | | | | position: 8:9+13 | | | | | | args: array (1) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode @@ -202,42 +201,42 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | value: 'a' - | | | | | | | | | | | | position: 8:24 + | | | | | | | | | | | | position: 8:24+3 | | | | | | | | | | | key: null | | | | | | | | | | | byRef: false | | | | | | | | | | | unpack: false - | | | | | | | | | | | position: 8:24 + | | | | | | | | | | | position: 8:24+3 | | | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | value: 'b' - | | | | | | | | | | | | position: 8:29 + | | | | | | | | | | | | position: 8:29+3 | | | | | | | | | | | key: null | | | | | | | | | | | byRef: false | | | | | | | | | | | unpack: false - | | | | | | | | | | | position: 8:29 + | | | | | | | | | | | position: 8:29+3 | | | | | | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | value: 'c' - | | | | | | | | | | | | position: 8:34 + | | | | | | | | | | | | position: 8:34+3 | | | | | | | | | | | key: null | | | | | | | | | | | byRef: false | | | | | | | | | | | unpack: false - | | | | | | | | | | | position: 8:34 - | | | | | | | | | position: 8:23 + | | | | | | | | | | | position: 8:34+3 + | | | | | | | | | position: 8:23+15 | | | | | | | | byRef: false | | | | | | | | unpack: false | | | | | | | | name: null - | | | | | | | | position: 8:23 - | | | | | | position: 8:5 + | | | | | | | | position: 8:23+15 + | | | | | | position: 8:5+34 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 8:2 - | | | position: 8:1 + | | | | | position: 8:2+37 + | | | position: 8:1+39 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+39 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (9) @@ -245,93 +244,93 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 9:2 + | | | | | | position: 9:2+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:2 + | | | | | position: 9:2+1 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 9:8 + | | | | | | position: 9:8+6 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 9:5 + | | | | | position: 9:5+9 | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'getArr' | | | | | | | kind: 1 - | | | | | | | position: 9:19 + | | | | | | | position: 9:19+6 | | | | | | args: array (0) - | | | | | | position: 9:19 + | | | | | | position: 9:19+8 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 9:16 + | | | | | position: 9:16+11 | | | | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 6 | | | | | | kind: 10 - | | | | | | position: 9:29 + | | | | | | position: 9:29+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:29 + | | | | | position: 9:29+1 | | | | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 7 | | | | | | kind: 10 - | | | | | | position: 9:32 + | | | | | | position: 9:32+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:32 + | | | | | position: 9:32+1 | | | | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 8 | | | | | | kind: 10 - | | | | | | position: 9:35 + | | | | | | position: 9:35+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:35 + | | | | | position: 9:35+1 | | | | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 9 | | | | | | kind: 10 - | | | | | | position: 9:38 + | | | | | | position: 9:38+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:38 + | | | | | position: 9:38+1 | | | | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 10 | | | | | | kind: 10 - | | | | | | position: 9:41 + | | | | | | position: 9:41+2 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 9:41 + | | | | | position: 9:41+2 | | | | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'arrGen' | | | | | | | kind: 1 - | | | | | | | position: 9:48 + | | | | | | | position: 9:48+6 | | | | | | args: array (0) - | | | | | | position: 9:48 + | | | | | | position: 9:48+8 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 9:45 - | | | position: 9:1 + | | | | | position: 9:45+11 + | | | position: 9:1+56 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+56 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (4) @@ -339,40 +338,40 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 10:2 + | | | | | | position: 10:2+1 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 10:2 + | | | | | position: 10:2+1 | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 10:8 + | | | | | | position: 10:8+6 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 10:5 + | | | | | position: 10:5+9 | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 10:19 + | | | | | | position: 10:19+6 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 10:16 + | | | | | position: 10:16+9 | | | | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'end' - | | | | | | position: 10:27 + | | | | | | position: 10:27+5 | | | | | key: null | | | | | byRef: false | | | | | unpack: false - | | | | | position: 10:27 - | | | position: 10:1 + | | | | | position: 10:27+5 + | | | position: 10:1+32 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+32 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | items: array (1) @@ -383,37 +382,37 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 1 | | | | | | | | | kind: 10 - | | | | | | | | | position: 11:12 + | | | | | | | | | position: 11:12+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 11:12 + | | | | | | | | position: 11:12+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 2 | | | | | | | | | kind: 10 - | | | | | | | | | position: 11:15 + | | | | | | | | | position: 11:15+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 11:15 + | | | | | | | | position: 11:15+1 | | | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 3 | | | | | | | | | kind: 10 - | | | | | | | | | position: 11:18 + | | | | | | | | | position: 11:18+1 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 11:18 - | | | | | | position: 11:11 + | | | | | | | | position: 11:18+1 + | | | | | | position: 11:11+9 | | | | | key: null | | | | | byRef: false | | | | | unpack: true - | | | | | position: 11:2 - | | | position: 11:1 + | | | | | position: 11:2+18 + | | | position: 11:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 - position: 1:1 + | | position: 11:1+20 + position: 1:1+243 diff --git a/tests/phpParser/arrowFunction.phpt b/tests/phpParser/arrowFunction.phpt index 3a87a984e..398465803 100644 --- a/tests/phpParser/arrowFunction.phpt +++ b/tests/phpParser/arrowFunction.phpt @@ -1,31 +1,30 @@ - $a, - fn($x = 42) => $x, - fn&($x) => $x, - fn($x, ...$rest) => $rest, - fn(): int => $x, - - fn($a, $b) => $a and $b, - fn($a, $b) => $a && $b, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $a, + fn($x = 42) => $x, + fn&($x) => $x, + fn($x, ...$rest) => $rest, + fn(): int => $x, + + fn($a, $b) => $a and $b, + fn($a, $b) => $a && $b, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (7) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -34,24 +33,24 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 1:9 + | | | | | | position: 1:9+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'bool' - | | | | | | position: 1:4 + | | | | | | position: 1:4+4 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 1:4 + | | | | | position: 1:4+7 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:16 - | | | position: 1:1 + | | | | position: 1:16+2 + | | | position: 1:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+17 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -59,25 +58,25 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 2:4 + | | | | | | position: 2:4+2 | | | | | default: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 42 | | | | | | kind: 10 - | | | | | | position: 2:9 + | | | | | | position: 2:9+2 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 2:4 + | | | | | position: 2:4+7 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 2:16 - | | | position: 2:1 + | | | | position: 2:16+2 + | | | position: 2:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+17 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: true @@ -85,22 +84,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 3:5 + | | | | | | position: 3:5+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 3:5 + | | | | | position: 3:5+2 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 3:12 - | | | position: 3:1 + | | | | position: 3:12+2 + | | | position: 3:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+13 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -108,31 +107,31 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 4:4 + | | | | | | position: 4:4+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 4:4 + | | | | | position: 4:4+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'rest' - | | | | | | position: 4:11 + | | | | | | position: 4:11+5 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: true - | | | | | position: 4:8 + | | | | | position: 4:8+8 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'rest' - | | | | position: 4:21 - | | | position: 4:1 + | | | | position: 4:21+5 + | | | position: 4:1+25 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+25 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -140,15 +139,15 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | uses: array (0) | | | returnType: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'int' - | | | | position: 5:7 + | | | | position: 5:7+3 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 5:14 - | | | position: 5:1 + | | | | position: 5:14+2 + | | | position: 5:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+15 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -157,36 +156,36 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 7:4 + | | | | | | | position: 7:4+2 | | | | | | default: null | | | | | | type: null | | | | | | byRef: false | | | | | | variadic: false - | | | | | | position: 7:4 + | | | | | | position: 7:4+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 7:8 + | | | | | | | position: 7:8+2 | | | | | | default: null | | | | | | type: null | | | | | | byRef: false | | | | | | variadic: false - | | | | | | position: 7:8 + | | | | | | position: 7:8+2 | | | | uses: array (0) | | | | returnType: null | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 7:15 - | | | | position: 7:1 + | | | | | position: 7:15+2 + | | | | position: 7:1+16 | | | operator: 'and' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 7:22 - | | | position: 7:1 + | | | | position: 7:22+2 + | | | position: 7:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+23 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -194,35 +193,35 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 8:4 + | | | | | | position: 8:4+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 8:4 + | | | | | position: 8:4+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 8:8 + | | | | | | position: 8:8+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 8:8 + | | | | | position: 8:8+2 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 8:15 + | | | | | position: 8:15+2 | | | | operator: '&&' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 8:21 - | | | | position: 8:15 - | | | position: 8:1 + | | | | | position: 8:21+2 + | | | | position: 8:15+8 + | | | position: 8:1+22 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 - position: 1:1 + | | position: 8:1+22 + position: 1:1+146 diff --git a/tests/phpParser/assign.phpt b/tests/phpParser/assign.phpt index 82c964d0f..f40f107b7 100644 --- a/tests/phpParser/assign.phpt +++ b/tests/phpParser/assign.phpt @@ -1,331 +1,330 @@ ->= $b, - $a **= $b, - $a ??= $b, - - /* chained assign */ - $a = $b *= $c **= $d, - - /* by ref assign */ - $a =& $b, - - /* inc/dec */ - ++$a, - $a++, - --$a, - $a--, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +>= $b, + $a **= $b, + $a ??= $b, + + /* chained assign */ + $a = $b *= $c **= $d, + + /* by ref assign */ + $a =& $b, + + /* inc/dec */ + ++$a, + $a++, + --$a, + $a--, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (20) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 2:6 + | | | | position: 2:6+2 | | | byRef: false - | | | position: 2:1 + | | | position: 2:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:1 + | | | | position: 5:1+2 | | | operator: '&' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 5:7 - | | | position: 5:1 + | | | | position: 5:7+2 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+8 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:1 + | | | | position: 6:1+2 | | | operator: '|' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 6:7 - | | | position: 6:1 + | | | | position: 6:7+2 + | | | position: 6:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+8 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:1 + | | | | position: 7:1+2 | | | operator: '^' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 7:7 - | | | position: 7:1 + | | | | position: 7:7+2 + | | | position: 7:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+8 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:1 + | | | | position: 8:1+2 | | | operator: '.' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 8:7 - | | | position: 8:1 + | | | | position: 8:7+2 + | | | position: 8:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+8 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 9:1 + | | | | position: 9:1+2 | | | operator: '/' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 9:7 - | | | position: 9:1 + | | | | position: 9:7+2 + | | | position: 9:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+8 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 10:1 + | | | | position: 10:1+2 | | | operator: '-' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 10:7 - | | | position: 10:1 + | | | | position: 10:7+2 + | | | position: 10:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+8 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 11:1 + | | | | position: 11:1+2 | | | operator: '%' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 11:7 - | | | position: 11:1 + | | | | position: 11:7+2 + | | | position: 11:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+8 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 12:1 + | | | | position: 12:1+2 | | | operator: '*' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 12:7 - | | | position: 12:1 + | | | | position: 12:7+2 + | | | position: 12:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+8 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 13:1 + | | | | position: 13:1+2 | | | operator: '+' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 13:7 - | | | position: 13:1 + | | | | position: 13:7+2 + | | | position: 13:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+8 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 14:1 + | | | | position: 14:1+2 | | | operator: '<<' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 14:8 - | | | position: 14:1 + | | | | position: 14:8+2 + | | | position: 14:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+9 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 15:1 + | | | | position: 15:1+2 | | | operator: '>>' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 15:8 - | | | position: 15:1 + | | | | position: 15:8+2 + | | | position: 15:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+9 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 16:1 + | | | | position: 16:1+2 | | | operator: '**' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 16:8 - | | | position: 16:1 + | | | | position: 16:8+2 + | | | position: 16:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+9 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 17:1 + | | | | position: 17:1+2 | | | operator: '??' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 17:8 - | | | position: 17:1 + | | | | position: 17:8+2 + | | | position: 17:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+9 | 14 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 20:1 + | | | | position: 20:1+2 | | | expr: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 20:6 + | | | | | position: 20:6+2 | | | | operator: '*' | | | | expr: Latte\Compiler\Nodes\Php\Expression\AssignOpNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 20:12 + | | | | | | position: 20:12+2 | | | | | operator: '**' | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'd' - | | | | | | position: 20:19 - | | | | | position: 20:12 - | | | | position: 20:6 + | | | | | | position: 20:19+2 + | | | | | position: 20:12+9 + | | | | position: 20:6+15 | | | byRef: false - | | | position: 20:1 + | | | position: 20:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 20:1 + | | position: 20:1+20 | 15 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 23:1 + | | | | position: 23:1+2 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 23:7 + | | | | position: 23:7+2 | | | byRef: true - | | | position: 23:1 + | | | position: 23:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 23:1 + | | position: 23:1+8 | 16 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PreOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 26:3 + | | | | position: 26:3+2 | | | operator: '++' - | | | position: 26:1 + | | | position: 26:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 26:1 + | | position: 26:1+4 | 17 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PostOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 27:1 + | | | | position: 27:1+2 | | | operator: '++' - | | | position: 27:1 + | | | position: 27:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 27:1 + | | position: 27:1+4 | 18 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PreOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 28:3 + | | | | position: 28:3+2 | | | operator: '--' - | | | position: 28:1 + | | | position: 28:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 28:1 + | | position: 28:1+4 | 19 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PostOpNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 29:1 + | | | | position: 29:1+2 | | | operator: '--' - | | | position: 29:1 + | | | position: 29:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 29:1 - position: 2:1 + | | position: 29:1+4 + position: 2:1+279 diff --git a/tests/phpParser/cast.phpt b/tests/phpParser/cast.phpt index b8284b0ae..092e4aa38 100644 --- a/tests/phpParser/cast.phpt +++ b/tests/phpParser/cast.phpt @@ -1,94 +1,93 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'array' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:11 - | | | position: 1:1 + | | | | position: 1:11+2 + | | | position: 1:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+12 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'bool' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:11 - | | | position: 2:1 + | | | | position: 2:11+2 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'float' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:11 - | | | position: 3:1 + | | | | position: 3:11+2 + | | | position: 3:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+12 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'int' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:11 - | | | position: 4:1 + | | | | position: 4:11+2 + | | | position: 4:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+12 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'object' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:11 - | | | position: 5:1 + | | | | position: 5:11+2 + | | | position: 5:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+12 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CastNode | | | type: 'string' | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:11 - | | | position: 6:1 + | | | | position: 6:11+2 + | | | position: 6:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+12 + position: 1:1+83 diff --git a/tests/phpParser/clone.phpt b/tests/phpParser/clone.phpt index 22d7a87f3..48850310e 100644 --- a/tests/phpParser/clone.phpt +++ b/tests/phpParser/clone.phpt @@ -1,376 +1,375 @@ - $foo, 'bar' => $bar ]), - clone($x, $array), - clone($x, $array, $extraParameter, $trailingComma, ), - clone(object: $x, withProperties: [ 'foo' => $foo, 'bar' => $bar ]), - clone($x, withProperties: [ 'foo' => $foo, 'bar' => $bar ]), - clone(object: $x), - clone(object: $x, [ 'foo' => $foo, 'bar' => $bar ]), - clone(...['object' => $x, 'withProperties' => [ 'foo' => $foo, 'bar' => $bar ]]), - clone(...), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $foo, 'bar' => $bar ]), + clone($x, $array), + clone($x, $array, $extraParameter, $trailingComma, ), + clone(object: $x, withProperties: [ 'foo' => $foo, 'bar' => $bar ]), + clone($x, withProperties: [ 'foo' => $foo, 'bar' => $bar ]), + clone(object: $x), + clone(object: $x, [ 'foo' => $foo, 'bar' => $bar ]), + clone(...['object' => $x, 'withProperties' => [ 'foo' => $foo, 'bar' => $bar ]]), + clone(...), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (12) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CloneNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 1:7 - | | | position: 1:1 + | | | | position: 1:7+2 + | | | position: 1:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\CloneNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 2:7 - | | | position: 2:1 + | | | | position: 2:7+2 + | | | position: 2:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+9 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+11 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 3:7 + | | | | | | position: 3:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:6 - | | | position: 3:1 + | | | | | position: 3:6+6 + | | | position: 3:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+11 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 4:1 + | | | | position: 4:1+43 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 4:7 + | | | | | | position: 4:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 4:7 + | | | | | position: 4:7+36 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'foo' - | | | | | | | | | position: 4:22 + | | | | | | | | | position: 4:22+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 4:13 + | | | | | | | | | position: 4:13+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 4:13 + | | | | | | | | position: 4:13+13 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'bar' - | | | | | | | | | position: 4:37 + | | | | | | | | | position: 4:37+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'bar' - | | | | | | | | | position: 4:28 + | | | | | | | | | position: 4:28+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 4:28 - | | | | | | position: 4:11 + | | | | | | | | position: 4:28+13 + | | | | | | position: 4:11+32 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 4:11 - | | | position: 4:1 + | | | | | position: 4:11+32 + | | | position: 4:1+43 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+43 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 5:1 + | | | | position: 5:1+17 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 5:7 + | | | | | | position: 5:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:7 + | | | | | position: 5:7+10 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 5:11 + | | | | | | position: 5:11+6 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:11 - | | | position: 5:1 + | | | | | position: 5:11+6 + | | | position: 5:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+17 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 6:1 + | | | | position: 6:1+52 | | | args: array (4) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 6:7 + | | | | | | position: 6:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 6:7 + | | | | | position: 6:7+10 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'array' - | | | | | | position: 6:11 + | | | | | | position: 6:11+6 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 6:11 + | | | | | position: 6:11+6 | | | | 2 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'extraParameter' - | | | | | | position: 6:19 + | | | | | | position: 6:19+15 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 6:19 + | | | | | position: 6:19+15 | | | | 3 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'trailingComma' - | | | | | | position: 6:36 + | | | | | | position: 6:36+14 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 6:36 - | | | position: 6:1 + | | | | | position: 6:36+14 + | | | position: 6:1+52 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+52 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 7:1 + | | | | position: 7:1+67 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 7:15 + | | | | | | position: 7:15+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'object' - | | | | | | position: 7:7 - | | | | | position: 7:7 + | | | | | | position: 7:7+6 + | | | | | position: 7:7+10 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'foo' - | | | | | | | | | position: 7:46 + | | | | | | | | | position: 7:46+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 7:37 + | | | | | | | | | position: 7:37+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 7:37 + | | | | | | | | position: 7:37+13 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'bar' - | | | | | | | | | position: 7:61 + | | | | | | | | | position: 7:61+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'bar' - | | | | | | | | | position: 7:52 + | | | | | | | | | position: 7:52+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 7:52 - | | | | | | position: 7:35 + | | | | | | | | position: 7:52+13 + | | | | | | position: 7:35+32 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'withProperties' - | | | | | | position: 7:19 - | | | | | position: 7:19 - | | | position: 7:1 + | | | | | | position: 7:19+14 + | | | | | position: 7:19+48 + | | | position: 7:1+67 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+67 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 8:1 + | | | | position: 8:1+59 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 8:7 + | | | | | | position: 8:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 8:7 + | | | | | position: 8:7+52 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'foo' - | | | | | | | | | position: 8:38 + | | | | | | | | | position: 8:38+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 8:29 + | | | | | | | | | position: 8:29+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 8:29 + | | | | | | | | position: 8:29+13 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'bar' - | | | | | | | | | position: 8:53 + | | | | | | | | | position: 8:53+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'bar' - | | | | | | | | | position: 8:44 + | | | | | | | | | position: 8:44+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 8:44 - | | | | | | position: 8:27 + | | | | | | | | position: 8:44+13 + | | | | | | position: 8:27+32 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'withProperties' - | | | | | | position: 8:11 - | | | | | position: 8:11 - | | | position: 8:1 + | | | | | | position: 8:11+14 + | | | | | position: 8:11+48 + | | | position: 8:1+59 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+59 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 9:1 + | | | | position: 9:1+17 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 9:15 + | | | | | | position: 9:15+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'object' - | | | | | | position: 9:7 - | | | | | position: 9:7 - | | | position: 9:1 + | | | | | | position: 9:7+6 + | | | | | position: 9:7+10 + | | | position: 9:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+17 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 10:1 + | | | | position: 10:1+51 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'x' - | | | | | | position: 10:15 + | | | | | | position: 10:15+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'object' - | | | | | | position: 10:7 - | | | | | position: 10:7 + | | | | | | position: 10:7+6 + | | | | | position: 10:7+10 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'foo' - | | | | | | | | | position: 10:30 + | | | | | | | | | position: 10:30+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 10:21 + | | | | | | | | | position: 10:21+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 10:21 + | | | | | | | | position: 10:21+13 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'bar' - | | | | | | | | | position: 10:45 + | | | | | | | | | position: 10:45+4 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'bar' - | | | | | | | | | position: 10:36 + | | | | | | | | | position: 10:36+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 10:36 - | | | | | | position: 10:19 + | | | | | | | | position: 10:36+13 + | | | | | | position: 10:19+32 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 10:19 - | | | position: 10:1 + | | | | | position: 10:19+32 + | | | position: 10:1+51 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+51 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 11:1 + | | | | position: 11:1+80 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode @@ -378,65 +377,65 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'x' - | | | | | | | | | position: 11:23 + | | | | | | | | | position: 11:23+2 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'object' - | | | | | | | | | position: 11:11 + | | | | | | | | | position: 11:11+8 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 11:11 + | | | | | | | | position: 11:11+14 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | items: array (2) | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | | name: 'foo' - | | | | | | | | | | | | position: 11:58 + | | | | | | | | | | | | position: 11:58+4 | | | | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | value: 'foo' - | | | | | | | | | | | | position: 11:49 + | | | | | | | | | | | | position: 11:49+5 | | | | | | | | | | | byRef: false | | | | | | | | | | | unpack: false - | | | | | | | | | | | position: 11:49 + | | | | | | | | | | | position: 11:49+13 | | | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | | name: 'bar' - | | | | | | | | | | | | position: 11:73 + | | | | | | | | | | | | position: 11:73+4 | | | | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | value: 'bar' - | | | | | | | | | | | | position: 11:64 + | | | | | | | | | | | | position: 11:64+5 | | | | | | | | | | | byRef: false | | | | | | | | | | | unpack: false - | | | | | | | | | | | position: 11:64 - | | | | | | | | | position: 11:47 + | | | | | | | | | | | position: 11:64+13 + | | | | | | | | | position: 11:47+32 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'withProperties' - | | | | | | | | | position: 11:27 + | | | | | | | | | position: 11:27+16 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 11:27 - | | | | | | position: 11:10 + | | | | | | | | position: 11:27+52 + | | | | | | position: 11:10+70 | | | | | byRef: false | | | | | unpack: true | | | | | name: null - | | | | | position: 11:7 - | | | position: 11:1 + | | | | | position: 11:7+73 + | | | position: 11:1+80 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+80 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'clone' | | | | kind: 1 - | | | | position: 12:1 + | | | | position: 12:1+10 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\VariadicPlaceholderNode - | | | | | position: 12:7 - | | | position: 12:1 + | | | | | position: 12:7+3 + | | | position: 12:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 - position: 1:1 + | | position: 12:1+10 + position: 1:1+447 diff --git a/tests/phpParser/closure.phpt b/tests/phpParser/closure.phpt index eb59c454e..3f001f1bd 100644 --- a/tests/phpParser/closure.phpt +++ b/tests/phpParser/closure.phpt @@ -1,30 +1,29 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -33,22 +32,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 1:11 + | | | | | | position: 1:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 1:11 + | | | | | position: 1:11+2 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:24 - | | | position: 1:1 + | | | | position: 1:24+2 + | | | position: 1:1+28 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+28 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -56,22 +55,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:11 + | | | | | | position: 2:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 2:11 + | | | | | position: 2:11+2 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:24 - | | | position: 2:1 + | | | | position: 2:24+2 + | | | position: 2:1+28 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+28 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -79,26 +78,26 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:11 + | | | | | | position: 3:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 3:11 + | | | | | position: 3:11+2 | | | uses: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ClosureUseNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:20 + | | | | | | position: 3:20+2 | | | | | byRef: false - | | | | | position: 3:20 + | | | | | position: 3:20+2 | | | returnType: null | | | expr: null - | | | position: 3:1 + | | | position: 3:1+26 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+26 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -107,22 +106,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ClosureUseNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:18 + | | | | | | position: 4:18+2 | | | | | byRef: false - | | | | | position: 4:18 + | | | | | position: 4:18+2 | | | | 1 => Latte\Compiler\Nodes\Php\ClosureUseNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 4:23 + | | | | | | position: 4:23+2 | | | | | byRef: true - | | | | | position: 4:22 + | | | | | position: 4:22+3 | | | returnType: null | | | expr: null - | | | position: 4:1 + | | | position: 4:1+37 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+37 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: true @@ -130,20 +129,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 5:12 + | | | | | | position: 5:12+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 5:12 + | | | | | position: 5:12+2 | | | uses: array (0) | | | returnType: null | | | expr: null - | | | position: 5:1 + | | | position: 5:1+26 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+26 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -151,23 +150,23 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 6:11 + | | | | | | position: 6:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 6:11 + | | | | | position: 6:11+2 | | | uses: array (0) | | | returnType: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'array' - | | | | position: 6:17 + | | | | position: 6:17+5 | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 6:32 - | | | position: 6:1 + | | | | position: 6:32+4 + | | | position: 6:1+38 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+38 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -176,18 +175,18 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ClosureUseNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 7:18 + | | | | | | position: 7:18+2 | | | | | byRef: false - | | | | | position: 7:18 + | | | | | position: 7:18+2 | | | returnType: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'Foo\Bar' | | | | kind: 2 - | | | | position: 7:25 + | | | | position: 7:25+8 | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 7:43 - | | | position: 7:1 + | | | | position: 7:43+4 + | | | position: 7:1+49 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 - position: 1:1 + | | position: 7:1+49 + position: 1:1+245 diff --git a/tests/phpParser/comparison.phpt b/tests/phpParser/comparison.phpt index c6562bba3..2ea6c6d44 100644 --- a/tests/phpParser/comparison.phpt +++ b/tests/phpParser/comparison.phpt @@ -1,186 +1,185 @@ - $b, - $a >= $b, - $a == $b, - $a === $b, - $a != $b, - $a !== $b, - $a <=> $b, - $a instanceof B, - $a instanceof $b, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $b, + $a >= $b, + $a == $b, + $a === $b, + $a != $b, + $a !== $b, + $a <=> $b, + $a instanceof B, + $a instanceof $b, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (11) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:1 + | | | | position: 1:1+2 | | | operator: '<' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 1:6 - | | | position: 1:1 + | | | | position: 1:6+2 + | | | position: 1:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | operator: '<=' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 2:7 - | | | position: 2:1 + | | | | position: 2:7+2 + | | | position: 2:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+8 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:1 + | | | | position: 3:1+2 | | | operator: '>' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 3:6 - | | | position: 3:1 + | | | | position: 3:6+2 + | | | position: 3:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:1 + | | | | position: 4:1+2 | | | operator: '>=' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 4:7 - | | | position: 4:1 + | | | | position: 4:7+2 + | | | position: 4:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+8 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:1 + | | | | position: 5:1+2 | | | operator: '==' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 5:7 - | | | position: 5:1 + | | | | position: 5:7+2 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+8 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:1 + | | | | position: 6:1+2 | | | operator: '===' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 6:8 - | | | position: 6:1 + | | | | position: 6:8+2 + | | | position: 6:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+9 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:1 + | | | | position: 7:1+2 | | | operator: '!=' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 7:7 - | | | position: 7:1 + | | | | position: 7:7+2 + | | | position: 7:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+8 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:1 + | | | | position: 8:1+2 | | | operator: '!==' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 8:8 - | | | position: 8:1 + | | | | position: 8:8+2 + | | | position: 8:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+9 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 9:1 + | | | | position: 9:1+2 | | | operator: '<=>' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 9:8 - | | | position: 9:1 + | | | | position: 9:8+2 + | | | position: 9:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+9 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\InstanceofNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 10:1 + | | | | position: 10:1+2 | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'B' | | | | kind: 1 - | | | | position: 10:15 - | | | position: 10:1 + | | | | position: 10:15+1 + | | | position: 10:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+15 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\InstanceofNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 11:1 + | | | | position: 11:1+2 | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 11:15 - | | | position: 11:1 + | | | | position: 11:15+2 + | | | position: 11:1+16 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 - position: 1:1 + | | position: 11:1+16 + position: 1:1+125 diff --git a/tests/phpParser/constantDeref.phpt b/tests/phpParser/constantDeref.phpt index 9c52b7f7c..3ad67c3cc 100644 --- a/tests/phpParser/constantDeref.phpt +++ b/tests/phpParser/constantDeref.phpt @@ -1,42 +1,41 @@ -length, - \A->length(), - \A[0], - \A[0][1][2], - x\foo[0], - - A::B[0], - A::B[0][1][2], - A::B->length, - A::B->length(), - A::B::C, - A::B::$c, - A::B::c(), - - $foo::BAR[2][1][0], - - __FUNCTION__[0], - __FUNCTION__->length, - __FUNCIONT__->length(), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +length, + \A->length(), + \A[0], + \A[0][1][2], + x\foo[0], + + A::B[0], + A::B[0][1][2], + A::B->length, + A::B->length(), + A::B::C, + A::B::$c, + A::B::c(), + + $foo::BAR[2][1][0], + + __FUNCTION__[0], + __FUNCTION__->length, + __FUNCIONT__->length(), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (16) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode @@ -44,52 +43,52 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 2 - | | | | | position: 1:1 - | | | | position: 1:1 + | | | | | position: 1:1+2 + | | | | position: 1:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 1:5 + | | | | position: 1:5+6 | | | nullsafe: false - | | | position: 1:1 + | | | position: 1:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+10 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 2 - | | | | | position: 2:1 - | | | | position: 2:1 + | | | | | position: 2:1+2 + | | | | position: 2:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 2:5 + | | | | position: 2:5+6 | | | args: array (0) | | | nullsafe: false - | | | position: 2:1 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 2 - | | | | | position: 3:1 - | | | | position: 3:1 + | | | | | position: 3:1+2 + | | | | position: 3:1+2 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 3:4 - | | | position: 3:1 + | | | | position: 3:4+1 + | | | position: 3:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+5 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -98,64 +97,64 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'A' | | | | | | | kind: 2 - | | | | | | | position: 4:1 - | | | | | | position: 4:1 + | | | | | | | position: 4:1+2 + | | | | | | position: 4:1+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 4:4 - | | | | | position: 4:1 + | | | | | | position: 4:4+1 + | | | | | position: 4:1+5 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 1 | | | | | kind: 10 - | | | | | position: 4:7 - | | | | position: 4:1 + | | | | | position: 4:7+1 + | | | | position: 4:1+8 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 2 | | | | kind: 10 - | | | | position: 4:10 - | | | position: 4:1 + | | | | position: 4:10+1 + | | | position: 4:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+11 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'x\foo' | | | | | kind: 1 - | | | | | position: 5:1 - | | | | position: 5:1 + | | | | | position: 5:1+5 + | | | | position: 5:1+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 5:7 - | | | position: 5:1 + | | | | position: 5:7+1 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+8 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 7:1 + | | | | | position: 7:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 7:4 - | | | | position: 7:1 + | | | | | position: 7:4+1 + | | | | position: 7:1+4 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 7:6 - | | | position: 7:1 + | | | | position: 7:6+1 + | | | position: 7:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+7 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -164,129 +163,129 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'A' | | | | | | | kind: 1 - | | | | | | | position: 8:1 + | | | | | | | position: 8:1+1 | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'B' - | | | | | | | position: 8:4 - | | | | | | position: 8:1 + | | | | | | | position: 8:4+1 + | | | | | | position: 8:1+4 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 8:6 - | | | | | position: 8:1 + | | | | | | position: 8:6+1 + | | | | | position: 8:1+7 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 1 | | | | | kind: 10 - | | | | | position: 8:9 - | | | | position: 8:1 + | | | | | position: 8:9+1 + | | | | position: 8:1+10 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 2 | | | | kind: 10 - | | | | position: 8:12 - | | | position: 8:1 + | | | | position: 8:12+1 + | | | position: 8:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+13 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 9:1 + | | | | | position: 9:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 9:4 - | | | | position: 9:1 + | | | | | position: 9:4+1 + | | | | position: 9:1+4 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 9:7 + | | | | position: 9:7+6 | | | nullsafe: false - | | | position: 9:1 + | | | position: 9:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+12 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 10:1 + | | | | | position: 10:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 10:4 - | | | | position: 10:1 + | | | | | position: 10:4+1 + | | | | position: 10:1+4 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 10:7 + | | | | position: 10:7+6 | | | args: array (0) | | | nullsafe: false - | | | position: 10:1 + | | | position: 10:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+14 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 11:1 + | | | | | position: 11:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 11:4 - | | | | position: 11:1 + | | | | | position: 11:4+1 + | | | | position: 11:1+4 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'C' - | | | | position: 11:7 - | | | position: 11:1 + | | | | position: 11:7+1 + | | | position: 11:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+7 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 12:1 + | | | | | position: 12:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 12:4 - | | | | position: 12:1 + | | | | | position: 12:4+1 + | | | | position: 12:1+4 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'c' - | | | | position: 12:7 - | | | position: 12:1 + | | | | position: 12:7+2 + | | | position: 12:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+8 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 13:1 + | | | | | position: 13:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'B' - | | | | | position: 13:4 - | | | | position: 13:1 + | | | | | position: 13:4+1 + | | | | position: 13:1+4 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'c' - | | | | position: 13:7 + | | | | position: 13:7+1 | | | args: array (0) - | | | position: 13:1 + | | | position: 13:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+9 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -294,80 +293,80 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'foo' - | | | | | | | position: 15:1 + | | | | | | | position: 15:1+4 | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'BAR' - | | | | | | | position: 15:7 - | | | | | | position: 15:1 + | | | | | | | position: 15:7+3 + | | | | | | position: 15:1+9 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 15:11 - | | | | | position: 15:1 + | | | | | | position: 15:11+1 + | | | | | position: 15:1+12 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 1 | | | | | kind: 10 - | | | | | position: 15:14 - | | | | position: 15:1 + | | | | | position: 15:14+1 + | | | | position: 15:1+15 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 15:17 - | | | position: 15:1 + | | | | position: 15:17+1 + | | | position: 15:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+18 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: '__FUNCTION__' | | | | | kind: 1 - | | | | | position: 17:1 - | | | | position: 17:1 + | | | | | position: 17:1+12 + | | | | position: 17:1+12 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 17:14 - | | | position: 17:1 + | | | | position: 17:14+1 + | | | position: 17:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+15 | 14 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: '__FUNCTION__' | | | | | kind: 1 - | | | | | position: 18:1 - | | | | position: 18:1 + | | | | | position: 18:1+12 + | | | | position: 18:1+12 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 18:15 + | | | | position: 18:15+6 | | | nullsafe: false - | | | position: 18:1 + | | | position: 18:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 18:1 + | | position: 18:1+20 | 15 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: '__FUNCIONT__' | | | | | kind: 1 - | | | | | position: 19:1 - | | | | position: 19:1 + | | | | | position: 19:1+12 + | | | | position: 19:1+12 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 19:15 + | | | | position: 19:15+6 | | | args: array (0) | | | nullsafe: false - | | | position: 19:1 + | | | position: 19:1+22 | | key: null | | byRef: false | | unpack: false - | | position: 19:1 - position: 1:1 + | | position: 19:1+22 + position: 1:1+225 diff --git a/tests/phpParser/constantFetch.phpt b/tests/phpParser/constantFetch.phpt index 7e2525017..f1f4b934f 100644 --- a/tests/phpParser/constantFetch.phpt +++ b/tests/phpParser/constantFetch.phpt @@ -1,129 +1,128 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 2 - | | | | position: 1:1 - | | | position: 1:1 + | | | | position: 1:1+2 + | | | position: 1:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+2 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+1 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'B' - | | | | position: 2:4 - | | | position: 2:1 + | | | | position: 2:4+1 + | | | position: 2:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+4 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+1 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'class' - | | | | position: 3:4 - | | | position: 3:1 + | | | | position: 3:4+5 + | | | position: 3:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+8 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:1 + | | | | position: 4:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'B' - | | | | position: 4:5 - | | | position: 4:1 + | | | | position: 4:5+1 + | | | position: 4:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+5 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:1 + | | | | position: 5:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'class' - | | | | position: 5:5 - | | | position: 5:1 + | | | | position: 5:5+5 + | | | position: 5:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+9 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'Foo' | | | | kind: 1 - | | | | position: 6:1 + | | | | position: 6:1+3 | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'bar' | | | | | kind: 1 - | | | | | position: 6:7 + | | | | | position: 6:7+3 | | | | args: array (0) - | | | | position: 6:7 - | | | position: 6:1 + | | | | position: 6:7+5 + | | | position: 6:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+12 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'foo' - | | | | position: 7:1 + | | | | position: 7:1+4 | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'bar' | | | | | kind: 1 - | | | | | position: 7:8 + | | | | | position: 7:8+3 | | | | args: array (0) - | | | | position: 7:8 - | | | position: 7:1 + | | | | position: 7:8+5 + | | | position: 7:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 - position: 1:1 + | | position: 7:1+13 + position: 1:1+66 diff --git a/tests/phpParser/defaultValues.phpt b/tests/phpParser/defaultValues.phpt index ee924e1bb..6ec2414d8 100644 --- a/tests/phpParser/defaultValues.phpt +++ b/tests/phpParser/defaultValues.phpt @@ -1,35 +1,34 @@ - 'baz'], - $l = new Foo, - ) { return null; } - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + 'baz'], + $l = new Foo, + ) { return null; } + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (1) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -38,162 +37,162 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:5 + | | | | | | position: 2:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | | position: 2:10 + | | | | | | position: 2:10+4 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 2:5 + | | | | | position: 2:5+9 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 3:5 + | | | | | | position: 3:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'foo' - | | | | | | position: 3:10 + | | | | | | position: 3:10+5 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 3:5 + | | | | | position: 3:5+10 | | | | 2 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'd' - | | | | | | position: 4:5 + | | | | | | position: 4:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'A' | | | | | | | kind: 1 - | | | | | | | position: 4:10 + | | | | | | | position: 4:10+1 | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'B' - | | | | | | | position: 4:13 - | | | | | | position: 4:10 + | | | | | | | position: 4:13+1 + | | | | | | position: 4:10+4 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 4:5 + | | | | | position: 4:5+9 | | | | 3 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'f' - | | | | | | position: 5:5 + | | | | | | position: 5:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 5:11 + | | | | | | | position: 5:11+1 | | | | | | operator: '+' - | | | | | | position: 5:10 + | | | | | | position: 5:10+2 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 5:5 + | | | | | position: 5:5+7 | | | | 4 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'g' - | | | | | | position: 6:5 + | | | | | | position: 6:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | | | | | value: 1.0 - | | | | | | | position: 6:11 + | | | | | | | position: 6:11+3 | | | | | | operator: '-' - | | | | | | position: 6:10 + | | | | | | position: 6:10+4 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 6:5 + | | | | | position: 6:5+9 | | | | 5 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'h' - | | | | | | position: 7:5 + | | | | | | position: 7:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (0) - | | | | | | position: 7:10 + | | | | | | position: 7:10+7 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 7:5 + | | | | | position: 7:5+12 | | | | 6 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'i' - | | | | | | position: 8:5 + | | | | | | position: 8:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (0) - | | | | | | position: 8:10 + | | | | | | position: 8:10+2 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 8:5 + | | | | | position: 8:5+7 | | | | 7 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'j' - | | | | | | position: 9:5 + | | | | | | position: 9:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (1) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 9:11 + | | | | | | | | | position: 9:11+5 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 9:11 - | | | | | | position: 9:10 + | | | | | | | | position: 9:11+5 + | | | | | | position: 9:10+7 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 9:5 + | | | | | position: 9:5+12 | | | | 8 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'k' - | | | | | | position: 10:5 + | | | | | | position: 10:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | items: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'foo' - | | | | | | | | | position: 10:11 + | | | | | | | | | position: 10:11+5 | | | | | | | | key: null | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 10:11 + | | | | | | | | position: 10:11+5 | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'baz' - | | | | | | | | | position: 10:27 + | | | | | | | | | position: 10:27+5 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'bar' - | | | | | | | | | position: 10:18 + | | | | | | | | | position: 10:18+5 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 10:18 - | | | | | | position: 10:10 + | | | | | | | | position: 10:18+14 + | | | | | | position: 10:10+23 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 10:5 + | | | | | position: 10:5+28 | | | | 9 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'l' - | | | | | | position: 11:5 + | | | | | | position: 11:5+2 | | | | | default: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'Foo' | | | | | | | kind: 1 - | | | | | | | position: 11:14 + | | | | | | | position: 11:14+3 | | | | | | args: array (0) - | | | | | | position: 11:10 + | | | | | | position: 11:10+7 | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 11:5 + | | | | | position: 11:5+12 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 12:12 - | | | position: 1:1 + | | | | position: 12:12+4 + | | | position: 1:1+204 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 - position: 1:1 + | | position: 1:1+204 + position: 1:1+204 diff --git a/tests/phpParser/docString.phpt b/tests/phpParser/docString.phpt index 37eb7e408..1f5b22b15 100644 --- a/tests/phpParser/docString.phpt +++ b/tests/phpParser/docString.phpt @@ -1,118 +1,117 @@ -c test - EOS, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +c test + EOS, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (6) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '' - | | | position: 2:1 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '' - | | | position: 4:1 + | | | position: 4:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+10 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'Test '" $a \n' - | | | position: 8:1 + | | | position: 8:1+26 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+26 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'Test '" $a \n' - | | | position: 11:1 + | | | position: 11:1+25 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+25 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: 'Test ' - | | | | | position: 17:1 + | | | | | position: 17:1+5 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 17:6 - | | | position: 16:1 + | | | | | position: 17:6+2 + | | | position: 16:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+18 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (5) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: 'Test ' - | | | | | position: 20:1 + | | | | | position: 20:1+5 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 20:6 + | | | | | position: 20:6+2 | | | | 2 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: ' and ' - | | | | | position: 20:8 + | | | | | position: 20:8+5 | | | | 3 => Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 20:13 + | | | | | | position: 20:13+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'c' - | | | | | | position: 20:17 + | | | | | | position: 20:17+1 | | | | | nullsafe: false - | | | | | position: 20:13 + | | | | | position: 20:13+5 | | | | 4 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: ' test' - | | | | | position: 20:18 - | | | position: 19:1 + | | | | | position: 20:18+6 + | | | position: 19:1+33 | | key: null | | byRef: false | | unpack: false - | | position: 19:1 - position: 2:1 + | | position: 19:1+33 + position: 2:1+192 diff --git a/tests/phpParser/errorSuppress.phpt b/tests/phpParser/errorSuppress.phpt index 96320d8d2..6f298cc4a 100644 --- a/tests/phpParser/errorSuppress.phpt +++ b/tests/phpParser/errorSuppress.phpt @@ -1,34 +1,33 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:2 + | | | | position: 1:2+2 | | | operator: '@' - | | | position: 1:1 + | | | position: 1:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 - position: 1:1 + | | position: 1:1+3 + position: 1:1+4 diff --git a/tests/phpParser/explicitOctal.phpt b/tests/phpParser/explicitOctal.phpt index 9c00c553c..e9528dd55 100644 --- a/tests/phpParser/explicitOctal.phpt +++ b/tests/phpParser/explicitOctal.phpt @@ -1,61 +1,60 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 83 | | | kind: 8 - | | | position: 1:1 + | | | position: 1:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+5 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 83 | | | kind: 8 - | | | position: 2:1 + | | | position: 2:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+5 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 83 | | | kind: 8 - | | | position: 3:1 + | | | position: 3:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 9.223372036854776e+18 - | | | position: 4:1 + | | | position: 4:1+24 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+24 + position: 1:1+48 diff --git a/tests/phpParser/exprInIsset.phpt b/tests/phpParser/exprInIsset.phpt index 56a8c7304..26f96f481 100644 --- a/tests/phpParser/exprInIsset.phpt +++ b/tests/phpParser/exprInIsset.phpt @@ -1,37 +1,36 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 1:8 + | | | | | position: 1:8+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 1:15 - | | | position: 1:1 + | | | | | position: 1:15+2 + | | | position: 1:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 - position: 1:1 + | | position: 1:1+19 + position: 1:1+20 diff --git a/tests/phpParser/exprInList.phpt b/tests/phpParser/exprInList.phpt index 20258802f..fcb85ea85 100644 --- a/tests/phpParser/exprInList.phpt +++ b/tests/phpParser/exprInList.phpt @@ -1,24 +1,23 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode @@ -27,25 +26,25 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 1:7 + | | | | | | | position: 1:7+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 1:6 + | | | | | | position: 1:6+4 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 1:15 + | | | | | | | position: 1:15+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 1:12 - | | | | position: 1:1 + | | | | | | position: 1:12+8 + | | | | position: 1:1+20 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 1:24 + | | | | position: 1:24+2 | | | byRef: false - | | | position: 1:1 + | | | position: 1:1+25 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 - position: 1:1 + | | position: 1:1+25 + position: 1:1+26 diff --git a/tests/phpParser/filters.phpt b/tests/phpParser/filters.phpt index 446f998b6..e3b4c27db 100644 --- a/tests/phpParser/filters.phpt +++ b/tests/phpParser/filters.phpt @@ -1,297 +1,296 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:2 + | | | | position: 1:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'upper' - | | | | | position: 1:5 + | | | | | position: 1:5+5 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 1:4 - | | | position: 1:2 + | | | | position: 1:4+6 + | | | position: 1:2+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+10 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:2 + | | | | | | position: 2:2+2 | | | | | operator: '.' | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:7 - | | | | | position: 2:2 + | | | | | | position: 2:7+2 + | | | | | position: 2:2+7 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'upper' - | | | | | | position: 2:12 + | | | | | | position: 2:12+5 | | | | | args: array (0) | | | | | nullsafe: false - | | | | | position: 2:10 - | | | | position: 2:2 + | | | | | position: 2:10+7 + | | | | position: 2:2+15 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 2:18 + | | | | | position: 2:18+8 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 2:17 - | | | position: 2:2 + | | | | position: 2:17+9 + | | | position: 2:2+24 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+26 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 3:2 + | | | | | position: 3:2+2 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'truncate' - | | | | | | position: 3:6 + | | | | | | position: 3:6+8 | | | | | args: array (2) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 10 | | | | | | | | kind: 10 - | | | | | | | | position: 3:16 + | | | | | | | | position: 3:16+2 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 3:16 + | | | | | | | position: 3:16+2 | | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 20 | | | | | | | | kind: 10 - | | | | | | | | position: 3:20 + | | | | | | | | position: 3:20+2 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 3:20 + | | | | | | | position: 3:20+2 | | | | | nullsafe: false - | | | | | position: 3:5 - | | | | position: 3:2 + | | | | | position: 3:5+17 + | | | | position: 3:2+20 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'trim' - | | | | | position: 3:23 + | | | | | position: 3:23+4 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 3:22 - | | | position: 3:2 + | | | | position: 3:22+5 + | | | position: 3:2+25 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+27 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 4:2 + | | | | | position: 4:2+2 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'truncate' - | | | | | | position: 4:6 + | | | | | | position: 4:6+8 | | | | | args: array (2) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 10 | | | | | | | | kind: 10 - | | | | | | | | position: 4:16 + | | | | | | | | position: 4:16+2 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 4:16 + | | | | | | | position: 4:16+2 | | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | value: 20 | | | | | | | | | kind: 10 - | | | | | | | | | position: 4:21 + | | | | | | | | | position: 4:21+2 | | | | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | | | name: 'round' - | | | | | | | | | | position: 4:24 + | | | | | | | | | | position: 4:24+5 | | | | | | | | | args: array (0) | | | | | | | | | nullsafe: false - | | | | | | | | | position: 4:23 - | | | | | | | | position: 4:21 + | | | | | | | | | position: 4:23+6 + | | | | | | | | position: 4:21+8 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 4:20 + | | | | | | | position: 4:20+10 | | | | | nullsafe: false - | | | | | position: 4:5 - | | | | position: 4:2 + | | | | | position: 4:5+25 + | | | | position: 4:2+28 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'trim' - | | | | | position: 4:31 + | | | | | position: 4:31+4 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 4:30 - | | | position: 4:2 + | | | | position: 4:30+5 + | | | position: 4:2+33 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+35 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:2 + | | | | position: 5:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 5:6 + | | | | | position: 5:6+8 | | | | args: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 10 | | | | | | | kind: 10 - | | | | | | | position: 5:19 + | | | | | | | position: 5:19+2 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'a' - | | | | | | | position: 5:16 - | | | | | | position: 5:16 + | | | | | | | position: 5:16+1 + | | | | | | position: 5:16+5 | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | | | | | value: true - | | | | | | | position: 5:26 + | | | | | | | position: 5:26+4 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'b' - | | | | | | | position: 5:23 - | | | | | | position: 5:23 + | | | | | | | position: 5:23+1 + | | | | | | position: 5:23+7 | | | | nullsafe: false - | | | | position: 5:5 - | | | position: 5:2 + | | | | position: 5:5+25 + | | | position: 5:2+28 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+30 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:2 + | | | | position: 6:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 6:6 + | | | | | position: 6:6+8 | | | | args: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 10 | | | | | | | kind: 10 - | | | | | | | position: 6:19 + | | | | | | | position: 6:19+2 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'a' - | | | | | | | position: 6:16 - | | | | | | position: 6:16 + | | | | | | | position: 6:16+1 + | | | | | | position: 6:16+5 | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | | | | | value: true - | | | | | | | position: 6:26 + | | | | | | | position: 6:26+4 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'b' - | | | | | | | position: 6:23 - | | | | | | position: 6:23 + | | | | | | | position: 6:23+1 + | | | | | | position: 6:23+7 | | | | nullsafe: false - | | | | position: 6:5 - | | | position: 6:2 + | | | | position: 6:5+26 + | | | position: 6:2+29 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+31 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:2 + | | | | position: 7:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 7:6 + | | | | | position: 7:6+8 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 10 | | | | | | | kind: 10 - | | | | | | | position: 7:19 + | | | | | | | position: 7:19+2 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'a' - | | | | | | | position: 7:16 - | | | | | | position: 7:16 + | | | | | | | position: 7:16+1 + | | | | | | position: 7:16+5 | | | | nullsafe: false - | | | | position: 7:5 - | | | position: 7:2 + | | | | position: 7:5+19 + | | | position: 7:2+22 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+24 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:2 + | | | | position: 8:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 8:6 + | | | | | position: 8:6+8 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 8:5 - | | | position: 8:2 + | | | | position: 8:5+11 + | | | position: 8:2+14 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 - position: 1:1 + | | position: 8:1+16 + position: 1:1+214 diff --git a/tests/phpParser/filtersNullsafe.phpt b/tests/phpParser/filtersNullsafe.phpt index ac9e547ea..cc3fa8d6b 100644 --- a/tests/phpParser/filtersNullsafe.phpt +++ b/tests/phpParser/filtersNullsafe.phpt @@ -1,111 +1,110 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:2 + | | | | position: 1:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'upper' - | | | | | position: 1:6 + | | | | | position: 1:6+5 | | | | args: array (0) | | | | nullsafe: true - | | | | position: 1:4 - | | | position: 1:2 + | | | | position: 1:4+7 + | | | position: 1:2+9 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+11 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:2 + | | | | | | position: 2:2+2 | | | | | operator: '.' | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:7 - | | | | | position: 2:2 + | | | | | | position: 2:7+2 + | | | | | position: 2:2+7 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'upper' - | | | | | | position: 2:12 + | | | | | | position: 2:12+5 | | | | | args: array (0) | | | | | nullsafe: true - | | | | | position: 2:10 - | | | | position: 2:2 + | | | | | position: 2:10+7 + | | | | position: 2:2+15 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 2:19 + | | | | | position: 2:19+8 | | | | args: array (0) | | | | nullsafe: true - | | | | position: 2:17 - | | | position: 2:2 + | | | | position: 2:17+10 + | | | position: 2:2+25 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+27 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:2 + | | | | | | position: 3:2+2 | | | | | operator: '.' | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:7 - | | | | | position: 3:2 + | | | | | | position: 3:7+2 + | | | | | position: 3:2+7 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'upper' - | | | | | | position: 3:12 + | | | | | | position: 3:12+5 | | | | | args: array (0) | | | | | nullsafe: true - | | | | | position: 3:10 - | | | | position: 3:2 + | | | | | position: 3:10+7 + | | | | position: 3:2+15 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 3:18 + | | | | | position: 3:18+8 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 3:17 - | | | position: 3:2 + | | | | position: 3:17+9 + | | | position: 3:2+24 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+26 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode @@ -113,142 +112,142 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 4:2 + | | | | | | | position: 4:2+2 | | | | | | operator: '.' | | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 4:7 - | | | | | | position: 4:2 + | | | | | | | position: 4:7+2 + | | | | | | position: 4:2+7 | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'upper' - | | | | | | | position: 4:12 + | | | | | | | position: 4:12+5 | | | | | | args: array (0) | | | | | | nullsafe: true - | | | | | | position: 4:10 - | | | | | position: 4:2 + | | | | | | position: 4:10+7 + | | | | | position: 4:2+15 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'truncate' - | | | | | | position: 4:18 + | | | | | | position: 4:18+8 | | | | | args: array (0) | | | | | nullsafe: false - | | | | | position: 4:17 - | | | | position: 4:2 + | | | | | position: 4:17+9 + | | | | position: 4:2+24 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'trim' - | | | | | position: 4:28 + | | | | | position: 4:28+4 | | | | args: array (0) | | | | nullsafe: true - | | | | position: 4:26 - | | | position: 4:2 + | | | | position: 4:26+6 + | | | position: 4:2+30 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+32 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 5:2 + | | | | | position: 5:2+2 | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'truncate' - | | | | | | position: 5:7 + | | | | | | position: 5:7+8 | | | | | args: array (2) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 10 | | | | | | | | kind: 10 - | | | | | | | | position: 5:17 + | | | | | | | | position: 5:17+2 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 5:17 + | | | | | | | position: 5:17+2 | | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'c' - | | | | | | | | | position: 5:22 + | | | | | | | | | position: 5:22+2 | | | | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | | | name: 'round' - | | | | | | | | | | position: 5:26 + | | | | | | | | | | position: 5:26+5 | | | | | | | | | args: array (0) | | | | | | | | | nullsafe: true - | | | | | | | | | position: 5:24 - | | | | | | | | position: 5:22 + | | | | | | | | | position: 5:24+7 + | | | | | | | | position: 5:22+9 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 5:21 + | | | | | | | position: 5:21+11 | | | | | nullsafe: true - | | | | | position: 5:5 - | | | | position: 5:2 + | | | | | position: 5:5+27 + | | | | position: 5:2+30 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'trim' - | | | | | position: 5:33 + | | | | | position: 5:33+4 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 5:32 - | | | position: 5:2 + | | | | position: 5:32+5 + | | | position: 5:2+35 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+37 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:2 + | | | | position: 6:2+2 | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'truncate' - | | | | | position: 6:7 + | | | | | position: 6:7+8 | | | | args: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 10 | | | | | | | kind: 10 - | | | | | | | position: 6:17 + | | | | | | | position: 6:17+2 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 6:17 + | | | | | | position: 6:17+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'c' - | | | | | | | | | position: 6:23 + | | | | | | | | | position: 6:23+2 | | | | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | | | name: 'round' - | | | | | | | | | | position: 6:27 + | | | | | | | | | | position: 6:27+5 | | | | | | | | | args: array (0) | | | | | | | | | nullsafe: true - | | | | | | | | | position: 6:25 - | | | | | | | | position: 6:23 + | | | | | | | | | position: 6:25+7 + | | | | | | | | position: 6:23+9 | | | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | | name: 'trim' - | | | | | | | | | position: 6:34 + | | | | | | | | | position: 6:34+4 | | | | | | | | args: array (0) | | | | | | | | nullsafe: false - | | | | | | | | position: 6:33 - | | | | | | | position: 6:22 + | | | | | | | | position: 6:33+5 + | | | | | | | position: 6:22+16 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 6:21 + | | | | | | position: 6:21+18 | | | | nullsafe: true - | | | | position: 6:5 - | | | position: 6:2 + | | | | position: 6:5+34 + | | | position: 6:2+37 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+39 + position: 1:1+183 diff --git a/tests/phpParser/firstClassCallables.phpt b/tests/phpParser/firstClassCallables.phpt index d2d024e37..14d56b372 100644 --- a/tests/phpParser/firstClassCallables.phpt +++ b/tests/phpParser/firstClassCallables.phpt @@ -1,73 +1,72 @@ -foo(...), - A::foo(...), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +foo(...), + A::foo(...), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (3) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'foo' | | | | kind: 1 - | | | | position: 1:1 + | | | | position: 1:1+3 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\VariadicPlaceholderNode - | | | | | position: 1:5 - | | | position: 1:1 + | | | | | position: 1:5+3 + | | | position: 1:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'this' - | | | | position: 2:1 + | | | | position: 2:1+5 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'foo' - | | | | position: 2:8 + | | | | position: 2:8+3 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\VariadicPlaceholderNode - | | | | | position: 2:12 + | | | | | position: 2:12+3 | | | nullsafe: false - | | | position: 2:1 + | | | position: 2:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+15 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+1 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'foo' - | | | | position: 3:4 + | | | | position: 3:4+3 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\VariadicPlaceholderNode - | | | | | position: 3:8 - | | | position: 3:1 + | | | | | position: 3:8+3 + | | | position: 3:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 - position: 1:1 + | | position: 3:1+11 + position: 1:1+39 diff --git a/tests/phpParser/float.phpt b/tests/phpParser/float.phpt index 606ec257e..50a289213 100644 --- a/tests/phpParser/float.phpt +++ b/tests/phpParser/float.phpt @@ -1,151 +1,150 @@ - float overflows */ - /* (all are actually the same number, just in different representations) */ - 18446744073709551615, - 0xFFFFFFFFFFFFFFFF, - 01777777777777777777777, - 0b1111111111111111111111111111111111111111111111111111111111111111, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + float overflows */ + /* (all are actually the same number, just in different representations) */ + 18446744073709551615, + 0xFFFFFFFFFFFFFFFF, + 01777777777777777777777, + 0b1111111111111111111111111111111111111111111111111111111111111111, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (14) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 1:1 + | | | position: 1:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+3 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 2:1 + | | | position: 2:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+2 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 3:1 + | | | position: 3:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+2 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 4:1 + | | | position: 4:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+3 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 5:1 + | | | position: 5:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+3 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 6:1 + | | | position: 6:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+4 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 0.0 - | | | position: 7:1 + | | | position: 7:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+4 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 302000000000.0 - | | | position: 8:1 + | | | position: 8:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+8 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 3.002e+102 - | | | position: 9:1 + | | | position: 9:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+11 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: INF - | | | position: 10:1 + | | | position: 10:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+7 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 1.8446744073709552e+19 - | | | position: 14:1 + | | | position: 14:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+20 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 1.8446744073709552e+19 - | | | position: 15:1 + | | | position: 15:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+18 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 1.8446744073709552e+19 - | | | position: 16:1 + | | | position: 16:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+23 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 1.8446744073709552e+19 - | | | position: 17:1 + | | | position: 17:1+66 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 - position: 1:1 + | | position: 17:1+66 + position: 1:1+319 diff --git a/tests/phpParser/funcCall.phpt b/tests/phpParser/funcCall.phpt index 544eb8554..e6de7b1a3 100644 --- a/tests/phpParser/funcCall.phpt +++ b/tests/phpParser/funcCall.phpt @@ -1,122 +1,121 @@ -b['c'](), - - /* array dereferencing */ - a()['b'], - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b['c'](), + + /* array dereferencing */ + a()['b'], + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (6) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'a' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+1 | | | args: array (0) - | | | position: 2:1 + | | | position: 2:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+3 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:1 + | | | | position: 3:1+2 | | | args: array (0) - | | | position: 3:1 + | | | position: 3:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+4 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'a' - | | | | | position: 4:3 - | | | | position: 4:1 + | | | | | position: 4:3+3 + | | | | position: 4:1+6 | | | args: array (0) - | | | position: 4:1 + | | | position: 4:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+8 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 5:1 + | | | | | position: 5:1+2 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'b' - | | | | | position: 5:4 - | | | | position: 5:1 + | | | | | position: 5:4+3 + | | | | position: 5:1+7 | | | args: array (0) - | | | position: 5:1 + | | | position: 5:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+9 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 6:1 + | | | | | | position: 6:1+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 6:5 + | | | | | | position: 6:5+1 | | | | | nullsafe: false - | | | | | position: 6:1 + | | | | | position: 6:1+5 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'c' - | | | | | position: 6:7 - | | | | position: 6:1 + | | | | | position: 6:7+3 + | | | | position: 6:1+10 | | | args: array (0) - | | | position: 6:1 + | | | position: 6:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+12 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'a' | | | | | kind: 1 - | | | | | position: 9:1 + | | | | | position: 9:1+1 | | | | args: array (0) - | | | | position: 9:1 + | | | | position: 9:1+3 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 9:5 - | | | position: 9:1 + | | | | position: 9:5+3 + | | | position: 9:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 - position: 2:1 + | | position: 9:1+8 + position: 2:1+82 diff --git a/tests/phpParser/in.phpt b/tests/phpParser/in.phpt index 9c7db95f8..2c7f0905b 100644 --- a/tests/phpParser/in.phpt +++ b/tests/phpParser/in.phpt @@ -1,83 +1,82 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\InNode | | | needle: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:1 + | | | | position: 1:1+2 | | | haystack: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 1:7 - | | | position: 1:1 + | | | | position: 1:7+2 + | | | position: 1:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\InNode | | | | needle: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 4:1 + | | | | | position: 4:1+2 | | | | haystack: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 4:7 - | | | | position: 4:1 + | | | | | position: 4:7+2 + | | | | position: 4:1+8 | | | operator: '||' | | | right: Latte\Compiler\Nodes\Php\Expression\InNode | | | | needle: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 4:13 + | | | | | position: 4:13+2 | | | | haystack: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'd' - | | | | | position: 4:19 - | | | | position: 4:13 - | | | position: 4:1 + | | | | | position: 4:19+2 + | | | | position: 4:13+8 + | | | position: 4:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+20 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:1 + | | | | position: 5:1+2 | | | expr: Latte\Compiler\Nodes\Php\Expression\InNode | | | | needle: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 5:6 + | | | | | position: 5:6+2 | | | | haystack: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 5:12 - | | | | position: 5:6 + | | | | | position: 5:12+2 + | | | | position: 5:6+8 | | | byRef: false - | | | position: 5:1 + | | | position: 5:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+13 + position: 1:1+64 diff --git a/tests/phpParser/indirectCall.phpt b/tests/phpParser/indirectCall.phpt index 2e6ecc638..552dac3cc 100644 --- a/tests/phpParser/indirectCall.phpt +++ b/tests/phpParser/indirectCall.phpt @@ -1,44 +1,43 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -46,32 +45,32 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'id' | | | | | kind: 1 - | | | | | position: 1:1 + | | | | | position: 1:1+2 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 1:4 + | | | | | | | position: 1:4+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 1:4 - | | | | position: 1:1 + | | | | | | position: 1:4+10 + | | | | position: 1:1+14 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 1 | | | | | | kind: 10 - | | | | | | position: 1:16 + | | | | | | position: 1:16+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 1:16 - | | | position: 1:1 + | | | | | position: 1:16+1 + | | | position: 1:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+17 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -79,42 +78,42 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'id' | | | | | | kind: 1 - | | | | | | position: 3:1 + | | | | | | position: 3:1+2 | | | | | args: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | value: 'id' - | | | | | | | | position: 3:4 + | | | | | | | | position: 3:4+4 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 3:4 - | | | | | position: 3:1 + | | | | | | | position: 3:4+4 + | | | | | position: 3:1+8 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 3:10 + | | | | | | | position: 3:10+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 3:10 - | | | | position: 3:1 + | | | | | | position: 3:10+10 + | | | | position: 3:1+20 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 3:22 + | | | | | | position: 3:22+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:22 - | | | position: 3:1 + | | | | | position: 3:22+1 + | | | position: 3:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+23 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -123,36 +122,36 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'id' | | | | | | | kind: 1 - | | | | | | | position: 5:1 + | | | | | | | position: 5:1+2 | | | | | | args: array (0) - | | | | | | position: 5:1 + | | | | | | position: 5:1+4 | | | | | args: array (0) - | | | | | position: 5:1 + | | | | | position: 5:1+6 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 5:8 + | | | | | | | position: 5:8+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 5:8 - | | | | position: 5:1 + | | | | | | position: 5:8+10 + | | | | position: 5:1+18 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 4 | | | | | | kind: 10 - | | | | | | position: 5:20 + | | | | | | position: 5:20+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:20 - | | | position: 5:1 + | | | | | position: 5:20+1 + | | | position: 5:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+21 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -162,7 +161,7 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'id' | | | | | | | | kind: 1 - | | | | | | | | position: 7:1 + | | | | | | | | position: 7:1+2 | | | | | | | args: array (1) | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\ArrayNode @@ -170,57 +169,57 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | | value: 'udef' - | | | | | | | | | | | | | position: 7:5 + | | | | | | | | | | | | | position: 7:5+6 | | | | | | | | | | | | key: null | | | | | | | | | | | | byRef: false | | | | | | | | | | | | unpack: false - | | | | | | | | | | | | position: 7:5 + | | | | | | | | | | | | position: 7:5+6 | | | | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | | | value: 'id' - | | | | | | | | | | | | | position: 7:13 + | | | | | | | | | | | | | position: 7:13+4 | | | | | | | | | | | | key: null | | | | | | | | | | | | byRef: false | | | | | | | | | | | | unpack: false - | | | | | | | | | | | | position: 7:13 - | | | | | | | | | | position: 7:4 + | | | | | | | | | | | | position: 7:13+4 + | | | | | | | | | | position: 7:4+14 | | | | | | | | | byRef: false | | | | | | | | | unpack: false | | | | | | | | | name: null - | | | | | | | | | position: 7:4 - | | | | | | | position: 7:1 + | | | | | | | | | position: 7:4+14 + | | | | | | | position: 7:1+18 | | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 7:20 - | | | | | | position: 7:1 + | | | | | | | position: 7:20+1 + | | | | | | position: 7:1+21 | | | | | args: array (0) - | | | | | position: 7:1 + | | | | | position: 7:1+23 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 7:25 + | | | | | | | position: 7:25+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 7:25 - | | | | position: 7:1 + | | | | | | position: 7:25+10 + | | | | position: 7:1+35 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 5 | | | | | | kind: 10 - | | | | | | position: 7:37 + | | | | | | position: 7:37+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 7:37 - | | | position: 7:1 + | | | | | position: 7:37+1 + | | | position: 7:1+38 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+38 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -231,53 +230,53 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'x' - | | | | | | | | | position: 9:11 + | | | | | | | | | position: 9:11+2 | | | | | | | | default: null | | | | | | | | type: null | | | | | | | | byRef: false | | | | | | | | variadic: false - | | | | | | | | position: 9:11 + | | | | | | | | position: 9:11+2 | | | | | | uses: array (0) | | | | | | returnType: null | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'x' - | | | | | | | position: 9:24 - | | | | | | position: 9:2 + | | | | | | | position: 9:24+2 + | | | | | | position: 9:2+27 | | | | | args: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | value: 'id' - | | | | | | | | position: 9:31 + | | | | | | | | position: 9:31+4 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 9:31 - | | | | | position: 9:1 + | | | | | | | position: 9:31+4 + | | | | | position: 9:1+35 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 9:37 + | | | | | | | position: 9:37+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 9:37 - | | | | position: 9:1 + | | | | | | position: 9:37+10 + | | | | position: 9:1+47 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 8 | | | | | | kind: 10 - | | | | | | position: 9:49 + | | | | | | position: 9:49+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 9:49 - | | | position: 9:1 + | | | | | position: 9:49+1 + | | | position: 9:1+50 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+50 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -287,71 +286,71 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | name: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | name: 'f' - | | | | | | | | | position: 11:2 + | | | | | | | | | position: 11:2+2 | | | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | | | | | | | byRef: false | | | | | | | | | params: array (1) | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | | name: 'x' - | | | | | | | | | | | | position: 11:16 + | | | | | | | | | | | | position: 11:16+2 | | | | | | | | | | | default: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | | | | | | | | position: 11:21 + | | | | | | | | | | | | position: 11:21+4 | | | | | | | | | | | type: null | | | | | | | | | | | byRef: false | | | | | | | | | | | variadic: false - | | | | | | | | | | | position: 11:16 + | | | | | | | | | | | position: 11:16+9 | | | | | | | | | uses: array (1) | | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ClosureUseNode | | | | | | | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | | name: 'f' - | | | | | | | | | | | | position: 11:33 + | | | | | | | | | | | | position: 11:33+2 | | | | | | | | | | | byRef: true - | | | | | | | | | | | position: 11:32 + | | | | | | | | | | | position: 11:32+3 | | | | | | | | | returnType: null | | | | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | | | | | | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | name: 'x' - | | | | | | | | | | | position: 12:12 + | | | | | | | | | | | position: 12:12+2 | | | | | | | | | | if: null | | | | | | | | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | name: 'f' - | | | | | | | | | | | position: 12:18 - | | | | | | | | | | position: 12:12 - | | | | | | | | | position: 11:7 + | | | | | | | | | | | position: 12:18+2 + | | | | | | | | | | position: 12:12+8 + | | | | | | | | | position: 11:7+54 | | | | | | | | byRef: false - | | | | | | | | position: 11:2 + | | | | | | | | position: 11:2+59 | | | | | | | args: array (0) - | | | | | | | position: 11:1 + | | | | | | | position: 11:1+63 | | | | | | args: array (0) - | | | | | | position: 11:1 + | | | | | | position: 11:1+65 | | | | | args: array (0) - | | | | | position: 11:1 + | | | | | position: 11:1+67 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 13:10 + | | | | | | | position: 13:10+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 13:10 - | | | | position: 11:1 + | | | | | | position: 13:10+10 + | | | | position: 11:1+79 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 9 | | | | | | kind: 10 - | | | | | | position: 13:22 + | | | | | | position: 13:22+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 13:22 - | | | position: 11:1 + | | | | | position: 13:22+1 + | | | position: 11:1+82 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+82 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -363,67 +362,67 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | | name: 'obj' - | | | | | | | | | | | position: 15:2 + | | | | | | | | | | | position: 15:2+4 | | | | | | | | | | key: null | | | | | | | | | | byRef: false | | | | | | | | | | unpack: false - | | | | | | | | | | position: 15:2 + | | | | | | | | | | position: 15:2+4 | | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | | | value: 'id' - | | | | | | | | | | | position: 15:8 + | | | | | | | | | | | position: 15:8+4 | | | | | | | | | | key: null | | | | | | | | | | byRef: false | | | | | | | | | | unpack: false - | | | | | | | | | | position: 15:8 - | | | | | | | | position: 15:1 + | | | | | | | | | | position: 15:8+4 + | | | | | | | | position: 15:1+12 | | | | | | | args: array (0) - | | | | | | | position: 15:1 + | | | | | | | position: 15:1+14 | | | | | | args: array (1) | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'id' - | | | | | | | | | position: 15:16 + | | | | | | | | | position: 15:16+4 | | | | | | | | byRef: false | | | | | | | | unpack: false | | | | | | | | name: null - | | | | | | | | position: 15:16 - | | | | | | position: 15:1 + | | | | | | | | position: 15:16+4 + | | | | | | position: 15:1+20 | | | | | args: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | name: 'id' - | | | | | | | | position: 15:22 + | | | | | | | | position: 15:22+3 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 15:22 - | | | | | position: 15:1 + | | | | | | | position: 15:22+3 + | | | | | position: 15:1+25 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 15:27 + | | | | | | | position: 15:27+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 15:27 - | | | | position: 15:1 + | | | | | | position: 15:27+10 + | | | | position: 15:1+37 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 10 | | | | | | kind: 10 - | | | | | | position: 15:39 + | | | | | | position: 15:39+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 15:39 - | | | position: 15:1 + | | | | | position: 15:39+2 + | | | position: 15:1+41 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+41 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -431,44 +430,44 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'id' - | | | | | | | position: 17:1 + | | | | | | | position: 17:1+4 | | | | | | args: array (0) - | | | | | | position: 17:1 + | | | | | | position: 17:1+6 | | | | | args: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | value: 'id' - | | | | | | | | position: 17:8 + | | | | | | | | position: 17:8+4 | | | | | | | byRef: false | | | | | | | unpack: false | | | | | | | name: null - | | | | | | | position: 17:8 - | | | | | position: 17:1 + | | | | | | | position: 17:8+4 + | | | | | position: 17:1+12 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 17:14 + | | | | | | | position: 17:14+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 17:14 - | | | | position: 17:1 + | | | | | | position: 17:14+10 + | | | | position: 17:1+24 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 12 | | | | | | kind: 10 - | | | | | | position: 17:26 + | | | | | | position: 17:26+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 17:26 - | | | position: 17:1 + | | | | | position: 17:26+2 + | | | position: 17:1+28 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+28 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode @@ -476,68 +475,68 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | name: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | | left: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'i' - | | | | | | | position: 19:2 + | | | | | | | position: 19:2+3 | | | | | | operator: '.' | | | | | | right: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'd' - | | | | | | | position: 19:8 - | | | | | | position: 19:2 + | | | | | | | position: 19:8+3 + | | | | | | position: 19:2+9 | | | | | args: array (0) - | | | | | position: 19:1 + | | | | | position: 19:1+13 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 19:15 + | | | | | | | position: 19:15+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 19:15 - | | | | position: 19:1 + | | | | | | position: 19:15+10 + | | | | position: 19:1+25 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 13 | | | | | | kind: 10 - | | | | | | position: 19:27 + | | | | | | position: 19:27+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 19:27 - | | | position: 19:1 + | | | | | position: 19:27+2 + | | | position: 19:1+29 | | key: null | | byRef: false | | unpack: false - | | position: 19:1 + | | position: 19:1+29 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: '\id' - | | | | | position: 21:1 + | | | | | position: 21:1+5 | | | | args: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'var_dump' - | | | | | | | position: 21:7 + | | | | | | | position: 21:7+10 | | | | | | byRef: false | | | | | | unpack: false | | | | | | name: null - | | | | | | position: 21:7 - | | | | position: 21:1 + | | | | | | position: 21:7+10 + | | | | position: 21:1+17 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 14 | | | | | | kind: 10 - | | | | | | position: 21:19 + | | | | | | position: 21:19+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 21:19 - | | | position: 21:1 + | | | | | position: 21:19+2 + | | | position: 21:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 21:1 - position: 1:1 + | | position: 21:1+21 + position: 1:1+378 diff --git a/tests/phpParser/int.phpt b/tests/phpParser/int.phpt index bac9933be..da8104172 100644 --- a/tests/phpParser/int.phpt +++ b/tests/phpParser/int.phpt @@ -1,92 +1,91 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 0 | | | kind: 10 - | | | position: 1:1 + | | | position: 1:1+1 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+1 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 1 | | | kind: 10 - | | | position: 2:1 + | | | position: 2:1+1 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+1 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 4095 | | | kind: 16 - | | | position: 3:1 + | | | position: 3:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+5 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 4095 | | | kind: 16 - | | | position: 4:1 + | | | position: 4:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+5 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 4095 | | | kind: 16 - | | | position: 5:1 + | | | position: 5:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+5 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 511 | | | kind: 8 - | | | position: 6:1 + | | | position: 6:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+4 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 3640 | | | kind: 2 - | | | position: 7:1 + | | | position: 7:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 - position: 1:1 + | | position: 7:1+14 + position: 1:1+48 diff --git a/tests/phpParser/interpolatedNegVarOffset.phpt b/tests/phpParser/interpolatedNegVarOffset.phpt index c7c70ec8a..ddbdfc750 100644 --- a/tests/phpParser/interpolatedNegVarOffset.phpt +++ b/tests/phpParser/interpolatedNegVarOffset.phpt @@ -1,27 +1,26 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode @@ -29,63 +28,63 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 1:2 + | | | | | | position: 1:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '-0' - | | | | | | position: 1:5 - | | | | | position: 1:2 - | | | position: 1:1 + | | | | | | position: 1:5+2 + | | | | | position: 1:2+6 + | | | position: 1:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:2 + | | | | | | position: 2:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: -1 | | | | | | kind: 10 - | | | | | | position: 2:5 - | | | | | position: 2:2 - | | | position: 2:1 + | | | | | | position: 2:5+2 + | | | | | position: 2:2+6 + | | | position: 2:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+8 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:2 + | | | | | | position: 3:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '-0x0' - | | | | | | position: 3:5 - | | | | | position: 3:2 - | | | position: 3:1 + | | | | | | position: 3:5+4 + | | | | | position: 3:2+8 + | | | position: 3:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+10 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:2 + | | | | | | position: 4:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '-00' - | | | | | | position: 4:5 - | | | | | position: 4:2 - | | | position: 4:1 + | | | | | | position: 4:5+3 + | | | | | position: 4:2+7 + | | | position: 4:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+9 + position: 1:1+42 diff --git a/tests/phpParser/interpolatedString.phpt b/tests/phpParser/interpolatedString.phpt index 0445f66c6..8317e0534 100644 --- a/tests/phpParser/interpolatedString.phpt +++ b/tests/phpParser/interpolatedString.phpt @@ -1,326 +1,325 @@ -B", - "$A[B]", - "$A[0]", - "$A[1234]", - "$A[9223372036854775808]", - "$A[000]", - "$A[0x0]", - "$A[0b0]", - "$A[$B]", - "{$A}", - "{$A['B']}", - "\{$A}", - "\{ $A }", - "\\{$A}", - "\\{ $A }", - "$$A[B]", - "A $B C", - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +B", + "$A[B]", + "$A[0]", + "$A[1234]", + "$A[9223372036854775808]", + "$A[000]", + "$A[0x0]", + "$A[0b0]", + "$A[$B]", + "{$A}", + "{$A['B']}", + "\{$A}", + "\{ $A }", + "\\{$A}", + "\\{ $A }", + "$$A[B]", + "A $B C", + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (18) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 1:2 - | | | position: 1:1 + | | | | | position: 1:2+2 + | | | position: 1:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+4 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 2:2 + | | | | | | position: 2:2+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'B' - | | | | | | position: 2:6 + | | | | | | position: 2:6+1 | | | | | nullsafe: false - | | | | | position: 2:2 - | | | position: 2:1 + | | | | | position: 2:2+5 + | | | position: 2:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+7 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 3:2 + | | | | | | position: 3:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'B' - | | | | | | position: 3:5 - | | | | | position: 3:2 - | | | position: 3:1 + | | | | | | position: 3:5+1 + | | | | | position: 3:2+5 + | | | position: 3:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 4:2 + | | | | | | position: 4:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 4:5 - | | | | | position: 4:2 - | | | position: 4:1 + | | | | | | position: 4:5+1 + | | | | | position: 4:2+5 + | | | position: 4:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+7 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 5:2 + | | | | | | position: 5:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 1234 | | | | | | kind: 10 - | | | | | | position: 5:5 - | | | | | position: 5:2 - | | | position: 5:1 + | | | | | | position: 5:5+4 + | | | | | position: 5:2+8 + | | | position: 5:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+10 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 6:2 + | | | | | | position: 6:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '9223372036854775808' - | | | | | | position: 6:5 - | | | | | position: 6:2 - | | | position: 6:1 + | | | | | | position: 6:5+19 + | | | | | position: 6:2+23 + | | | position: 6:1+25 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+25 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 7:2 + | | | | | | position: 7:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '000' - | | | | | | position: 7:5 - | | | | | position: 7:2 - | | | position: 7:1 + | | | | | | position: 7:5+3 + | | | | | position: 7:2+7 + | | | position: 7:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+9 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 8:2 + | | | | | | position: 8:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '0x0' - | | | | | | position: 8:5 - | | | | | position: 8:2 - | | | position: 8:1 + | | | | | | position: 8:5+3 + | | | | | position: 8:2+7 + | | | position: 8:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+9 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 9:2 + | | | | | | position: 9:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '0b0' - | | | | | | position: 9:5 - | | | | | position: 9:2 - | | | position: 9:1 + | | | | | | position: 9:5+3 + | | | | | position: 9:2+7 + | | | position: 9:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+9 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 10:2 + | | | | | | position: 10:2+2 | | | | | index: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'B' - | | | | | | position: 10:5 - | | | | | position: 10:2 - | | | position: 10:1 + | | | | | | position: 10:5+2 + | | | | | position: 10:2+6 + | | | position: 10:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+8 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 11:3 - | | | position: 11:1 + | | | | | position: 11:3+2 + | | | position: 11:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+6 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 12:3 + | | | | | | position: 12:3+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'B' - | | | | | | position: 12:6 - | | | | | position: 12:3 - | | | position: 12:1 + | | | | | | position: 12:6+3 + | | | | | position: 12:3+7 + | | | position: 12:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+11 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (3) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '\{' - | | | | | position: 13:2 + | | | | | position: 13:2+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 13:4 + | | | | | position: 13:4+2 | | | | 2 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '}' - | | | | | position: 13:6 - | | | position: 13:1 + | | | | | position: 13:6+1 + | | | position: 13:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+7 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (3) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '\{ ' - | | | | | position: 14:2 + | | | | | position: 14:2+3 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 14:5 + | | | | | position: 14:5+2 | | | | 2 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: ' }' - | | | | | position: 14:7 - | | | position: 14:1 + | | | | | position: 14:7+2 + | | | position: 14:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+9 | 14 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '\' - | | | | | position: 15:2 + | | | | | position: 15:2+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 15:5 - | | | position: 15:1 + | | | | | position: 15:5+2 + | | | position: 15:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+8 | 15 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (3) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '\{ ' - | | | | | position: 16:2 + | | | | | position: 16:2+4 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'A' - | | | | | position: 16:6 + | | | | | position: 16:6+2 | | | | 2 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: ' }' - | | | | | position: 16:8 - | | | position: 16:1 + | | | | | position: 16:8+2 + | | | position: 16:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+10 | 16 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: '$' - | | | | | position: 17:2 + | | | | | position: 17:2+1 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'A' - | | | | | | position: 17:3 + | | | | | | position: 17:3+2 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'B' - | | | | | | position: 17:6 - | | | | | position: 17:3 - | | | position: 17:1 + | | | | | | position: 17:6+1 + | | | | | position: 17:3+5 + | | | position: 17:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+8 | 17 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (3) | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: 'A ' - | | | | | position: 18:2 + | | | | | position: 18:2+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'B' - | | | | | position: 18:4 + | | | | | position: 18:4+2 | | | | 2 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | value: ' C' - | | | | | position: 18:6 - | | | position: 18:1 + | | | | | position: 18:6+2 + | | | position: 18:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 18:1 - position: 1:1 + | | position: 18:1+8 + position: 1:1+197 diff --git a/tests/phpParser/isset.phpt b/tests/phpParser/isset.phpt index 7832d9bf4..7405eaa23 100644 --- a/tests/phpParser/isset.phpt +++ b/tests/phpParser/isset.phpt @@ -1,26 +1,25 @@ - 'b']->a), - isset("str"->a), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + 'b']->a), + isset("str"->a), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (3) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode @@ -33,36 +32,36 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | | value: 0 | | | | | | | | | | kind: 10 - | | | | | | | | | | position: 1:9 + | | | | | | | | | | position: 1:9+1 | | | | | | | | | key: null | | | | | | | | | byRef: false | | | | | | | | | unpack: false - | | | | | | | | | position: 1:9 + | | | | | | | | | position: 1:9+1 | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | | | value: 1 | | | | | | | | | | kind: 10 - | | | | | | | | | | position: 1:12 + | | | | | | | | | | position: 1:12+1 | | | | | | | | | key: null | | | | | | | | | byRef: false | | | | | | | | | unpack: false - | | | | | | | | | position: 1:12 - | | | | | | | position: 1:8 + | | | | | | | | | position: 1:12+1 + | | | | | | | position: 1:8+6 | | | | | | operator: '+' | | | | | | right: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | items: array (0) - | | | | | | | position: 1:17 - | | | | | | position: 1:8 + | | | | | | | position: 1:17+2 + | | | | | | position: 1:8+11 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 1:21 - | | | | | position: 1:7 - | | | position: 1:1 + | | | | | | position: 1:21+1 + | | | | | position: 1:7+16 + | | | position: 1:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+23 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (1) @@ -72,39 +71,39 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'b' - | | | | | | | | | position: 2:15 + | | | | | | | | | position: 2:15+3 | | | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | | | value: 'a' - | | | | | | | | | position: 2:8 + | | | | | | | | | position: 2:8+3 | | | | | | | | byRef: false | | | | | | | | unpack: false - | | | | | | | | position: 2:8 - | | | | | | position: 2:7 + | | | | | | | | position: 2:8+10 + | | | | | | position: 2:7+12 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'a' - | | | | | | position: 2:21 + | | | | | | position: 2:21+1 | | | | | nullsafe: false - | | | | | position: 2:7 - | | | position: 2:1 + | | | | | position: 2:7+15 + | | | position: 2:1+22 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+22 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'str' - | | | | | | position: 3:7 + | | | | | | position: 3:7+5 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'a' - | | | | | | position: 3:14 + | | | | | | position: 3:14+1 | | | | | nullsafe: false - | | | | | position: 3:7 - | | | position: 3:1 + | | | | | position: 3:7+8 + | | | position: 3:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 - position: 1:1 + | | position: 3:1+15 + position: 1:1+65 diff --git a/tests/phpParser/issetAndEmpty.phpt b/tests/phpParser/issetAndEmpty.phpt index 597487081..0d77276fa 100644 --- a/tests/phpParser/issetAndEmpty.phpt +++ b/tests/phpParser/issetAndEmpty.phpt @@ -1,82 +1,81 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 1:7 - | | | position: 1:1 + | | | | | position: 1:7+2 + | | | position: 1:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+9 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (3) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 2:7 + | | | | | position: 2:7+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 2:11 + | | | | | position: 2:11+2 | | | | 2 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 2:15 - | | | position: 2:1 + | | | | | position: 2:15+2 + | | | position: 2:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+17 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\EmptyNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:7 - | | | position: 4:1 + | | | | position: 4:7+2 + | | | position: 4:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+9 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\EmptyNode | | | expr: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'foo' | | | | | kind: 1 - | | | | | position: 5:7 + | | | | | position: 5:7+3 | | | | args: array (0) - | | | | position: 5:7 - | | | position: 5:1 + | | | | position: 5:7+5 + | | | position: 5:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+12 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\EmptyNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayNode @@ -85,33 +84,33 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 6:13 + | | | | | | | position: 6:13+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 6:13 + | | | | | | position: 6:13+1 | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 2 | | | | | | | kind: 10 - | | | | | | | position: 6:16 + | | | | | | | position: 6:16+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 6:16 + | | | | | | position: 6:16+1 | | | | | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 3 | | | | | | | kind: 10 - | | | | | | | position: 6:19 + | | | | | | | position: 6:19+1 | | | | | | key: null | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 6:19 - | | | | position: 6:7 - | | | position: 6:1 + | | | | | | position: 6:19+1 + | | | | position: 6:7+14 + | | | position: 6:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+21 + position: 1:1+78 diff --git a/tests/phpParser/listAssign.phpt b/tests/phpParser/listAssign.phpt index c84e0548c..a4bd865a4 100644 --- a/tests/phpParser/listAssign.phpt +++ b/tests/phpParser/listAssign.phpt @@ -1,36 +1,35 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode @@ -39,20 +38,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 2:6 + | | | | | | | position: 2:6+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 2:6 - | | | | position: 2:1 + | | | | | | position: 2:6+2 + | | | | position: 2:1+8 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 2:12 + | | | | position: 2:12+2 | | | byRef: false - | | | position: 2:1 + | | | position: 2:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+13 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -60,28 +59,28 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 3:6 + | | | | | | | position: 3:6+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 3:6 + | | | | | | position: 3:6+2 | | | | | 1 => null | | | | | 2 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 3:12 + | | | | | | | position: 3:12+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 3:12 - | | | | position: 3:1 + | | | | | | position: 3:12+2 + | | | | position: 3:1+14 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 3:18 + | | | | position: 3:18+2 | | | byRef: false - | | | position: 3:1 + | | | position: 3:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+19 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -89,10 +88,10 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 4:6 + | | | | | | | position: 4:6+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 4:6 + | | | | | | position: 4:6+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\ListNode | | | | | | | items: array (2) @@ -100,31 +99,31 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'c' - | | | | | | | | | | position: 4:17 + | | | | | | | | | | position: 4:17+2 | | | | | | | | | key: null | | | | | | | | | byRef: false - | | | | | | | | | position: 4:17 - | | | | | | | position: 4:10 + | | | | | | | | | position: 4:17+2 + | | | | | | | position: 4:10+10 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 4:10 + | | | | | | position: 4:10+10 | | | | | 2 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'd' - | | | | | | | position: 4:22 + | | | | | | | position: 4:22+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 4:22 - | | | | position: 4:1 + | | | | | | position: 4:22+2 + | | | | position: 4:1+24 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'e' - | | | | position: 4:28 + | | | | position: 4:28+2 | | | byRef: false - | | | position: 4:1 + | | | position: 4:1+29 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+29 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -132,20 +131,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 7:2 + | | | | | | | position: 7:2+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 7:2 - | | | | position: 7:1 + | | | | | | position: 7:2+2 + | | | | position: 7:1+4 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 7:8 + | | | | position: 7:8+2 | | | byRef: false - | | | position: 7:1 + | | | position: 7:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+9 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -153,28 +152,28 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 8:2 + | | | | | | | position: 8:2+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 8:2 + | | | | | | position: 8:2+2 | | | | | 1 => null | | | | | 2 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 8:8 + | | | | | | | position: 8:8+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 8:8 - | | | | position: 8:1 + | | | | | | position: 8:8+2 + | | | | position: 8:1+10 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 8:14 + | | | | position: 8:14+2 | | | byRef: false - | | | position: 8:1 + | | | position: 8:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+15 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -182,10 +181,10 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 9:2 + | | | | | | | position: 9:2+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 9:2 + | | | | | | position: 9:2+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\ListNode | | | | | | | items: array (2) @@ -193,31 +192,31 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'c' - | | | | | | | | | | position: 9:9 + | | | | | | | | | | position: 9:9+2 | | | | | | | | | key: null | | | | | | | | | byRef: false - | | | | | | | | | position: 9:9 - | | | | | | | position: 9:6 + | | | | | | | | | position: 9:9+2 + | | | | | | | position: 9:6+6 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 9:6 + | | | | | | position: 9:6+6 | | | | | 2 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'd' - | | | | | | | position: 9:14 + | | | | | | | position: 9:14+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 9:14 - | | | | position: 9:1 + | | | | | | position: 9:14+2 + | | | | position: 9:1+16 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'e' - | | | | position: 9:20 + | | | | position: 9:20+2 | | | byRef: false - | | | position: 9:1 + | | | position: 9:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+21 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -225,10 +224,10 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 12:2 + | | | | | | | position: 12:2+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 12:2 + | | | | | | position: 12:2+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\ListNode | | | | | | | items: array (2) @@ -236,24 +235,24 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'c' - | | | | | | | | | | position: 12:13 + | | | | | | | | | | position: 12:13+2 | | | | | | | | | key: null | | | | | | | | | byRef: false - | | | | | | | | | position: 12:13 - | | | | | | | position: 12:6 + | | | | | | | | | position: 12:13+2 + | | | | | | | position: 12:6+10 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 12:6 - | | | | position: 12:1 + | | | | | | position: 12:6+10 + | | | | position: 12:1+16 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'e' - | | | | position: 12:20 + | | | | position: 12:20+2 | | | byRef: false - | | | position: 12:1 + | | | position: 12:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+21 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -261,10 +260,10 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 13:6 + | | | | | | | position: 13:6+2 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 13:6 + | | | | | | position: 13:6+2 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\ListNode | | | | | | | items: array (2) @@ -272,22 +271,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'c' - | | | | | | | | | | position: 13:13 + | | | | | | | | | | position: 13:13+2 | | | | | | | | | key: null | | | | | | | | | byRef: false - | | | | | | | | | position: 13:13 - | | | | | | | position: 13:10 + | | | | | | | | | position: 13:13+2 + | | | | | | | position: 13:10+6 | | | | | | key: null | | | | | | byRef: false - | | | | | | position: 13:10 - | | | | position: 13:1 + | | | | | | position: 13:10+6 + | | | | position: 13:1+16 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'e' - | | | | position: 13:20 + | | | | position: 13:20+2 | | | byRef: false - | | | position: 13:1 + | | | position: 13:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 - position: 2:1 + | | position: 13:1+21 + position: 2:1+213 diff --git a/tests/phpParser/listReferences.phpt b/tests/phpParser/listReferences.phpt index fc61cbbdb..9ce5b6751 100644 --- a/tests/phpParser/listReferences.phpt +++ b/tests/phpParser/listReferences.phpt @@ -1,27 +1,26 @@ - &$v) = $x, - [&$v] = $x, - ['k' => &$v] = $x, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + &$v) = $x, + [&$v] = $x, + ['k' => &$v] = $x, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (4) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode @@ -30,20 +29,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'v' - | | | | | | | position: 1:7 + | | | | | | | position: 1:7+2 | | | | | | key: null | | | | | | byRef: true - | | | | | | position: 1:6 - | | | | position: 1:1 + | | | | | | position: 1:6+3 + | | | | position: 1:1+9 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 1:13 + | | | | position: 1:13+2 | | | byRef: false - | | | position: 1:1 + | | | position: 1:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+14 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -51,22 +50,22 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'v' - | | | | | | | position: 2:14 + | | | | | | | position: 2:14+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'k' - | | | | | | | position: 2:6 + | | | | | | | position: 2:6+3 | | | | | | byRef: true - | | | | | | position: 2:6 - | | | | position: 2:1 + | | | | | | position: 2:6+10 + | | | | position: 2:1+16 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 2:20 + | | | | position: 2:20+2 | | | byRef: false - | | | position: 2:1 + | | | position: 2:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+21 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -74,20 +73,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'v' - | | | | | | | position: 3:3 + | | | | | | | position: 3:3+2 | | | | | | key: null | | | | | | byRef: true - | | | | | | position: 3:2 - | | | | position: 3:1 + | | | | | | position: 3:2+3 + | | | | position: 3:1+5 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 3:9 + | | | | position: 3:9+2 | | | byRef: false - | | | position: 3:1 + | | | position: 3:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+10 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -95,20 +94,20 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'v' - | | | | | | | position: 4:10 + | | | | | | | position: 4:10+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'k' - | | | | | | | position: 4:2 + | | | | | | | position: 4:2+3 | | | | | | byRef: true - | | | | | | position: 4:2 - | | | | position: 4:1 + | | | | | | position: 4:2+10 + | | | | position: 4:1+12 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 4:16 + | | | | position: 4:16+2 | | | byRef: false - | | | position: 4:1 + | | | position: 4:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+17 + position: 1:1+69 diff --git a/tests/phpParser/listWithKeys.phpt b/tests/phpParser/listWithKeys.phpt index 800211b4c..87d3c8bf3 100644 --- a/tests/phpParser/listWithKeys.phpt +++ b/tests/phpParser/listWithKeys.phpt @@ -1,25 +1,24 @@ - $b) = ['a' => 'b'], - list('a' => list($b => $c), 'd' => $e) = $x, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $b) = ['a' => 'b'], + list('a' => list($b => $c), 'd' => $e) = $x, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (2) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode @@ -28,32 +27,32 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'b' - | | | | | | | position: 1:13 + | | | | | | | position: 1:13+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'a' - | | | | | | | position: 1:6 + | | | | | | | position: 1:6+3 | | | | | | byRef: false - | | | | | | position: 1:6 - | | | | position: 1:1 + | | | | | | position: 1:6+9 + | | | | position: 1:1+15 | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | items: array (1) | | | | | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'b' - | | | | | | | position: 1:27 + | | | | | | | position: 1:27+3 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'a' - | | | | | | | position: 1:20 + | | | | | | | position: 1:20+3 | | | | | | byRef: false | | | | | | unpack: false - | | | | | | position: 1:20 - | | | | position: 1:19 + | | | | | | position: 1:20+10 + | | | | position: 1:19+12 | | | byRef: false - | | | position: 1:1 + | | | position: 1:1+30 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+30 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\ListNode @@ -64,35 +63,35 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | | 0 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'c' - | | | | | | | | | | position: 2:24 + | | | | | | | | | | position: 2:24+2 | | | | | | | | | key: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | | | | name: 'b' - | | | | | | | | | | position: 2:18 + | | | | | | | | | | position: 2:18+2 | | | | | | | | | byRef: false - | | | | | | | | | position: 2:18 - | | | | | | | position: 2:13 + | | | | | | | | | position: 2:18+8 + | | | | | | | position: 2:13+14 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'a' - | | | | | | | position: 2:6 + | | | | | | | position: 2:6+3 | | | | | | byRef: false - | | | | | | position: 2:6 + | | | | | | position: 2:6+21 | | | | | 1 => Latte\Compiler\Nodes\Php\ListItemNode | | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'e' - | | | | | | | position: 2:36 + | | | | | | | position: 2:36+2 | | | | | | key: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | | value: 'd' - | | | | | | | position: 2:29 + | | | | | | | position: 2:29+3 | | | | | | byRef: false - | | | | | | position: 2:29 - | | | | position: 2:1 + | | | | | | position: 2:29+9 + | | | | position: 2:1+38 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'x' - | | | | position: 2:42 + | | | | position: 2:42+2 | | | byRef: false - | | | position: 2:1 + | | | position: 2:1+43 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 - position: 1:1 + | | position: 2:1+43 + position: 1:1+76 diff --git a/tests/phpParser/literals.phpt b/tests/phpParser/literals.phpt index 46ae80ac8..889f1061c 100644 --- a/tests/phpParser/literals.phpt +++ b/tests/phpParser/literals.phpt @@ -1,102 +1,101 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: true - | | | position: 1:1 + | | | position: 1:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+4 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: false - | | | position: 2:1 + | | | position: 2:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+5 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | position: 3:1 + | | | position: 3:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+4 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: true - | | | position: 5:1 + | | | position: 5:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+4 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: false - | | | position: 6:1 + | | | position: 6:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+5 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | position: 7:1 + | | | position: 7:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+4 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: true - | | | position: 9:1 + | | | position: 9:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+4 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\BooleanNode | | | value: false - | | | position: 10:1 + | | | position: 10:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+5 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | position: 11:1 + | | | position: 11:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 - position: 1:1 + | | position: 11:1+4 + position: 1:1+58 diff --git a/tests/phpParser/logic.phpt b/tests/phpParser/logic.phpt index 8de70ab42..8b14ed508 100644 --- a/tests/phpParser/logic.phpt +++ b/tests/phpParser/logic.phpt @@ -1,226 +1,225 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | operator: '&&' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 2:7 - | | | position: 2:1 + | | | | position: 2:7+2 + | | | position: 2:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:1 + | | | | position: 3:1+2 | | | operator: '||' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 3:7 - | | | position: 3:1 + | | | | position: 3:7+2 + | | | position: 3:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+8 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:2 + | | | | position: 4:2+2 | | | operator: '!' - | | | position: 4:1 + | | | position: 4:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+3 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 5:3 + | | | | | position: 5:3+2 | | | | operator: '!' - | | | | position: 5:2 + | | | | position: 5:2+3 | | | operator: '!' - | | | position: 5:1 + | | | position: 5:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+4 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:1 + | | | | position: 8:1+2 | | | operator: 'and' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 8:8 - | | | position: 8:1 + | | | | position: 8:8+2 + | | | position: 8:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+9 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 9:1 + | | | | position: 9:1+2 | | | operator: 'or' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 9:7 - | | | position: 9:1 + | | | | position: 9:7+2 + | | | position: 9:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+8 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 10:1 + | | | | position: 10:1+2 | | | operator: 'xor' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 10:8 - | | | position: 10:1 + | | | | position: 10:8+2 + | | | position: 10:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+9 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 13:1 + | | | | | position: 13:1+2 | | | | operator: '&&' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 13:7 - | | | | position: 13:1 + | | | | | position: 13:7+2 + | | | | position: 13:1+8 | | | operator: '||' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 13:13 + | | | | | position: 13:13+2 | | | | operator: '&&' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'd' - | | | | | position: 13:19 - | | | | position: 13:13 - | | | position: 13:1 + | | | | | position: 13:19+2 + | | | | position: 13:13+8 + | | | position: 13:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+20 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 14:1 + | | | | | position: 14:1+2 | | | | operator: '&&' | | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 14:8 + | | | | | | position: 14:8+2 | | | | | operator: '||' | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 14:14 - | | | | | position: 14:8 - | | | | position: 14:1 + | | | | | | position: 14:14+2 + | | | | | position: 14:8+8 + | | | | position: 14:1+16 | | | operator: '&&' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'd' - | | | | position: 14:21 - | | | position: 14:1 + | | | | position: 14:21+2 + | | | position: 14:1+22 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+22 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 16:1 + | | | | position: 16:1+2 | | | expr: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 16:6 + | | | | | position: 16:6+2 | | | | operator: '||' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 16:12 - | | | | position: 16:6 + | | | | | position: 16:12+2 + | | | | position: 16:6+8 | | | byRef: false - | | | position: 16:1 + | | | position: 16:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+13 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 17:1 + | | | | | position: 17:1+2 | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 17:6 + | | | | | position: 17:6+2 | | | | byRef: false - | | | | position: 17:1 + | | | | position: 17:1+7 | | | operator: 'or' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 17:12 - | | | position: 17:1 + | | | | position: 17:12+2 + | | | position: 17:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 - position: 2:1 + | | position: 17:1+13 + position: 2:1+176 diff --git a/tests/phpParser/match.phpt b/tests/phpParser/match.phpt index 1efa2c7e7..1e3bf70d8 100644 --- a/tests/phpParser/match.phpt +++ b/tests/phpParser/match.phpt @@ -1,110 +1,109 @@ - 'Foo', - 1 => 'Bar', - }, - - match (1) { - /* list of conditions */ - 0, 1 => 'Foo', - }, - - match ($operator) { - BinaryOperator::ADD => $lhs + $rhs, - }, - - match ($char) { - 1 => '1', - default => 'default' - }, - - match (1) { - 0, 1, => 'Foo', - default, => 'Bar', - }, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + 'Foo', + 1 => 'Bar', + }, + + match (1) { + /* list of conditions */ + 0, 1 => 'Foo', + }, + + match ($operator) { + BinaryOperator::ADD => $lhs + $rhs, + }, + + match ($char) { + 1 => '1', + default => 'default' + }, + + match (1) { + 0, 1, => 'Foo', + default, => 'Bar', + }, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (5) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MatchNode | | | cond: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 1 | | | | kind: 10 - | | | | position: 1:8 + | | | | position: 1:8+1 | | | arms: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 0 | | | | | | | kind: 10 - | | | | | | | position: 2:5 + | | | | | | | position: 2:5+1 | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'Foo' - | | | | | | position: 2:10 - | | | | | position: 2:5 + | | | | | | position: 2:10+5 + | | | | | position: 2:5+10 | | | | 1 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 3:5 + | | | | | | | position: 3:5+1 | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'Bar' - | | | | | | position: 3:10 - | | | | | position: 3:5 - | | | position: 1:1 + | | | | | | position: 3:10+5 + | | | | | position: 3:5+10 + | | | position: 1:1+45 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+45 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MatchNode | | | cond: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 1 | | | | kind: 10 - | | | | position: 6:8 + | | | | position: 6:8+1 | | | arms: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (2) | | | | | | 0 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 0 | | | | | | | kind: 10 - | | | | | | | position: 8:5 + | | | | | | | position: 8:5+1 | | | | | | 1 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 8:8 + | | | | | | | position: 8:8+1 | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'Foo' - | | | | | | position: 8:13 - | | | | | position: 8:5 - | | | position: 6:1 + | | | | | | position: 8:13+5 + | | | | | position: 8:5+13 + | | | position: 6:1+61 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+61 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MatchNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'operator' - | | | | position: 11:8 + | | | | position: 11:8+9 | | | arms: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (1) @@ -112,83 +111,83 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'BinaryOperator' | | | | | | | | kind: 1 - | | | | | | | | position: 12:5 + | | | | | | | | position: 12:5+14 | | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | name: 'ADD' - | | | | | | | | position: 12:21 - | | | | | | | position: 12:5 + | | | | | | | | position: 12:21+3 + | | | | | | | position: 12:5+19 | | | | | body: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'lhs' - | | | | | | | position: 12:28 + | | | | | | | position: 12:28+4 | | | | | | operator: '+' | | | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'rhs' - | | | | | | | position: 12:35 - | | | | | | position: 12:28 - | | | | | position: 12:5 - | | | position: 11:1 + | | | | | | | position: 12:35+4 + | | | | | | position: 12:28+11 + | | | | | position: 12:5+34 + | | | position: 11:1+61 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+61 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MatchNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'char' - | | | | position: 15:8 + | | | | position: 15:8+5 | | | arms: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (1) | | | | | | 0 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 16:5 + | | | | | | | position: 16:5+1 | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: '1' - | | | | | | position: 16:10 - | | | | | position: 16:5 + | | | | | | position: 16:10+3 + | | | | | position: 16:5+8 | | | | 1 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: null | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'default' - | | | | | | position: 17:16 - | | | | | position: 17:5 - | | | position: 15:1 + | | | | | | position: 17:16+9 + | | | | | position: 17:5+20 + | | | position: 15:1+56 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+56 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MatchNode | | | cond: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 1 | | | | kind: 10 - | | | | position: 20:8 + | | | | position: 20:8+1 | | | arms: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: array (2) | | | | | | 0 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 0 | | | | | | | kind: 10 - | | | | | | | position: 21:5 + | | | | | | | position: 21:5+1 | | | | | | 1 => Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 1 | | | | | | | kind: 10 - | | | | | | | position: 21:8 + | | | | | | | position: 21:8+1 | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'Foo' - | | | | | | position: 21:14 - | | | | | position: 21:5 + | | | | | | position: 21:14+5 + | | | | | position: 21:5+14 | | | | 1 => Latte\Compiler\Nodes\Php\MatchArmNode | | | | | conds: null | | | | | body: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'Bar' - | | | | | | position: 22:17 - | | | | | position: 22:5 - | | | position: 20:1 + | | | | | | position: 22:17+5 + | | | | | position: 22:5+17 + | | | position: 20:1+56 | | key: null | | byRef: false | | unpack: false - | | position: 20:1 - position: 1:1 + | | position: 20:1+56 + position: 1:1+292 diff --git a/tests/phpParser/math.phpt b/tests/phpParser/math.phpt index 6d0339228..14665e89e 100644 --- a/tests/phpParser/math.phpt +++ b/tests/phpParser/math.phpt @@ -1,374 +1,373 @@ -> $b, - $a ** $b, - - /* associativity */ - $a * $b * $c, - $a * ($b * $c), - - /* precedence */ - $a + $b * $c, - ($a + $b) * $c, - - /* pow is special */ - $a ** $b ** $c, - ($a ** $b) ** $c, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +> $b, + $a ** $b, + + /* associativity */ + $a * $b * $c, + $a * ($b * $c), + + /* precedence */ + $a + $b * $c, + ($a + $b) * $c, + + /* pow is special */ + $a ** $b ** $c, + ($a ** $b) ** $c, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (21) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:2 + | | | | position: 2:2+2 | | | operator: '~' - | | | position: 2:1 + | | | position: 2:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+3 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:2 + | | | | position: 3:2+2 | | | operator: '+' - | | | position: 3:1 + | | | position: 3:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+3 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\UnaryOpNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 4:2 + | | | | position: 4:2+2 | | | operator: '-' - | | | position: 4:1 + | | | position: 4:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+3 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:1 + | | | | position: 7:1+2 | | | operator: '|' | | | right: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 1 | | | | kind: 10 - | | | | position: 7:6 - | | | position: 7:1 + | | | | position: 7:6+1 + | | | position: 7:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+6 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:1 + | | | | position: 8:1+2 | | | operator: '&' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 8:6 - | | | position: 8:1 + | | | | position: 8:6+2 + | | | position: 8:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+7 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 9:1 + | | | | position: 9:1+2 | | | operator: '^' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 9:6 - | | | position: 9:1 + | | | | position: 9:6+2 + | | | position: 9:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+7 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 10:1 + | | | | position: 10:1+2 | | | operator: '.' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 10:6 - | | | position: 10:1 + | | | | position: 10:6+2 + | | | position: 10:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+7 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 11:1 + | | | | position: 11:1+2 | | | operator: '/' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 11:6 - | | | position: 11:1 + | | | | position: 11:6+2 + | | | position: 11:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+7 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 12:1 + | | | | position: 12:1+2 | | | operator: '-' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 12:6 - | | | position: 12:1 + | | | | position: 12:6+2 + | | | position: 12:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+7 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 13:1 + | | | | position: 13:1+2 | | | operator: '%' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 13:6 - | | | position: 13:1 + | | | | position: 13:6+2 + | | | position: 13:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+7 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 14:1 + | | | | position: 14:1+2 | | | operator: '*' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 14:6 - | | | position: 14:1 + | | | | position: 14:6+2 + | | | position: 14:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+7 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 15:1 + | | | | position: 15:1+2 | | | operator: '+' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 15:6 - | | | position: 15:1 + | | | | position: 15:6+2 + | | | position: 15:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+7 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 16:1 + | | | | position: 16:1+2 | | | operator: '<<' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 16:7 - | | | position: 16:1 + | | | | position: 16:7+2 + | | | position: 16:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+8 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 17:1 + | | | | position: 17:1+2 | | | operator: '>>' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 17:7 - | | | position: 17:1 + | | | | position: 17:7+2 + | | | position: 17:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+8 | 14 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 18:1 + | | | | position: 18:1+2 | | | operator: '**' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 18:7 - | | | position: 18:1 + | | | | position: 18:7+2 + | | | position: 18:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 18:1 + | | position: 18:1+8 | 15 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 21:1 + | | | | | position: 21:1+2 | | | | operator: '*' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 21:6 - | | | | position: 21:1 + | | | | | position: 21:6+2 + | | | | position: 21:1+7 | | | operator: '*' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 21:11 - | | | position: 21:1 + | | | | position: 21:11+2 + | | | position: 21:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 21:1 + | | position: 21:1+12 | 16 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 22:1 + | | | | position: 22:1+2 | | | operator: '*' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 22:7 + | | | | | position: 22:7+2 | | | | operator: '*' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 22:12 - | | | | position: 22:7 - | | | position: 22:1 + | | | | | position: 22:12+2 + | | | | position: 22:7+7 + | | | position: 22:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 22:1 + | | position: 22:1+14 | 17 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 25:1 + | | | | position: 25:1+2 | | | operator: '+' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 25:6 + | | | | | position: 25:6+2 | | | | operator: '*' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 25:11 - | | | | position: 25:6 - | | | position: 25:1 + | | | | | position: 25:11+2 + | | | | position: 25:6+7 + | | | position: 25:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 25:1 + | | position: 25:1+12 | 18 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 26:2 + | | | | | position: 26:2+2 | | | | operator: '+' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 26:7 - | | | | position: 26:2 + | | | | | position: 26:7+2 + | | | | position: 26:2+7 | | | operator: '*' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 26:13 - | | | position: 26:1 + | | | | position: 26:13+2 + | | | position: 26:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 26:1 + | | position: 26:1+14 | 19 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 29:1 + | | | | position: 29:1+2 | | | operator: '**' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 29:7 + | | | | | position: 29:7+2 | | | | operator: '**' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 29:13 - | | | | position: 29:7 - | | | position: 29:1 + | | | | | position: 29:13+2 + | | | | position: 29:7+8 + | | | position: 29:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 29:1 + | | position: 29:1+14 | 20 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 30:2 + | | | | | position: 30:2+2 | | | | operator: '**' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 30:8 - | | | | position: 30:2 + | | | | | position: 30:8+2 + | | | | position: 30:2+8 | | | operator: '**' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 30:15 - | | | position: 30:1 + | | | | position: 30:15+2 + | | | position: 30:1+16 | | key: null | | byRef: false | | unpack: false - | | position: 30:1 - position: 2:1 + | | position: 30:1+16 + position: 2:1+297 diff --git a/tests/phpParser/misc.phpt b/tests/phpParser/misc.phpt index b3c76b7d0..bd12fc61b 100644 --- a/tests/phpParser/misc.phpt +++ b/tests/phpParser/misc.phpt @@ -1,85 +1,84 @@ -length(), - "foo$bar"[0], - "foo$bar"->length(), - (clone $obj)->b[0](1), - [0, 1][0] = 1, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +length(), + "foo$bar"[0], + "foo$bar"->length(), + (clone $obj)->b[0](1), + [0, 1][0] = 1, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (5) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'string' - | | | | position: 1:1 + | | | | position: 1:1+8 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 1:11 + | | | | position: 1:11+6 | | | args: array (0) | | | nullsafe: false - | | | position: 1:1 + | | | position: 1:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+18 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | | parts: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | | value: 'foo' - | | | | | | position: 2:2 + | | | | | | position: 2:2+3 | | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'bar' - | | | | | | position: 2:5 - | | | | position: 2:1 + | | | | | | position: 2:5+4 + | | | | position: 2:1+9 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 2:11 - | | | position: 2:1 + | | | | position: 2:11+1 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | | parts: array (2) | | | | | 0 => Latte\Compiler\Nodes\Php\InterpolatedStringPartNode | | | | | | value: 'foo' - | | | | | | position: 3:2 + | | | | | | position: 3:2+3 | | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'bar' - | | | | | | position: 3:5 - | | | | position: 3:1 + | | | | | | position: 3:5+4 + | | | | position: 3:1+9 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'length' - | | | | position: 3:12 + | | | | position: 3:12+6 | | | args: array (0) | | | nullsafe: false - | | | position: 3:1 + | | | position: 3:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+19 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -87,33 +86,33 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\CloneNode | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'obj' - | | | | | | | position: 4:8 - | | | | | | position: 4:2 + | | | | | | | position: 4:8+4 + | | | | | | position: 4:2+10 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 4:15 + | | | | | | position: 4:15+1 | | | | | nullsafe: false - | | | | | position: 4:1 + | | | | | position: 4:1+15 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 4:17 - | | | | position: 4:1 + | | | | | position: 4:17+1 + | | | | position: 4:1+18 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 1 | | | | | | kind: 10 - | | | | | | position: 4:20 + | | | | | | position: 4:20+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 4:20 - | | | position: 4:1 + | | | | | position: 4:20+1 + | | | position: 4:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+21 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -123,34 +122,34 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 0 | | | | | | | | kind: 10 - | | | | | | | | position: 5:2 + | | | | | | | | position: 5:2+1 | | | | | | | key: null | | | | | | | byRef: false | | | | | | | unpack: false - | | | | | | | position: 5:2 + | | | | | | | position: 5:2+1 | | | | | | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | | value: 1 | | | | | | | | kind: 10 - | | | | | | | | position: 5:5 + | | | | | | | | position: 5:5+1 | | | | | | | key: null | | | | | | | byRef: false | | | | | | | unpack: false - | | | | | | | position: 5:5 - | | | | | position: 5:1 + | | | | | | | position: 5:5+1 + | | | | | position: 5:1+6 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 5:8 - | | | | position: 5:1 + | | | | | position: 5:8+1 + | | | | position: 5:1+9 | | | expr: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 1 | | | | kind: 10 - | | | | position: 5:13 + | | | | position: 5:13+1 | | | byRef: false - | | | position: 5:1 + | | | position: 5:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+13 + position: 1:1+92 diff --git a/tests/phpParser/modifier.phpt b/tests/phpParser/modifier.phpt index 2a15fb665..a58e83878 100644 --- a/tests/phpParser/modifier.phpt +++ b/tests/phpParser/modifier.phpt @@ -1,73 +1,72 @@ -tokenize($code); -$parser = new Latte\Compiler\TagParser($tokens); -$node = $parser->parseModifier(); -if (!$parser->isEnd()) { - $parser->stream->throwUnexpectedException(); -} - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\ModifierNode +tokenize($code); +$parser = new Latte\Compiler\TagParser($tokens); +$node = $parser->parseModifier(); +if (!$parser->isEnd()) { + $parser->stream->throwUnexpectedException(); +} + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\ModifierNode check: true filters: array (2) | 0 => Latte\Compiler\Nodes\Php\FilterNode | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | name: 'truncate' - | | | position: 1:2 + | | | position: 1:2+8 | | args: array (2) | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 10 | | | | | kind: 10 - | | | | | position: 1:12 + | | | | | position: 1:12+2 | | | | byRef: false | | | | unpack: false | | | | name: null - | | | | position: 1:12 + | | | | position: 1:12+2 | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 20 | | | | | | kind: 10 - | | | | | | position: 1:17 + | | | | | | position: 1:17+2 | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'round' - | | | | | | | position: 1:20 + | | | | | | | position: 1:20+5 | | | | | | args: array (0) | | | | | | nullsafe: false - | | | | | | position: 1:19 - | | | | | position: 1:17 + | | | | | | position: 1:19+6 + | | | | | position: 1:17+8 | | | | byRef: false | | | | unpack: false | | | | name: null - | | | | position: 1:16 + | | | | position: 1:16+10 | | nullsafe: false - | | position: 1:1 + | | position: 1:1+25 | 1 => Latte\Compiler\Nodes\Php\FilterNode | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | name: 'trim' - | | | position: 1:27 + | | | position: 1:27+4 | | args: array (0) | | nullsafe: false - | | position: 1:26 + | | position: 1:26+5 escape: false - position: 1:1 + position: 1:1+30 diff --git a/tests/phpParser/modifierNullsafe.phpt b/tests/phpParser/modifierNullsafe.phpt index 6077ed889..a0ffeb36b 100644 --- a/tests/phpParser/modifierNullsafe.phpt +++ b/tests/phpParser/modifierNullsafe.phpt @@ -1,73 +1,72 @@ -tokenize($code); -$parser = new Latte\Compiler\TagParser($tokens); -$node = $parser->parseModifier(); -if (!$parser->isEnd()) { - $parser->stream->throwUnexpectedException(); -} - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\ModifierNode +tokenize($code); +$parser = new Latte\Compiler\TagParser($tokens); +$node = $parser->parseModifier(); +if (!$parser->isEnd()) { + $parser->stream->throwUnexpectedException(); +} + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\ModifierNode check: true filters: array (2) | 0 => Latte\Compiler\Nodes\Php\FilterNode | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | name: 'truncate' - | | | position: 1:3 + | | | position: 1:3+8 | | args: array (2) | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 10 | | | | | kind: 10 - | | | | | position: 1:13 + | | | | | position: 1:13+2 | | | | byRef: false | | | | unpack: false | | | | name: null - | | | | position: 1:13 + | | | | position: 1:13+2 | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | value: Latte\Compiler\Nodes\Php\Expression\FilterCallNode | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 20 | | | | | | kind: 10 - | | | | | | position: 1:18 + | | | | | | position: 1:18+2 | | | | | filter: Latte\Compiler\Nodes\Php\FilterNode | | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | name: 'round' - | | | | | | | position: 1:22 + | | | | | | | position: 1:22+5 | | | | | | args: array (0) | | | | | | nullsafe: true - | | | | | | position: 1:20 - | | | | | position: 1:18 + | | | | | | position: 1:20+7 + | | | | | position: 1:18+9 | | | | byRef: false | | | | unpack: false | | | | name: null - | | | | position: 1:17 + | | | | position: 1:17+11 | | nullsafe: true - | | position: 1:1 + | | position: 1:1+27 | 1 => Latte\Compiler\Nodes\Php\FilterNode | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | name: 'trim' - | | | position: 1:30 + | | | position: 1:30+4 | | args: array (0) | | nullsafe: true - | | position: 1:28 + | | position: 1:28+6 escape: false - position: 1:1 + position: 1:1+33 diff --git a/tests/phpParser/namedArgs.phpt b/tests/phpParser/namedArgs.phpt index edf74b34e..834dff080 100644 --- a/tests/phpParser/namedArgs.phpt +++ b/tests/phpParser/namedArgs.phpt @@ -1,79 +1,78 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'foo' | | | | kind: 1 - | | | | position: 1:1 + | | | | position: 1:1+3 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 1:8 + | | | | | | position: 1:8+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'a' - | | | | | | position: 1:5 - | | | | | position: 1:5 + | | | | | | position: 1:5+1 + | | | | | position: 1:5+5 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'd' - | | | | | | position: 1:15 + | | | | | | position: 1:15+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'c' - | | | | | | position: 1:12 - | | | | | position: 1:12 - | | | position: 1:1 + | | | | | | position: 1:12+1 + | | | | | position: 1:12+5 + | | | position: 1:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+17 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'bar' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+3 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 0 | | | | | | kind: 10 - | | | | | | position: 2:12 + | | | | | | position: 2:12+1 | | | | | byRef: false | | | | | unpack: false | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'class' - | | | | | | position: 2:5 - | | | | | position: 2:5 - | | | position: 2:1 + | | | | | | position: 2:5+5 + | | | | | position: 2:5+8 + | | | position: 2:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 - position: 1:1 + | | position: 2:1+13 + position: 1:1+33 diff --git a/tests/phpParser/new.phpt b/tests/phpParser/new.phpt index 91be146b9..0aa48272e 100644 --- a/tests/phpParser/new.phpt +++ b/tests/phpParser/new.phpt @@ -1,270 +1,269 @@ -b(), - new $a->b->c(), - new $a->b['c'](), - - /* UVS new expressions */ - new $className, - new $array['className'], - new $obj->className, - new Test::$className, - new $test::$className, - new $weird[0]->foo::$className, - - /* New dereference without parentheses */ - new A()->foo, - new A()->foo(), - new A()::FOO, - new A()::foo(), - new A()::$foo, - new A()[0], - new A()(), - - /* test regression introduces by new dereferencing syntax */ - (new A), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b(), + new $a->b->c(), + new $a->b['c'](), + + /* UVS new expressions */ + new $className, + new $array['className'], + new $obj->className, + new Test::$className, + new $test::$className, + new $weird[0]->foo::$className, + + /* New dereference without parentheses */ + new A()->foo, + new A()->foo(), + new A()::FOO, + new A()::foo(), + new A()::$foo, + new A()[0], + new A()(), + + /* test regression introduces by new dereferencing syntax */ + (new A), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (22) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 1:5 + | | | | position: 1:5+1 | | | args: array (0) - | | | position: 1:1 + | | | position: 1:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+5 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 2:5 + | | | | position: 2:5+1 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:7 + | | | | | | position: 2:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:7 - | | | position: 2:1 + | | | | | position: 2:7+2 + | | | position: 2:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+9 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 5:5 + | | | | position: 5:5+2 | | | args: array (0) - | | | position: 5:1 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+8 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 6:5 + | | | | | position: 6:5+2 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'b' - | | | | | position: 6:8 - | | | | position: 6:5 + | | | | | position: 6:8+3 + | | | | position: 6:5+7 | | | args: array (0) - | | | position: 6:1 + | | | position: 6:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+13 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 7:5 + | | | | | position: 7:5+1 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'b' - | | | | | position: 7:8 - | | | | position: 7:5 + | | | | | position: 7:8+2 + | | | | position: 7:5+5 | | | args: array (0) - | | | position: 7:1 + | | | position: 7:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+11 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 9:5 + | | | | | position: 9:5+2 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 9:9 + | | | | | position: 9:9+1 | | | | nullsafe: false - | | | | position: 9:5 + | | | | position: 9:5+5 | | | args: array (0) - | | | position: 9:1 + | | | position: 9:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+11 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 10:5 + | | | | | | position: 10:5+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 10:9 + | | | | | | position: 10:9+1 | | | | | nullsafe: false - | | | | | position: 10:5 + | | | | | position: 10:5+5 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'c' - | | | | | position: 10:12 + | | | | | position: 10:12+1 | | | | nullsafe: false - | | | | position: 10:5 + | | | | position: 10:5+8 | | | args: array (0) - | | | position: 10:1 + | | | position: 10:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+14 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 11:5 + | | | | | | position: 11:5+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 11:9 + | | | | | | position: 11:9+1 | | | | | nullsafe: false - | | | | | position: 11:5 + | | | | | position: 11:5+5 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'c' - | | | | | position: 11:11 - | | | | position: 11:5 + | | | | | position: 11:11+3 + | | | | position: 11:5+10 | | | args: array (0) - | | | position: 11:1 + | | | position: 11:1+16 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+16 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'className' - | | | | position: 14:5 + | | | | position: 14:5+10 | | | args: array (0) - | | | position: 14:1 + | | | position: 14:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+14 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'array' - | | | | | position: 15:5 + | | | | | position: 15:5+6 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'className' - | | | | | position: 15:12 - | | | | position: 15:5 + | | | | | position: 15:12+11 + | | | | position: 15:5+19 | | | args: array (0) - | | | position: 15:1 + | | | position: 15:1+23 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 + | | position: 15:1+23 | 10 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'obj' - | | | | | position: 16:5 + | | | | | position: 16:5+4 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'className' - | | | | | position: 16:11 + | | | | | position: 16:11+9 | | | | nullsafe: false - | | | | position: 16:5 + | | | | position: 16:5+15 | | | args: array (0) - | | | position: 16:1 + | | | position: 16:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+19 | 11 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'Test' | | | | | kind: 1 - | | | | | position: 17:5 + | | | | | position: 17:5+4 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'className' - | | | | | position: 17:11 - | | | | position: 17:5 + | | | | | position: 17:11+10 + | | | | position: 17:5+16 | | | args: array (0) - | | | position: 17:1 + | | | position: 17:1+20 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 + | | position: 17:1+20 | 12 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'test' - | | | | | position: 18:5 + | | | | | position: 18:5+5 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'className' - | | | | | position: 18:12 - | | | | position: 18:5 + | | | | | position: 18:12+10 + | | | | position: 18:5+17 | | | args: array (0) - | | | position: 18:1 + | | | position: 18:1+21 | | key: null | | byRef: false | | unpack: false - | | position: 18:1 + | | position: 18:1+21 | 13 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode @@ -272,159 +271,159 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'weird' - | | | | | | | position: 19:5 + | | | | | | | position: 19:5+6 | | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | | value: 0 | | | | | | | kind: 10 - | | | | | | | position: 19:12 - | | | | | | position: 19:5 + | | | | | | | position: 19:12+1 + | | | | | | position: 19:5+9 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'foo' - | | | | | | position: 19:16 + | | | | | | position: 19:16+3 | | | | | nullsafe: false - | | | | | position: 19:5 + | | | | | position: 19:5+14 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'className' - | | | | | position: 19:21 - | | | | position: 19:5 + | | | | | position: 19:21+10 + | | | | position: 19:5+26 | | | args: array (0) - | | | position: 19:1 + | | | position: 19:1+30 | | key: null | | byRef: false | | unpack: false - | | position: 19:1 + | | position: 19:1+30 | 14 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 22:5 + | | | | | position: 22:5+1 | | | | args: array (0) - | | | | position: 22:1 + | | | | position: 22:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'foo' - | | | | position: 22:10 + | | | | position: 22:10+3 | | | nullsafe: false - | | | position: 22:1 + | | | position: 22:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 22:1 + | | position: 22:1+12 | 15 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 23:5 + | | | | | position: 23:5+1 | | | | args: array (0) - | | | | position: 23:1 + | | | | position: 23:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'foo' - | | | | position: 23:10 + | | | | position: 23:10+3 | | | args: array (0) | | | nullsafe: false - | | | position: 23:1 + | | | position: 23:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 23:1 + | | position: 23:1+14 | 16 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClassConstantFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 24:5 + | | | | | position: 24:5+1 | | | | args: array (0) - | | | | position: 24:1 + | | | | position: 24:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'FOO' - | | | | position: 24:10 - | | | position: 24:1 + | | | | position: 24:10+3 + | | | position: 24:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 24:1 + | | position: 24:1+12 | 17 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 25:5 + | | | | | position: 25:5+1 | | | | args: array (0) - | | | | position: 25:1 + | | | | position: 25:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'foo' - | | | | position: 25:10 + | | | | position: 25:10+3 | | | args: array (0) - | | | position: 25:1 + | | | position: 25:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 25:1 + | | position: 25:1+14 | 18 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 26:5 + | | | | | position: 26:5+1 | | | | args: array (0) - | | | | position: 26:1 + | | | | position: 26:1+7 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'foo' - | | | | position: 26:10 - | | | position: 26:1 + | | | | position: 26:10+4 + | | | position: 26:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 26:1 + | | position: 26:1+13 | 19 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 27:5 + | | | | | position: 27:5+1 | | | | args: array (0) - | | | | position: 27:1 + | | | | position: 27:1+7 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 27:9 - | | | position: 27:1 + | | | | position: 27:9+1 + | | | position: 27:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 27:1 + | | position: 27:1+10 | 20 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 28:5 + | | | | | position: 28:5+1 | | | | args: array (0) - | | | | position: 28:1 + | | | | position: 28:1+7 | | | args: array (0) - | | | position: 28:1 + | | | position: 28:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 28:1 + | | position: 28:1+9 | 21 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 31:6 + | | | | position: 31:6+1 | | | args: array (0) - | | | position: 31:2 + | | | position: 31:2+5 | | key: null | | byRef: false | | unpack: false - | | position: 31:1 - position: 1:1 + | | position: 31:1+7 + position: 1:1+534 diff --git a/tests/phpParser/newDeref.phpt b/tests/phpParser/newDeref.phpt index 6a94374c8..0f1cb3f69 100644 --- a/tests/phpParser/newDeref.phpt +++ b/tests/phpParser/newDeref.phpt @@ -1,27 +1,26 @@ -b, - (new A)->b(), - (new A)['b'], - (new A)['b']['c'], - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b, + (new A)->b(), + (new A)['b'], + (new A)['b']['c'], + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (4) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode @@ -29,54 +28,54 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 1:6 + | | | | | position: 1:6+1 | | | | args: array (0) - | | | | position: 1:2 + | | | | position: 1:2+5 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 1:10 + | | | | position: 1:10+1 | | | nullsafe: false - | | | position: 1:1 + | | | position: 1:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+10 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 2:6 + | | | | | position: 2:6+1 | | | | args: array (0) - | | | | position: 2:2 + | | | | position: 2:2+5 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 2:10 + | | | | position: 2:10+1 | | | args: array (0) | | | nullsafe: false - | | | position: 2:1 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\NewNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 3:6 + | | | | | position: 3:6+1 | | | | args: array (0) - | | | | position: 3:2 + | | | | position: 3:2+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 3:9 - | | | position: 3:1 + | | | | position: 3:9+3 + | | | position: 3:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+12 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -84,19 +83,19 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'A' | | | | | | kind: 1 - | | | | | | position: 4:6 + | | | | | | position: 4:6+1 | | | | | args: array (0) - | | | | | position: 4:2 + | | | | | position: 4:2+5 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'b' - | | | | | position: 4:9 - | | | | position: 4:1 + | | | | | position: 4:9+3 + | | | | position: 4:1+12 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 4:14 - | | | position: 4:1 + | | | | position: 4:14+3 + | | | position: 4:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+17 + position: 1:1+58 diff --git a/tests/phpParser/newInstanceofExpr.phpt b/tests/phpParser/newInstanceofExpr.phpt index c87f1fa60..c9b376e5a 100644 --- a/tests/phpParser/newInstanceofExpr.phpt +++ b/tests/phpParser/newInstanceofExpr.phpt @@ -1,86 +1,85 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'Foo' - | | | | | position: 1:6 + | | | | | position: 1:6+5 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'bar' - | | | | | position: 1:14 - | | | | position: 1:6 + | | | | | position: 1:14+4 + | | | | position: 1:6+12 | | | args: array (0) - | | | position: 1:1 + | | | position: 1:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+18 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'Foo' - | | | | | position: 2:6 + | | | | | position: 2:6+5 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'bar' - | | | | | position: 2:14 - | | | | position: 2:6 + | | | | | position: 2:14+4 + | | | | position: 2:6+12 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'arg' - | | | | | | position: 2:20 + | | | | | | position: 2:20+4 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:20 - | | | position: 2:1 + | | | | | position: 2:20+4 + | | | position: 2:1+24 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+24 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\InstanceofNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'obj' - | | | | position: 3:1 + | | | | position: 3:1+4 | | | class: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'Foo' - | | | | | position: 3:18 + | | | | | position: 3:18+5 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'bar' - | | | | | position: 3:26 - | | | | position: 3:18 - | | | position: 3:1 + | | | | | position: 3:26+4 + | | | | position: 3:18+12 + | | | position: 3:1+30 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 - position: 1:1 + | | position: 3:1+30 + position: 1:1+77 diff --git a/tests/phpParser/nullsafe.phpt b/tests/phpParser/nullsafe.phpt index e1a2f3447..6d9b6e488 100644 --- a/tests/phpParser/nullsafe.phpt +++ b/tests/phpParser/nullsafe.phpt @@ -1,115 +1,114 @@ -b, - $a?->b($c), - new $a?->b, - "{$a?->b}", - "$a?->b", - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b, + $a?->b($c), + new $a?->b, + "{$a?->b}", + "$a?->b", + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (5) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:1 + | | | | position: 1:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 1:6 + | | | | position: 1:6+1 | | | nullsafe: true - | | | position: 1:1 + | | | position: 1:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+6 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 2:6 + | | | | position: 2:6+1 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 2:8 + | | | | | | position: 2:8+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:8 + | | | | | position: 2:8+2 | | | nullsafe: true - | | | position: 2:1 + | | | position: 2:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+10 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 3:5 + | | | | | position: 3:5+2 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 3:10 + | | | | | position: 3:10+1 | | | | nullsafe: true - | | | | position: 3:5 + | | | | position: 3:5+6 | | | args: array (0) - | | | position: 3:1 + | | | position: 3:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+10 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:3 + | | | | | | position: 4:3+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 4:8 + | | | | | | position: 4:8+1 | | | | | nullsafe: true - | | | | | position: 4:3 - | | | position: 4:1 + | | | | | position: 4:3+6 + | | | position: 4:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+10 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 5:2 + | | | | | | position: 5:2+2 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 5:7 + | | | | | | position: 5:7+1 | | | | | nullsafe: true - | | | | | position: 5:2 - | | | position: 5:1 + | | | | | position: 5:2+6 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+8 + position: 1:1+53 diff --git a/tests/phpParser/numberSeparators.phpt b/tests/phpParser/numberSeparators.phpt index 9b75a6e51..631edf34c 100644 --- a/tests/phpParser/numberSeparators.phpt +++ b/tests/phpParser/numberSeparators.phpt @@ -1,71 +1,70 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\FloatNode | | | value: 6.674083e-11 - | | | position: 1:1 + | | | position: 1:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+13 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 299792458 | | | kind: 10 - | | | position: 2:1 + | | | position: 2:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+11 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 3405705229 | | | kind: 16 - | | | position: 3:1 + | | | position: 3:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+11 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 95 | | | kind: 2 - | | | position: 4:1 + | | | position: 4:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+11 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | value: 48673 | | | kind: 8 - | | | position: 5:1 + | | | position: 5:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+8 + position: 1:1+63 diff --git a/tests/phpParser/objectAccess.phpt b/tests/phpParser/objectAccess.phpt index 226a94a6b..af869204b 100644 --- a/tests/phpParser/objectAccess.phpt +++ b/tests/phpParser/objectAccess.phpt @@ -1,154 +1,153 @@ -b, - $a->b['c'], - - /* method call variations */ - $a->b(), - $a->{'b'}(), - $a->$b(), - $a->$b['c'](), - - /* array dereferencing */ - $a->b()['c'], - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b, + $a->b['c'], + + /* method call variations */ + $a->b(), + $a->{'b'}(), + $a->$b(), + $a->$b['c'](), + + /* array dereferencing */ + $a->b()['c'], + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (7) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 2:5 + | | | | position: 2:5+1 | | | nullsafe: false - | | | position: 2:1 + | | | position: 2:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+5 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 3:1 + | | | | | position: 3:1+2 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 3:5 + | | | | | position: 3:5+1 | | | | nullsafe: false - | | | | position: 3:1 + | | | | position: 3:1+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 3:7 - | | | position: 3:1 + | | | | position: 3:7+3 + | | | position: 3:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+10 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 6:1 + | | | | position: 6:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 6:5 + | | | | position: 6:5+1 | | | args: array (0) | | | nullsafe: false - | | | position: 6:1 + | | | position: 6:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:1 + | | | | position: 7:1+2 | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 7:6 + | | | | position: 7:6+3 | | | args: array (0) | | | nullsafe: false - | | | position: 7:1 + | | | position: 7:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+11 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 8:1 + | | | | position: 8:1+2 | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 8:5 + | | | | position: 8:5+2 | | | args: array (0) | | | nullsafe: false - | | | position: 8:1 + | | | position: 8:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 8:1 + | | position: 8:1+8 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 9:1 + | | | | | | position: 9:1+2 | | | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 9:5 + | | | | | | position: 9:5+2 | | | | | nullsafe: false - | | | | | position: 9:1 + | | | | | position: 9:1+6 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'c' - | | | | | position: 9:8 - | | | | position: 9:1 + | | | | | position: 9:8+3 + | | | | position: 9:1+11 | | | args: array (0) - | | | position: 9:1 + | | | position: 9:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+13 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 12:1 + | | | | | position: 12:1+2 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 12:5 + | | | | | position: 12:5+1 | | | | args: array (0) | | | | nullsafe: false - | | | | position: 12:1 + | | | | position: 12:1+7 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 12:9 - | | | position: 12:1 + | | | | position: 12:9+3 + | | | position: 12:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 - position: 2:1 + | | position: 12:1+12 + position: 2:1+136 diff --git a/tests/phpParser/pipe.phpt b/tests/phpParser/pipe.phpt index 984d97057..eb5e43f4a 100644 --- a/tests/phpParser/pipe.phpt +++ b/tests/phpParser/pipe.phpt @@ -1,112 +1,111 @@ - $b |> $c, - $a . $b |> $c . $d, - $a |> $b == $c, - $c == $a |> $b, - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode + $b |> $c, + $a . $b |> $c . $d, + $a |> $b == $c, + $c == $a |> $b, + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (4) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 1:1 + | | | | | position: 1:1+2 | | | | operator: '|>' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 1:7 - | | | | position: 1:1 + | | | | | position: 1:7+2 + | | | | position: 1:1+8 | | | operator: '|>' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 1:13 - | | | position: 1:1 + | | | | position: 1:13+2 + | | | position: 1:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+14 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 2:1 + | | | | | position: 2:1+2 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 2:6 - | | | | position: 2:1 + | | | | | position: 2:6+2 + | | | | position: 2:1+7 | | | operator: '|>' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 2:12 + | | | | | position: 2:12+2 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'd' - | | | | | position: 2:17 - | | | | position: 2:12 - | | | position: 2:1 + | | | | | position: 2:17+2 + | | | | position: 2:12+7 + | | | position: 2:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+18 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 3:1 + | | | | | position: 3:1+2 | | | | operator: '|>' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 3:7 - | | | | position: 3:1 + | | | | | position: 3:7+2 + | | | | position: 3:1+8 | | | operator: '==' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 3:13 - | | | position: 3:1 + | | | | position: 3:13+2 + | | | position: 3:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+14 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 4:1 + | | | | position: 4:1+2 | | | operator: '==' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 4:7 + | | | | | position: 4:7+2 | | | | operator: '|>' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 4:13 - | | | | position: 4:7 - | | | position: 4:1 + | | | | | position: 4:13+2 + | | | | position: 4:7+8 + | | | position: 4:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+14 + position: 1:1+67 diff --git a/tests/phpParser/simpleArrayAccess.phpt b/tests/phpParser/simpleArrayAccess.phpt index 653b979f7..9613c9859 100644 --- a/tests/phpParser/simpleArrayAccess.phpt +++ b/tests/phpParser/simpleArrayAccess.phpt @@ -1,89 +1,88 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 1:1 + | | | | position: 1:1+2 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 1:4 - | | | position: 1:1 + | | | | position: 1:4+3 + | | | position: 1:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 2:1 + | | | | | position: 2:1+2 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'b' - | | | | | position: 2:4 - | | | | position: 2:1 + | | | | | position: 2:4+3 + | | | | position: 2:1+7 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 2:9 - | | | position: 2:1 + | | | | position: 2:9+3 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\AssignNode | | | var: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 3:1 + | | | | | position: 3:1+2 | | | | index: null - | | | | position: 3:1 + | | | | position: 3:1+4 | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 3:8 + | | | | position: 3:8+2 | | | byRef: false - | | | position: 3:1 + | | | position: 3:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+9 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 4:3 - | | | | position: 4:1 + | | | | | position: 4:3+2 + | | | | position: 4:1+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 4:7 - | | | position: 4:1 + | | | | position: 4:7+3 + | | | position: 4:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+10 + position: 1:1+45 diff --git a/tests/phpParser/staticCall.phpt b/tests/phpParser/staticCall.phpt index 33a422b7b..0b796cc24 100644 --- a/tests/phpParser/staticCall.phpt +++ b/tests/phpParser/staticCall.phpt @@ -1,84 +1,83 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+1 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 2:4 + | | | | position: 2:4+1 | | | args: array (0) - | | | position: 2:1 + | | | position: 2:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+6 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+1 | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 3:5 + | | | | position: 3:5+3 | | | args: array (0) - | | | position: 3:1 + | | | position: 3:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+10 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 4:1 + | | | | position: 4:1+1 | | | name: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 4:4 + | | | | position: 4:4+2 | | | args: array (0) - | | | position: 4:1 + | | | position: 4:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -86,21 +85,21 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'A' | | | | | | kind: 1 - | | | | | | position: 5:1 + | | | | | | position: 5:1+1 | | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | | name: 'b' - | | | | | | position: 5:4 - | | | | | position: 5:1 + | | | | | | position: 5:4+2 + | | | | | position: 5:1+5 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'c' - | | | | | position: 5:7 - | | | | position: 5:1 + | | | | | position: 5:7+3 + | | | | position: 5:1+10 | | | args: array (0) - | | | position: 5:1 + | | | position: 5:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+12 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode @@ -109,107 +108,107 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'A' | | | | | | | kind: 1 - | | | | | | | position: 6:1 + | | | | | | | position: 6:1+1 | | | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | | | name: 'b' - | | | | | | | position: 6:4 - | | | | | | position: 6:1 + | | | | | | | position: 6:4+2 + | | | | | | position: 6:1+5 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'c' - | | | | | | position: 6:7 - | | | | | position: 6:1 + | | | | | | position: 6:7+3 + | | | | | position: 6:1+10 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'd' - | | | | | position: 6:12 - | | | | position: 6:1 + | | | | | position: 6:12+3 + | | | | position: 6:1+15 | | | args: array (0) - | | | position: 6:1 + | | | position: 6:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+17 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 9:1 + | | | | | position: 9:1+1 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 9:4 + | | | | | position: 9:4+1 | | | | args: array (0) - | | | | position: 9:1 + | | | | position: 9:1+6 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 9:8 - | | | position: 9:1 + | | | | position: 9:8+3 + | | | position: 9:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 9:1 + | | position: 9:1+11 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'static' | | | | kind: 1 - | | | | position: 12:1 + | | | | position: 12:1+6 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 12:9 + | | | | position: 12:9+1 | | | args: array (0) - | | | position: 12:1 + | | | position: 12:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+11 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 13:1 + | | | | position: 13:1+2 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 13:5 + | | | | position: 13:5+1 | | | args: array (0) - | | | position: 13:1 + | | | position: 13:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+7 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'a' - | | | | | position: 14:3 - | | | | position: 14:1 + | | | | | position: 14:3+3 + | | | | position: 14:1+6 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 14:9 + | | | | position: 14:9+1 | | | args: array (0) - | | | position: 14:1 + | | | position: 14:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 14:1 + | | position: 14:1+11 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 15:1 + | | | | | position: 15:1+2 | | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'b' - | | | | | position: 15:4 - | | | | position: 15:1 + | | | | | position: 15:4+3 + | | | | position: 15:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'c' - | | | | position: 15:10 + | | | | position: 15:10+1 | | | args: array (0) - | | | position: 15:1 + | | | position: 15:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 15:1 - position: 2:1 + | | position: 15:1+12 + position: 2:1+179 diff --git a/tests/phpParser/staticProperty.phpt b/tests/phpParser/staticProperty.phpt index 3cbdc3230..c66c79b1f 100644 --- a/tests/phpParser/staticProperty.phpt +++ b/tests/phpParser/staticProperty.phpt @@ -1,125 +1,124 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 1:1 + | | | | position: 1:1+1 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 1:4 - | | | position: 1:1 + | | | | position: 1:4+2 + | | | position: 1:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+5 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'A' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 2:5 - | | | position: 2:1 + | | | | position: 2:5+2 + | | | position: 2:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+6 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'A' - | | | | position: 3:1 + | | | | position: 3:1+3 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 3:6 - | | | position: 3:1 + | | | | position: 3:6+2 + | | | position: 3:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+7 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'A' - | | | | | position: 4:2 + | | | | | position: 4:2+3 | | | | operator: '.' | | | | right: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: '' - | | | | | position: 4:8 - | | | | position: 4:2 + | | | | | position: 4:8+2 + | | | | position: 4:2+8 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 4:13 - | | | position: 4:1 + | | | | position: 4:13+2 + | | | position: 4:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+14 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | value: 'A' - | | | | | position: 5:1 + | | | | | position: 5:1+3 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 5:5 - | | | | position: 5:1 + | | | | | position: 5:5+1 + | | | | position: 5:1+6 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 5:9 - | | | position: 5:1 + | | | | position: 5:9+2 + | | | position: 5:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+10 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 6:1 + | | | | | position: 6:1+1 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'A' - | | | | | position: 6:4 - | | | | position: 6:1 + | | | | | position: 6:4+2 + | | | | position: 6:1+5 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 6:8 - | | | position: 6:1 + | | | | position: 6:8+2 + | | | position: 6:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+9 + position: 1:1+62 diff --git a/tests/phpParser/staticPropertyFetch.phpt b/tests/phpParser/staticPropertyFetch.phpt index 13f356651..10ce10e34 100644 --- a/tests/phpParser/staticPropertyFetch.phpt +++ b/tests/phpParser/staticPropertyFetch.phpt @@ -1,75 +1,74 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 2:1 + | | | | position: 2:1+1 | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | name: 'b' - | | | | position: 2:4 - | | | position: 2:1 + | | | | position: 2:4+2 + | | | position: 2:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+5 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'A' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+1 | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'b' - | | | | position: 3:6 - | | | position: 3:1 + | | | | position: 3:6+3 + | | | position: 3:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+9 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\StaticPropertyFetchNode | | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'A' | | | | | kind: 1 - | | | | | position: 6:1 + | | | | | position: 6:1+1 | | | | name: Latte\Compiler\Nodes\Php\VarLikeIdentifierNode | | | | | name: 'b' - | | | | | position: 6:4 - | | | | position: 6:1 + | | | | | position: 6:4+2 + | | | | position: 6:1+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'c' - | | | | position: 6:7 - | | | position: 6:1 + | | | | position: 6:7+3 + | | | position: 6:1+10 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 2:1 + | | position: 6:1+10 + position: 2:1+49 diff --git a/tests/phpParser/string.phpt b/tests/phpParser/string.phpt index be893e783..49de57ff9 100644 --- a/tests/phpParser/string.phpt +++ b/tests/phpParser/string.phpt @@ -1,87 +1,86 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '' - | | | position: 1:1 + | | | position: 1:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+2 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '' - | | | position: 2:1 + | | | position: 2:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+2 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'Hi' - | | | position: 3:1 + | | | position: 3:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+4 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'Hi' - | | | position: 4:1 + | | | position: 4:1+4 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+4 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '!'!\!\a!' - | | | position: 5:1 + | | | position: 5:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+12 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: string | | | | '!"!\!$!\n | | | | !\r!\t !\x0C!\x0B!\e!\a' - | | | position: 6:1 + | | | position: 6:1+32 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+32 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '!\xFF!\xFF!\x00!' - | | | position: 7:1 + | | | position: 7:1+16 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 - position: 1:1 + | | position: 7:1+16 + position: 1:1+85 diff --git a/tests/phpParser/stringDeref.phpt b/tests/phpParser/stringDeref.phpt index aad7941cd..2120a4cab 100644 --- a/tests/phpParser/stringDeref.phpt +++ b/tests/phpParser/stringDeref.phpt @@ -1,64 +1,63 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'abc' - | | | | position: 1:1 + | | | | position: 1:1+5 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 2 | | | | kind: 10 - | | | | position: 1:7 - | | | position: 1:1 + | | | | position: 1:7+1 + | | | position: 1:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+8 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | expr: Latte\Compiler\Nodes\Php\Expression\ArrayAccessNode | | | | | expr: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | | | value: 'abc' - | | | | | | position: 2:1 + | | | | | | position: 2:1+5 | | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | | value: 2 | | | | | | kind: 10 - | | | | | | position: 2:7 - | | | | | position: 2:1 + | | | | | | position: 2:7+1 + | | | | | position: 2:1+8 | | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | | value: 0 | | | | | kind: 10 - | | | | | position: 2:10 - | | | | position: 2:1 + | | | | | position: 2:10+1 + | | | | position: 2:1+11 | | | index: Latte\Compiler\Nodes\Php\Scalar\IntegerNode | | | | value: 0 | | | | kind: 10 - | | | | position: 2:13 - | | | position: 2:1 + | | | | position: 2:13+1 + | | | position: 2:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 - position: 1:1 + | | position: 2:1+14 + position: 1:1+25 diff --git a/tests/phpParser/ternaryAndCoalesce.phpt b/tests/phpParser/ternaryAndCoalesce.phpt index a3149a979..5e02994b0 100644 --- a/tests/phpParser/ternaryAndCoalesce.phpt +++ b/tests/phpParser/ternaryAndCoalesce.phpt @@ -1,227 +1,226 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 2:1 + | | | | position: 2:1+2 | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 2:6 + | | | | position: 2:6+2 | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 2:11 - | | | position: 2:1 + | | | | position: 2:11+2 + | | | position: 2:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+12 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 3:1 + | | | | position: 3:1+2 | | | if: null | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 3:7 - | | | position: 3:1 + | | | | position: 3:7+2 + | | | position: 3:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+8 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 6:1 + | | | | | position: 6:1+2 | | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 6:6 + | | | | | position: 6:6+2 | | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 6:11 - | | | | position: 6:1 + | | | | | position: 6:11+2 + | | | | position: 6:1+12 | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'd' - | | | | position: 6:16 + | | | | position: 6:16+2 | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'e' - | | | | position: 6:21 - | | | position: 6:1 + | | | | position: 6:21+2 + | | | position: 6:1+22 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 + | | position: 6:1+22 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 7:1 + | | | | position: 7:1+2 | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 7:6 + | | | | position: 7:6+2 | | | else: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 7:12 + | | | | | position: 7:12+2 | | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'd' - | | | | | position: 7:17 + | | | | | position: 7:17+2 | | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'e' - | | | | | position: 7:22 - | | | | position: 7:12 - | | | position: 7:1 + | | | | | position: 7:22+2 + | | | | position: 7:12+12 + | | | position: 7:1+24 | | key: null | | byRef: false | | unpack: false - | | position: 7:1 + | | position: 7:1+24 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 10:1 + | | | | position: 10:1+2 | | | operator: '??' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 10:7 - | | | position: 10:1 + | | | | position: 10:7+2 + | | | position: 10:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 10:1 + | | position: 10:1+8 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 11:1 + | | | | position: 11:1+2 | | | operator: '??' | | | right: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 11:7 + | | | | | position: 11:7+2 | | | | operator: '??' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 11:13 - | | | | position: 11:7 - | | | position: 11:1 + | | | | | position: 11:13+2 + | | | | position: 11:7+8 + | | | position: 11:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 11:1 + | | position: 11:1+14 | 6 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 12:1 + | | | | | position: 12:1+2 | | | | operator: '??' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 12:7 - | | | | position: 12:1 + | | | | | position: 12:7+2 + | | | | position: 12:1+8 | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 12:12 + | | | | position: 12:12+2 | | | else: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'd' - | | | | position: 12:17 - | | | position: 12:1 + | | | | position: 12:17+2 + | | | position: 12:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 12:1 + | | position: 12:1+18 | 7 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | left: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 13:1 + | | | | | position: 13:1+2 | | | | operator: '&&' | | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 13:7 - | | | | position: 13:1 + | | | | | position: 13:7+2 + | | | | position: 13:1+8 | | | operator: '??' | | | right: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'c' - | | | | position: 13:13 - | | | position: 13:1 + | | | | position: 13:13+2 + | | | position: 13:1+14 | | key: null | | byRef: false | | unpack: false - | | position: 13:1 + | | position: 13:1+14 | 8 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 16:1 + | | | | position: 16:1+2 | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'b' - | | | | position: 16:6 + | | | | position: 16:6+2 | | | else: null - | | | position: 16:1 + | | | position: 16:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 16:1 + | | position: 16:1+7 | 9 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'a' - | | | | position: 17:1 + | | | | position: 17:1+2 | | | if: Latte\Compiler\Nodes\Php\Expression\TernaryNode | | | | cond: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 17:6 + | | | | | position: 17:6+2 | | | | if: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'c' - | | | | | position: 17:11 + | | | | | position: 17:11+2 | | | | else: null - | | | | position: 17:6 + | | | | position: 17:6+7 | | | else: null - | | | position: 17:1 + | | | position: 17:1+12 | | key: null | | byRef: false | | unpack: false - | | position: 17:1 - position: 2:1 + | | position: 17:1+12 + position: 2:1+218 diff --git a/tests/phpParser/trailingCommas.phpt b/tests/phpParser/trailingCommas.phpt index 4d64b29fa..21d017034 100644 --- a/tests/phpParser/trailingCommas.phpt +++ b/tests/phpParser/trailingCommas.phpt @@ -1,188 +1,187 @@ -bar($a, $b, ), - Foo::bar($a, $b, ), - new Foo($a, $b, ), - abcde($a, $b, ), - isset($a, $b, ), - XX; - -$node = parseCode($test); - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +bar($a, $b, ), + Foo::bar($a, $b, ), + new Foo($a, $b, ), + abcde($a, $b, ), + isset($a, $b, ), + XX; + +$node = parseCode($test); + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (6) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'foo' | | | | kind: 1 - | | | | position: 1:1 + | | | | position: 1:1+3 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 1:5 + | | | | | | position: 1:5+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 1:5 + | | | | | position: 1:5+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 1:9 + | | | | | | position: 1:9+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 1:9 - | | | position: 1:1 + | | | | | position: 1:9+2 + | | | position: 1:1+13 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+13 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | name: 'foo' - | | | | position: 2:1 + | | | | position: 2:1+4 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'bar' - | | | | position: 2:7 + | | | | position: 2:7+3 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:11 + | | | | | | position: 2:11+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:11 + | | | | | position: 2:11+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:15 + | | | | | | position: 2:15+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:15 + | | | | | position: 2:15+2 | | | nullsafe: false - | | | position: 2:1 + | | | position: 2:1+19 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+19 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'Foo' | | | | kind: 1 - | | | | position: 3:1 + | | | | position: 3:1+3 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'bar' - | | | | position: 3:6 + | | | | position: 3:6+3 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:10 + | | | | | | position: 3:10+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:10 + | | | | | position: 3:10+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:14 + | | | | | | position: 3:14+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 3:14 - | | | position: 3:1 + | | | | | position: 3:14+2 + | | | position: 3:1+18 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+18 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'Foo' | | | | kind: 1 - | | | | position: 4:5 + | | | | position: 4:5+3 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:9 + | | | | | | position: 4:9+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 4:9 + | | | | | position: 4:9+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 4:13 + | | | | | | position: 4:13+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 4:13 - | | | position: 4:1 + | | | | | position: 4:13+2 + | | | position: 4:1+17 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+17 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'abcde' | | | | kind: 1 - | | | | position: 5:1 + | | | | position: 5:1+5 | | | args: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 5:7 + | | | | | | position: 5:7+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:7 + | | | | | position: 5:7+2 | | | | 1 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 5:11 + | | | | | | position: 5:11+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 5:11 - | | | position: 5:1 + | | | | | position: 5:11+2 + | | | position: 5:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+15 | 5 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\IssetNode | | | vars: array (2) | | | | 0 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 6:7 + | | | | | position: 6:7+2 | | | | 1 => Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'b' - | | | | | position: 6:11 - | | | position: 6:1 + | | | | | position: 6:11+2 + | | | position: 6:1+15 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+15 + position: 1:1+108 diff --git a/tests/phpParser/typeDeclarations.phpt b/tests/phpParser/typeDeclarations.phpt index 8d80f1912..5745fdaaf 100644 --- a/tests/phpParser/typeDeclarations.phpt +++ b/tests/phpParser/typeDeclarations.phpt @@ -1,33 +1,32 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -36,145 +35,145 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:2 + | | | | | | position: 2:2+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 2:2 + | | | | | position: 2:2+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:8 + | | | | | | position: 3:8+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'array' - | | | | | | position: 3:2 + | | | | | | position: 3:2+5 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 3:2 + | | | | | position: 3:2+8 | | | | 2 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 4:11 + | | | | | | position: 4:11+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'callable' | | | | | | kind: 1 - | | | | | | position: 4:2 + | | | | | | position: 4:2+8 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 4:2 + | | | | | position: 4:2+11 | | | | 3 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'd' - | | | | | | position: 5:4 + | | | | | | position: 5:4+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'E' | | | | | | kind: 1 - | | | | | | position: 5:2 + | | | | | | position: 5:2+1 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 5:2 + | | | | | position: 5:2+4 | | | | 4 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'e' - | | | | | | position: 6:10 + | | | | | | position: 6:10+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\NullableTypeNode | | | | | | type: Latte\Compiler\Nodes\Php\NameNode | | | | | | | name: 'Foo' | | | | | | | kind: 1 - | | | | | | | position: 6:6 - | | | | | | position: 6:5 + | | | | | | | position: 6:6+3 + | | | | | | position: 6:5+4 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 6:5 + | | | | | position: 6:5+7 | | | | 5 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'f' - | | | | | | position: 7:26 + | | | | | | position: 7:26+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\UnionTypeNode | | | | | | types: array (4) | | | | | | | 0 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'A' | | | | | | | | kind: 1 - | | | | | | | | position: 7:5 + | | | | | | | | position: 7:5+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | name: 'iterable' - | | | | | | | | position: 7:7 + | | | | | | | | position: 7:7+8 | | | | | | | 2 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'foo' | | | | | | | | kind: 1 - | | | | | | | | position: 7:17 + | | | | | | | | position: 7:17+3 | | | | | | | 3 => Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | | | name: 'null' - | | | | | | | | position: 7:21 - | | | | | | position: 7:5 + | | | | | | | | position: 7:21+4 + | | | | | | position: 7:5+20 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 7:5 + | | | | | position: 7:5+23 | | | | 6 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'f' - | | | | | | position: 8:21 + | | | | | | position: 8:21+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\UnionTypeNode | | | | | | types: array (5) | | | | | | | 0 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'A' | | | | | | | | kind: 1 - | | | | | | | | position: 8:5 + | | | | | | | | position: 8:5+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'B' | | | | | | | | kind: 1 - | | | | | | | | position: 8:7 + | | | | | | | | position: 8:7+1 | | | | | | | 2 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'C' | | | | | | | | kind: 2 - | | | | | | | | position: 8:9 + | | | | | | | | position: 8:9+2 | | | | | | | 3 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'D' | | | | | | | | kind: 1 - | | | | | | | | position: 8:14 + | | | | | | | | position: 8:14+1 | | | | | | | 4 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'E' | | | | | | | | kind: 2 - | | | | | | | | position: 8:18 - | | | | | | position: 8:5 + | | | | | | | | position: 8:18+2 + | | | | | | position: 8:5+15 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 8:5 + | | | | | position: 8:5+18 | | | | 7 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'g' - | | | | | | position: 9:9 + | | | | | | position: 9:9+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\IntersectionTypeNode | | | | | | types: array (2) | | | | | | | 0 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'A' | | | | | | | | kind: 1 - | | | | | | | | position: 9:5 + | | | | | | | | position: 9:5+1 | | | | | | | 1 => Latte\Compiler\Nodes\Php\NameNode | | | | | | | | name: 'B' | | | | | | | | kind: 1 - | | | | | | | | position: 9:7 - | | | | | | position: 9:5 + | | | | | | | | position: 9:7+1 + | | | | | | position: 9:5+3 | | | | | byRef: false | | | | | variadic: false - | | | | | position: 9:5 + | | | | | position: 9:5+6 | | | uses: array (0) | | | returnType: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'never' - | | | | position: 10:4 + | | | | position: 10:4+5 | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 10:19 - | | | position: 1:1 + | | | | position: 10:19+4 + | | | position: 1:1+151 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 - position: 1:1 + | | position: 1:1+151 + position: 1:1+151 diff --git a/tests/phpParser/undefinedsafe.phpt b/tests/phpParser/undefinedsafe.phpt index 4f0135330..be4e1939e 100644 --- a/tests/phpParser/undefinedsafe.phpt +++ b/tests/phpParser/undefinedsafe.phpt @@ -1,98 +1,97 @@ -b, - $a??->b($c), - new $a??->b, - "{$a??->b}", - "$a??->b", - XX; - -$node = @parseCode($test); // deprecated - -Assert::same( - loadContent(__FILE__, __COMPILER_HALT_OFFSET__), - exportNode($node), -); - -__halt_compiler(); -Latte\Compiler\Nodes\Php\Expression\ArrayNode +b, + $a??->b($c), + new $a??->b, + "{$a??->b}", + "$a??->b", + XX; + +$node = @parseCode($test); // deprecated + +Assert::same( + loadContent(__FILE__, __COMPILER_HALT_OFFSET__), + exportNode($node), +); + +__halt_compiler(); Latte\Compiler\Nodes\Php\Expression\ArrayNode items: array (5) | 0 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | object: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 1:1 + | | | | | position: 1:1+2 | | | | operator: '??' | | | | right: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | position: 1:1 - | | | | position: 1:1 + | | | | | position: 1:1+7 + | | | | position: 1:1+7 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 1:7 + | | | | position: 1:7+1 | | | nullsafe: true - | | | position: 1:1 + | | | position: 1:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\MethodCallNode | | | object: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | name: 'a' - | | | | | position: 2:1 + | | | | | position: 2:1+2 | | | | operator: '??' | | | | right: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | position: 2:1 - | | | | position: 2:1 + | | | | | position: 2:1+11 + | | | | position: 2:1+11 | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | name: 'b' - | | | | position: 2:7 + | | | | position: 2:7+1 | | | args: array (1) | | | | 0 => Latte\Compiler\Nodes\Php\ArgumentNode | | | | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'c' - | | | | | | position: 2:9 + | | | | | | position: 2:9+2 | | | | | byRef: false | | | | | unpack: false | | | | | name: null - | | | | | position: 2:9 + | | | | | position: 2:9+2 | | | nullsafe: true - | | | position: 2:1 + | | | position: 2:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+11 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\NewNode | | | class: Latte\Compiler\Nodes\Php\Expression\PropertyFetchNode | | | | object: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:5 + | | | | | | position: 3:5+2 | | | | | operator: '??' | | | | | right: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | | position: 3:5 - | | | | | position: 3:5 + | | | | | | position: 3:5+7 + | | | | | position: 3:5+7 | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | name: 'b' - | | | | | position: 3:11 + | | | | | position: 3:11+1 | | | | nullsafe: true - | | | | position: 3:5 + | | | | position: 3:5+7 | | | args: array (0) - | | | position: 3:1 + | | | position: 3:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+11 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) @@ -100,21 +99,21 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 4:3 + | | | | | | | position: 4:3+2 | | | | | | operator: '??' | | | | | | right: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | | | position: 4:3 - | | | | | | position: 4:3 + | | | | | | | position: 4:3+7 + | | | | | | position: 4:3+7 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 4:9 + | | | | | | position: 4:9+1 | | | | | nullsafe: true - | | | | | position: 4:3 - | | | position: 4:1 + | | | | | position: 4:3+7 + | | | position: 4:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 + | | position: 4:1+11 | 4 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\InterpolatedStringNode | | | parts: array (1) @@ -122,19 +121,19 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | | object: Latte\Compiler\Nodes\Php\Expression\BinaryOpNode | | | | | | left: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | | name: 'a' - | | | | | | | position: 5:2 + | | | | | | | position: 5:2+2 | | | | | | operator: '??' | | | | | | right: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | | | | position: 5:2 - | | | | | | position: 5:2 + | | | | | | | position: 5:2+7 + | | | | | | position: 5:2+7 | | | | | name: Latte\Compiler\Nodes\Php\IdentifierNode | | | | | | name: 'b' - | | | | | | position: 5:8 + | | | | | | position: 5:8+1 | | | | | nullsafe: true - | | | | | position: 5:2 - | | | position: 5:1 + | | | | | position: 5:2+7 + | | | position: 5:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 - position: 1:1 + | | position: 5:1+9 + position: 1:1+58 diff --git a/tests/phpParser/unicodeEscape.phpt b/tests/phpParser/unicodeEscape.phpt index 8d701de85..aba17f09d 100644 --- a/tests/phpParser/unicodeEscape.phpt +++ b/tests/phpParser/unicodeEscape.phpt @@ -1,49 +1,48 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '\x00' - | | | position: 1:1 + | | | position: 1:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+7 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'Ĕ' - | | | position: 2:1 + | | | position: 2:1+9 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+9 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: '😂' - | | | position: 3:1 + | | | position: 3:1+11 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 - position: 1:1 + | | position: 3:1+11 + position: 1:1+32 diff --git a/tests/phpParser/unquotedStrings.phpt b/tests/phpParser/unquotedStrings.phpt index a80652fe9..57cf05ee1 100644 --- a/tests/phpParser/unquotedStrings.phpt +++ b/tests/phpParser/unquotedStrings.phpt @@ -1,63 +1,62 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'a' - | | | position: 1:1 + | | | position: 1:1+1 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+1 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ConstantFetchNode | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | name: 'MD5' | | | | kind: 1 - | | | | position: 2:1 - | | | position: 2:1 + | | | | position: 2:1+3 + | | | position: 2:1+3 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+3 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'a-b-c' - | | | position: 5:1 + | | | position: 5:1+5 | | key: null | | byRef: false | | unpack: false - | | position: 5:1 + | | position: 5:1+5 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | value: 'a--b--c' - | | | position: 6:1 + | | | position: 6:1+7 | | key: null | | byRef: false | | unpack: false - | | position: 6:1 - position: 1:1 + | | position: 6:1+7 + position: 1:1+37 diff --git a/tests/phpParser/variable.phpt b/tests/phpParser/variable.phpt index 0d38eb101..72a6ef8be 100644 --- a/tests/phpParser/variable.phpt +++ b/tests/phpParser/variable.phpt @@ -1,57 +1,56 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | name: 'a' - | | | position: 1:1 + | | | position: 1:1+2 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+2 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | name: Latte\Compiler\Nodes\Php\Scalar\StringNode | | | | value: 'a' - | | | | position: 2:3 - | | | position: 2:1 + | | | | position: 2:3+3 + | | | position: 2:1+6 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+6 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | name: Latte\Compiler\Nodes\Php\Expression\FunctionCallNode | | | | name: Latte\Compiler\Nodes\Php\NameNode | | | | | name: 'foo' | | | | | kind: 1 - | | | | | position: 3:3 + | | | | | position: 3:3+3 | | | | args: array (0) - | | | | position: 3:3 - | | | position: 3:1 + | | | | position: 3:3+5 + | | | position: 3:1+8 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 - position: 1:1 + | | position: 3:1+8 + position: 1:1+21 diff --git a/tests/phpParser/variadic.phpt b/tests/phpParser/variadic.phpt index 52e3c84b8..6c95bebdf 100644 --- a/tests/phpParser/variadic.phpt +++ b/tests/phpParser/variadic.phpt @@ -1,27 +1,26 @@ - Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode @@ -30,30 +29,30 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 1:11 + | | | | | | position: 1:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 1:11 + | | | | | position: 1:11+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 1:18 + | | | | | | position: 1:18+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: true - | | | | | position: 1:15 + | | | | | position: 1:15+5 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 1:31 - | | | position: 1:1 + | | | | position: 1:31+4 + | | | position: 1:1+37 | | key: null | | byRef: false | | unpack: false - | | position: 1:1 + | | position: 1:1+37 | 1 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -61,30 +60,30 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 2:11 + | | | | | | position: 2:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 2:11 + | | | | | position: 2:11+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 2:19 + | | | | | | position: 2:19+2 | | | | | default: null | | | | | type: null | | | | | byRef: true | | | | | variadic: true - | | | | | position: 2:15 + | | | | | position: 2:15+6 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 2:32 - | | | position: 2:1 + | | | | position: 2:32+4 + | | | position: 2:1+38 | | key: null | | byRef: false | | unpack: false - | | position: 2:1 + | | position: 2:1+38 | 2 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -92,33 +91,33 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 3:11 + | | | | | | position: 3:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 3:11 + | | | | | position: 3:11+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 3:23 + | | | | | | position: 3:23+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'Type' | | | | | | kind: 1 - | | | | | | position: 3:15 + | | | | | | position: 3:15+4 | | | | | byRef: false | | | | | variadic: true - | | | | | position: 3:15 + | | | | | position: 3:15+10 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 3:36 - | | | position: 3:1 + | | | | position: 3:36+4 + | | | position: 3:1+42 | | key: null | | byRef: false | | unpack: false - | | position: 3:1 + | | position: 3:1+42 | 3 => Latte\Compiler\Nodes\Php\ArrayItemNode | | value: Latte\Compiler\Nodes\Php\Expression\ClosureNode | | | byRef: false @@ -126,31 +125,31 @@ Latte\Compiler\Nodes\Php\Expression\ArrayNode | | | | 0 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'a' - | | | | | | position: 4:11 + | | | | | | position: 4:11+2 | | | | | default: null | | | | | type: null | | | | | byRef: false | | | | | variadic: false - | | | | | position: 4:11 + | | | | | position: 4:11+2 | | | | 1 => Latte\Compiler\Nodes\Php\ParameterNode | | | | | var: Latte\Compiler\Nodes\Php\Expression\VariableNode | | | | | | name: 'b' - | | | | | | position: 4:24 + | | | | | | position: 4:24+2 | | | | | default: null | | | | | type: Latte\Compiler\Nodes\Php\NameNode | | | | | | name: 'Type' | | | | | | kind: 1 - | | | | | | position: 4:15 + | | | | | | position: 4:15+4 | | | | | byRef: true | | | | | variadic: true - | | | | | position: 4:15 + | | | | | position: 4:15+11 | | | uses: array (0) | | | returnType: null | | | expr: Latte\Compiler\Nodes\Php\Scalar\NullNode - | | | | position: 4:37 - | | | position: 4:1 + | | | | position: 4:37+4 + | | | position: 4:1+43 | | key: null | | byRef: false | | unpack: false - | | position: 4:1 - position: 1:1 + | | position: 4:1+43 + position: 1:1+167 diff --git a/tests/rewriter/Position.length.phpt b/tests/rewriter/Position.length.phpt new file mode 100644 index 000000000..3d01696d2 --- /dev/null +++ b/tests/rewriter/Position.length.phpt @@ -0,0 +1,118 @@ +parse('Hello World'); + + $textNode = $ast->main->children[0]; + Assert::type(TextNode::class, $textNode); + Assert::same(0, $textNode->position->offset); + Assert::same(11, $textNode->position->length); +}); + + +test('Plain text with newline is single node', function () { + $engine = new Latte\Engine; + $ast = $engine->parse("Hello\nWorld"); + + // In plain text mode, the whole content is a single TextNode + $node = $ast->main->children[0]; + Assert::type(TextNode::class, $node); + Assert::same(0, $node->position->offset); + Assert::same(11, $node->position->length); // "Hello\nWorld" +}); + + +test('HTML text has correct length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('

Hello

'); + + // Find the TextNode inside the element + $element = $ast->main->children[0]; + $textNode = $element->content->children[0]; + Assert::type(TextNode::class, $textNode); + Assert::same('Hello', $textNode->content); + Assert::same(5, $textNode->position->length); +}); + + +test('PrintNode has correct length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{=$var}'); + + $node = $ast->main->children[0]; + Assert::type(Latte\Compiler\Nodes\PrintNode::class, $node); + Assert::same(0, $node->position->offset); + Assert::same(7, $node->position->length); // {=$var} = 7 chars +}); + + +test('Paired tag has full length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $cond}text{/if}'); + + $node = $ast->main->children[0]; + Assert::type(Latte\Essential\Nodes\IfNode::class, $node); + Assert::same(0, $node->position->offset); + Assert::same(19, $node->position->length); // {if $cond}text{/if} = 19 chars +}); + + +test('Nested paired tags have correct lengths', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $a}{if $b}x{/if}{/if}'); + + // Outer if: {if $a}{if $b}x{/if}{/if} = 25 chars + $outer = $ast->main->children[0]; + Assert::type(Latte\Essential\Nodes\IfNode::class, $outer); + Assert::same(0, $outer->position->offset); + Assert::same(25, $outer->position->length); + + // Inner if: {if $b}x{/if} = 13 chars, starts at offset 7 + $inner = $outer->then->children[0]; + Assert::type(Latte\Essential\Nodes\IfNode::class, $inner); + Assert::same(7, $inner->position->offset); + Assert::same(13, $inner->position->length); +}); + + +test('HTML element has correct length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('

Hello

'); + + $elem = $ast->main->children[0]; + Assert::type(Latte\Compiler\Nodes\Html\ElementNode::class, $elem); + Assert::same(0, $elem->position->offset); + Assert::same(12, $elem->position->length); //

Hello

= 12 +}); + + +test('Void element has correct length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('
'); + + $elem = $ast->main->children[0]; + Assert::type(Latte\Compiler\Nodes\Html\ElementNode::class, $elem); + Assert::same(0, $elem->position->offset); + Assert::same(4, $elem->position->length); //
= 4 +}); + + +test('HTML attribute has correct length', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('x'); + + $elem = $ast->main->children[0]; + $attr = $elem->attributes->children[1]; // [0] is whitespace + Assert::type(Latte\Compiler\Nodes\Html\AttributeNode::class, $attr); + Assert::same(3, $attr->position->offset); + Assert::same(10, $attr->position->length); // href="url" = 10 +}); From 5d932e27361cb3ba8b63799a1277f6fdf98d5a00 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 24 Jan 2026 08:38:20 +0100 Subject: [PATCH 4/5] StatementNode: added tagPositions --- src/Latte/Compiler/Nodes/StatementNode.php | 4 + src/Latte/Compiler/TemplateParser.php | 8 + .../Essential/Nodes/FirstLastSepNode.php | 5 +- src/Latte/Essential/Nodes/ForeachNode.php | 5 +- src/Latte/Essential/Nodes/IfChangedNode.php | 7 +- src/Latte/Essential/Nodes/SwitchNode.php | 16 +- tests/rewriter/Position.tagPositions.phpt | 159 ++++++++++++++++++ 7 files changed, 182 insertions(+), 22 deletions(-) create mode 100644 tests/rewriter/Position.tagPositions.phpt diff --git a/src/Latte/Compiler/Nodes/StatementNode.php b/src/Latte/Compiler/Nodes/StatementNode.php index 3b92163cd..747a34cd9 100644 --- a/src/Latte/Compiler/Nodes/StatementNode.php +++ b/src/Latte/Compiler/Nodes/StatementNode.php @@ -7,6 +7,8 @@ namespace Latte\Compiler\Nodes; +use Latte\Compiler\Position; + /** * Base for Latte tags like {if}, {foreach}, {block}. @@ -16,4 +18,6 @@ */ abstract class StatementNode extends AreaNode { + /** @var list positions of all tags (opening, intermediate like {else}, closing) */ + public array $tagPositions = []; } diff --git a/src/Latte/Compiler/TemplateParser.php b/src/Latte/Compiler/TemplateParser.php index 3293df178..90b26fa56 100644 --- a/src/Latte/Compiler/TemplateParser.php +++ b/src/Latte/Compiler/TemplateParser.php @@ -194,6 +194,7 @@ public function parseLatteStatement(?\Closure $resolver = null): ?Node $token = $this->stream->peek(); $startTag = $this->pushTag($this->parseLatteTag()); + $tagPositions = [$startTag->position]; $parser = $this->getTagParser($startTag->name, $token->position); $res = $parser($startTag, $this); @@ -231,10 +232,12 @@ public function parseLatteStatement(?\Closure $resolver = null): ?Node if ($tag->closing) { $this->checkEndTag($startTag, $tag); + $tagPositions[] = $tag->position; $res->send([$content, $tag]); $this->ensureIsConsumed($tag); break; } elseif (in_array($tag->name, $this->lookFor[$startTag] ?? [], strict: true)) { + $tagPositions[] = $tag->position; $this->pushTag($tag); $res->send([$content, $tag]); $this->ensureIsConsumed($tag); @@ -273,6 +276,11 @@ public function parseLatteStatement(?\Closure $resolver = null): ?Node $node->position = isset($tag) && $tag->closing ? Position::range($startTag->position, $tag->position) : $startTag->position; + + if ($node instanceof Nodes\StatementNode) { + $node->tagPositions = $tagPositions; + } + return $node; } diff --git a/src/Latte/Essential/Nodes/FirstLastSepNode.php b/src/Latte/Essential/Nodes/FirstLastSepNode.php index e49c37694..94931b4cc 100644 --- a/src/Latte/Essential/Nodes/FirstLastSepNode.php +++ b/src/Latte/Essential/Nodes/FirstLastSepNode.php @@ -10,7 +10,6 @@ use Latte\Compiler\Nodes\AreaNode; use Latte\Compiler\Nodes\Php\ExpressionNode; use Latte\Compiler\Nodes\StatementNode; -use Latte\Compiler\Position; use Latte\Compiler\PrintContext; use Latte\Compiler\Tag; @@ -25,7 +24,6 @@ class FirstLastSepNode extends StatementNode public ?ExpressionNode $width; public AreaNode $then; public ?AreaNode $else = null; - public ?Position $elseLine = null; /** @return \Generator, array{AreaNode, ?Tag}, static> */ @@ -37,7 +35,6 @@ public static function create(Tag $tag): \Generator [$node->then, $nextTag] = yield ['else']; if ($nextTag?->name === 'else') { - $node->elseLine = $nextTag->position; [$node->else] = yield; } @@ -59,7 +56,7 @@ public function print(PrintContext $context): string $this->width, $this->position, $this->then, - $this->elseLine, + $this->tagPositions[1] ?? null, $this->else, ); } diff --git a/src/Latte/Essential/Nodes/ForeachNode.php b/src/Latte/Essential/Nodes/ForeachNode.php index e5d1a49f2..621aea665 100644 --- a/src/Latte/Essential/Nodes/ForeachNode.php +++ b/src/Latte/Essential/Nodes/ForeachNode.php @@ -18,7 +18,6 @@ use Latte\Compiler\Nodes\StatementNode; use Latte\Compiler\Nodes\TemplateNode; use Latte\Compiler\NodeTraverser; -use Latte\Compiler\Position; use Latte\Compiler\PrintContext; use Latte\Compiler\Tag; use Latte\Compiler\TagParser; @@ -38,7 +37,6 @@ class ForeachNode extends StatementNode public ExpressionNode|ListNode $value; public AreaNode $content; public ?AreaNode $else = null; - public ?Position $elseLine = null; public ?bool $iterator = null; public bool $checkArgs = true; @@ -66,7 +64,6 @@ public static function create(Tag $tag): \Generator [$node->content, $nextTag] = yield ['else']; if ($nextTag?->name === 'else') { - $node->elseLine = $nextTag->position; [$node->else] = yield; } @@ -102,7 +99,7 @@ public function print(PrintContext $context): string $code .= $context->format( "if (%raw) %line { %node\n}\n", $useIterator ? '$iterator->isEmpty()' : $context->format('empty(%node)', $this->expression), - $this->elseLine, + $this->tagPositions[1] ?? null, $this->else, ); } diff --git a/src/Latte/Essential/Nodes/IfChangedNode.php b/src/Latte/Essential/Nodes/IfChangedNode.php index 1c46027a0..bf31bd576 100644 --- a/src/Latte/Essential/Nodes/IfChangedNode.php +++ b/src/Latte/Essential/Nodes/IfChangedNode.php @@ -10,7 +10,6 @@ use Latte\Compiler\Nodes\AreaNode; use Latte\Compiler\Nodes\Php\Expression\ArrayNode; use Latte\Compiler\Nodes\StatementNode; -use Latte\Compiler\Position; use Latte\Compiler\PrintContext; use Latte\Compiler\Tag; @@ -24,7 +23,6 @@ class IfChangedNode extends StatementNode public ArrayNode $conditions; public AreaNode $then; public ?AreaNode $else = null; - public ?Position $elseLine = null; /** @return \Generator, array{AreaNode, ?Tag}, static> */ @@ -35,7 +33,6 @@ public static function create(Tag $tag): \Generator [$node->then, $nextTag] = yield ['else']; if ($nextTag?->name === 'else') { - $node->elseLine = $nextTag->position; [$node->else] = yield; } @@ -68,7 +65,7 @@ private function printExpression(PrintContext $context): string $context->generateId(), $this->conditions, $this->then, - $this->elseLine, + $this->tagPositions[1] ?? null, $this->else, ) : $context->format( @@ -107,7 +104,7 @@ private function printCapturing(PrintContext $context): string $this->position, $this->then, $context->generateId(), - $this->elseLine, + $this->tagPositions[1] ?? null, $this->else, ) : $context->format( diff --git a/src/Latte/Essential/Nodes/SwitchNode.php b/src/Latte/Essential/Nodes/SwitchNode.php index e53793b7d..7adf53974 100644 --- a/src/Latte/Essential/Nodes/SwitchNode.php +++ b/src/Latte/Essential/Nodes/SwitchNode.php @@ -13,7 +13,6 @@ use Latte\Compiler\Nodes\Php\ExpressionNode; use Latte\Compiler\Nodes\StatementNode; use Latte\Compiler\Nodes\TextNode; -use Latte\Compiler\Position; use Latte\Compiler\PrintContext; use Latte\Compiler\Tag; @@ -26,7 +25,7 @@ class SwitchNode extends StatementNode { public ?ExpressionNode $expression; - /** @var array */ + /** @var array */ public array $cases = []; @@ -53,17 +52,16 @@ public static function create(Tag $tag): \Generator while (true) { if ($nextTag->name === 'case') { $nextTag->expectArguments(); - [$case, $line] = [$nextTag->parser->parseArguments(), $nextTag->position]; + $case = $nextTag->parser->parseArguments(); [$content, $nextTag] = yield ['case', 'default']; - $node->cases[] = [$case, $line, $content]; + $node->cases[] = [$case, $content]; } elseif ($nextTag->name === 'default') { if ($default++) { throw new CompileException('Tag {switch} may only contain one {default} clause.', $nextTag->position); } - $line = $nextTag->position; [$content, $nextTag] = yield ['case', 'default']; - $node->cases[] = [null, $line, $content]; + $node->cases[] = [null, $content]; } else { return $node; @@ -81,7 +79,7 @@ public function print(PrintContext $context): string ); $first = true; $default = null; - foreach ($this->cases as [$case, $line, $content]) { + foreach ($this->cases as $i => [$case, $content]) { if (!$case) { $default = $content->print($context); continue; @@ -93,7 +91,7 @@ public function print(PrintContext $context): string $res .= $context->format( 'if (in_array($ʟ_switch, %node, true)) %line { %node } ', $case, - $line, + $this->tagPositions[$i + 1] ?? null, $content, ); } @@ -110,7 +108,7 @@ public function &getIterator(): \Generator if ($this->expression) { yield $this->expression; } - foreach ($this->cases as [&$case, , &$stmt]) { + foreach ($this->cases as [&$case, &$stmt]) { if ($case) { yield $case; } diff --git a/tests/rewriter/Position.tagPositions.phpt b/tests/rewriter/Position.tagPositions.phpt new file mode 100644 index 000000000..d969a74f0 --- /dev/null +++ b/tests/rewriter/Position.tagPositions.phpt @@ -0,0 +1,159 @@ +parse('{=$var}'); + + $node = $ast->main->children[0]; + Assert::type(Latte\Compiler\Nodes\PrintNode::class, $node); + Assert::count(1, $node->tagPositions); + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(7, $node->tagPositions[0]->length); +}); + + +test('paired tag has two tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $cond}text{/if}'); + + $node = $ast->main->children[0]; + Assert::type(IfNode::class, $node); + Assert::count(2, $node->tagPositions); + + // opening tag {if $cond} + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(10, $node->tagPositions[0]->length); + + // closing tag {/if} + Assert::same(14, $node->tagPositions[1]->offset); + Assert::same(5, $node->tagPositions[1]->length); +}); + + +test('if/else has three tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $a}text{else}more{/if}'); + + $node = $ast->main->children[0]; + Assert::type(IfNode::class, $node); + Assert::count(3, $node->tagPositions); + + // {if $a} + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(7, $node->tagPositions[0]->length); + + // {else} + Assert::same(11, $node->tagPositions[1]->offset); + Assert::same(6, $node->tagPositions[1]->length); + + // {/if} + Assert::same(21, $node->tagPositions[2]->offset); + Assert::same(5, $node->tagPositions[2]->length); +}); + + +test('if/elseif/else has four tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $a}A{elseif $b}B{else}C{/if}'); + + $node = $ast->main->children[0]; + Assert::type(IfNode::class, $node); + Assert::count(4, $node->tagPositions); + + // {if $a} + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(7, $node->tagPositions[0]->length); + + // {elseif $b} + Assert::same(8, $node->tagPositions[1]->offset); + Assert::same(11, $node->tagPositions[1]->length); + + // {else} + Assert::same(20, $node->tagPositions[2]->offset); + Assert::same(6, $node->tagPositions[2]->length); + + // {/if} + Assert::same(27, $node->tagPositions[3]->offset); + Assert::same(5, $node->tagPositions[3]->length); +}); + + +test('foreach has two tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{foreach $items as $item}x{/foreach}'); + + $node = $ast->main->children[0]; + Assert::type(ForeachNode::class, $node); + Assert::count(2, $node->tagPositions); + + // {foreach $items as $item} + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(25, $node->tagPositions[0]->length); + + // {/foreach} + Assert::same(26, $node->tagPositions[1]->offset); + Assert::same(10, $node->tagPositions[1]->length); +}); + + +test('foreach/else has three tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{foreach $items as $item}x{else}empty{/foreach}'); + + $node = $ast->main->children[0]; + Assert::type(ForeachNode::class, $node); + Assert::count(3, $node->tagPositions); + + // {foreach $items as $item} + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(25, $node->tagPositions[0]->length); + + // {else} + Assert::same(26, $node->tagPositions[1]->offset); + Assert::same(6, $node->tagPositions[1]->length); + + // {/foreach} + Assert::same(37, $node->tagPositions[2]->offset); + Assert::same(10, $node->tagPositions[2]->length); +}); + + +test('nested if tags have correct tagPositions', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{if $a}{if $b}x{/if}{/if}'); + + // Outer if + $outer = $ast->main->children[0]; + Assert::type(IfNode::class, $outer); + Assert::count(2, $outer->tagPositions); + Assert::same(0, $outer->tagPositions[0]->offset); // {if $a} + Assert::same(20, $outer->tagPositions[1]->offset); // {/if} + + // Inner if + $inner = $outer->then->children[0]; + Assert::type(IfNode::class, $inner); + Assert::count(2, $inner->tagPositions); + Assert::same(7, $inner->tagPositions[0]->offset); // {if $b} + Assert::same(15, $inner->tagPositions[1]->offset); // {/if} +}); + + +test('unpaired tag has one tagPosition', function () { + $engine = new Latte\Engine; + $ast = $engine->parse('{var $x = 1}'); + + // {var} goes to head, not main + $node = $ast->head->children[0]; + Assert::count(1, $node->tagPositions); + Assert::same(0, $node->tagPositions[0]->offset); + Assert::same(12, $node->tagPositions[0]->length); +}); From 8e016c585d37aa3e5cf698a9d2ccfae3648c03c1 Mon Sep 17 00:00:00 2001 From: David Krmela Date: Sat, 4 Apr 2026 13:12:30 +0200 Subject: [PATCH 5/5] Dedent: fixed indentation preservation for paired tags inside HTML --- src/Latte/Compiler/TemplateParser.php | 53 +++++++++++++++++++++++++-- tests/common/dedent.phpt | 18 +++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/Latte/Compiler/TemplateParser.php b/src/Latte/Compiler/TemplateParser.php index 90b26fa56..a393f8e60 100644 --- a/src/Latte/Compiler/TemplateParser.php +++ b/src/Latte/Compiler/TemplateParser.php @@ -513,6 +513,11 @@ private function applyDedent(FragmentNode $fragment, Tag $startTag): void $baseIndent = null; $atLineStart = true; $inlineChecked = false; + $root = $startTag; + while ($root->parent !== null) { + $root = $root->parent; + } + $tagIndentLen = $root->position->column - 1; foreach ($fragment->children as $i => $child) { if ($child instanceof Nodes\TextNode && $child->content === '') { @@ -545,12 +550,15 @@ private function applyDedent(FragmentNode $fragment, Tag $startTag): void if ($hasContent) { preg_match('/^([ \t]+)/', $line, $m); $baseIndent = $m[1] ?? null; - if ($baseIndent === null) { - return; // first content line has no indent + if ($baseIndent === null || strlen($baseIndent) <= $tagIndentLen) { + return; // first content line has no indent beyond tag level } } elseif ($continuesWithExpr) { $baseIndent = $line; + if (strlen($baseIndent) <= $tagIndentLen) { + return; + } } else { continue; // blank line before detection @@ -564,12 +572,51 @@ private function applyDedent(FragmentNode $fragment, Tag $startTag): void continue; // blank line, strip silently } - $line = substr($line, strlen((string) $baseIndent)); + $line = substr($line, 0, $tagIndentLen) . substr($line, strlen((string) $baseIndent)); } unset($line); $child->content = implode("\n", $lines); $atLineStart = str_ends_with($child->content, "\n"); } + + // Also dedent indentation inside HTML elements + $indentNodes = []; + $this->collectHtmlIndentNodes($fragment, $indentNodes); + if ($indentNodes) { + if ($baseIndent === null) { + // detect minimum from HTML elements + $baseIndent = $indentNodes[0]->content; + foreach ($indentNodes as $node) { + if (strlen($node->content) < strlen($baseIndent)) { + $baseIndent = $node->content; + } + } + if (strlen($baseIndent) <= $tagIndentLen) { + return; + } + } + foreach ($indentNodes as $node) { + if (str_starts_with($node->content, $baseIndent)) { + $node->content = substr($node->content, 0, $tagIndentLen) . substr($node->content, strlen($baseIndent)); + } + } + } + } + + + private function collectHtmlIndentNodes(FragmentNode $fragment, array &$nodes, bool $inElement = false): void + { + foreach ($fragment->children as $child) { + if ($inElement && $child instanceof Nodes\TextNode + && $child->content !== '' + && trim($child->content) === '' + && !str_contains($child->content, "\n") + ) { + $nodes[] = $child; + } elseif ($child instanceof Nodes\Html\ElementNode && $child->content instanceof FragmentNode) { + $this->collectHtmlIndentNodes($child->content, $nodes, true); + } + } } } diff --git a/tests/common/dedent.phpt b/tests/common/dedent.phpt index 736de7479..9d8cff453 100644 --- a/tests/common/dedent.phpt +++ b/tests/common/dedent.phpt @@ -115,6 +115,24 @@ test('expressions with OutputKeepIndentation and varying indent (issue #413)', f }); +test('foreach inside HTML - dedents only excess indentation', function () { + $result = dedent("
    \n\t{foreach \$items as \$item}\n\t\t
  • {\$item}
  • \n\t{/foreach}\n
", ['items' => ['a', 'b']]); + Assert::same("
    \n\t
  • a
  • \n\t
  • b
  • \n
", $result); +}); + + +test('nested foreach/if inside HTML', function () { + $result = dedent("
    \n\t{foreach [0, 1, 2] as \$item}\n\t\t{if \$item}\n\t\t\t
  • {\$item}
  • \n\t\t{/if}\n\t{/foreach}\n
"); + Assert::same("
    \n\t
  • 1
  • \n\t
  • 2
  • \n
", $result); +}); + + +test('HTML elements inside paired tags', function () { + $result = dedent("{foreach [0, 1, 2] as \$item}\n\t{if \$item}\n\t\t
    \n\t\t\t
  • {\$item}
  • \n\t\t
\n\t{/if}\n{/foreach}"); + Assert::same("
    \n\t
  • 1
  • \n
\n
    \n\t
  • 2
  • \n
\n", $result); +}); + + test('inconsistent indentation throws exception', function () { Assert::exception( fn() => dedent("{if true}\n\tHello\nWorld\n{/if}"),