', [
new TagNode('-', 0, 'foo'),
]],
['', [
new TagNode('-', 0, 'foo'),
]],
//0123456789012345678901
['bar', [
new TagNode('-', 0, 'foo', [], [
new TextNode('-', 9, 'bar'),
]),
]],
//0 1 2 3 4 5 6 7 8 9 0
//012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
['abc$xx', [
new TagNode('-', 0, 'foo', [
'a' => [
new VariableNode('-', 12, 'b', [
[new TextNode('-', 15, '0')],
[new VariableNode('-', 18, 'x', [])],
]),
],
'c' => [
new TextNode('-', 26, '"'),
],
'd' => [
new VariableNode('-', 33, 'e', []),
new TextNode('-', 37, 'f'),
]
], [
new TagNode('-', 40, 'foo', [], [
new TagNode('-', 49, 'xyz', [], [
new TextNode('-', 58, 'abc'),
]),
new TagNode('-', 71, 'foo'),
new VariableNode('-', 82, 'x', []),
]),
]),
new TextNode('-', 104, 'x'),
]],
//0 1 2 3
//01234567890123456789012345678901234567
['foo?{~{$x|eq|\}$y}|b|\}}$bar', [
new TextNode('-', 0, 'foo'),
new TagNode('-', 3, 'if', [], [
new TagNode('-', 5, 'cmp', [
'text_a' => [new VariableNode('-', 7, 'x', [])],
'op' => [new TextNode('-', 10, 'eq')],
'text_b' => [
new TextNode('-', 13, '}'),
new VariableNode('-', 15, 'y', []),
],
], []),
new TagNode('-', 3, 'then', [], [
new TextNode('-', 19, 'b'),
]),
new TagNode('-', 3, 'else', [], [
new TagNode('-', 21, 'foo'),
new TextNode('-', 31, '}'),
]),
]),
new VariableNode('-', 34, 'bar', []),
]],
['ignored', []],
['fooignoredbar', [
// These are not two TextNodes as the parser will collapse adjacent TextNodes
new TextNode('-', 0, 'foobar'),
]],
['$abc', [
new TextNode('-', 0, '$abc'),
]],
['$abc', [
new TextNode('-', 0, '$abc'),
]],
];
}
/**
* @dataProvider failsToParseDataProvider
* @param string $input
*/
public function testFailsToParse(string $input)
{
self::expectException(ParseCompileError::class);
Parser::parse($input, '-');
}
public function failsToParseDataProvider()
{
return [
// Incomplete tag
[''],
['bar'],
['barbarbar'],
[''],
// Unclosed parameter
[''],
// Unclosed tag
['bar'],
// Trailing closing tag
[''],
['abc'],
[''],
// Open/close tag mismatch
['bar'],
// Nesting error
[''],
// Invalid parameter name
[''],
// Unclosed variable
['${foo'],
['${${foo}'],
// Unclosed array
['$foo[bar'],
// Incomplete variable
['$'],
['foo$'],
['foo${}'],
// Incomplete shorthands
['?{foo|bar}'],
['?{foo|bar|baz'],
['?{foo|'],
['?{foo}'],
['?{'],
['~{foo|bar}'],
['~{foo|bar|baz'],
['~{foo|'],
['~{foo}'],
['~{'],
// Unclosing pseudotags
['foo'],
['foo'],
];
}
}