Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
SetTokenParser.php
01 <?php
02
03 /*
04 * This file is part of Twig.
05 *
06 * (c) Fabien Potencier
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Twig\TokenParser;
13
14 use Twig\Error\SyntaxError;
15 use Twig\Node\SetNode;
16 use Twig\Token;
17
18 /**
19 * Defines a variable.
20 *
21 * {% set foo = 'foo' %}
22 * {% set foo = [1, 2] %}
23 * {% set foo = {'foo': 'bar'} %}
24 * {% set foo = 'foo' ~ 'bar' %}
25 * {% set foo, bar = 'foo', 'bar' %}
26 * {% set foo %}Some content{% endset %}
27 */
28 final class SetTokenParser extends AbstractTokenParser
29 {
30 public function parse(Token $token)
31 {
32 $lineno = $token->getLine();
33 $stream = $this->parser->getStream();
34 $names = $this->parser->getExpressionParser()->parseAssignmentExpression();
35
36 $capture = false;
37 if ($stream->nextIf(/* Token::OPERATOR_TYPE */ 8, '=')) {
38 $values = $this->parser->getExpressionParser()->parseMultitargetExpression();
39
40 $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
41
42 if (\count($names) !== \count($values)) {
43 throw new SyntaxError('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
44 }
45 } else {
46 $capture = true;
47
48 if (\count($names) > 1) {
49 throw new SyntaxError('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
50 }
51
52 $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
53
54 $values = $this->parser->subparse([$this, 'decideBlockEnd'], true);
55 $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
56 }
57
58 return new SetNode($capture, $names, $values, $lineno, $this->getTag());
59 }
60
61 public function decideBlockEnd(Token $token)
62 {
63 return $token->test('endset');
64 }
65
66 public function getTag()
67 {
68 return 'set';
69 }
70 }
71
72 class_alias('Twig\TokenParser\SetTokenParser', 'Twig_TokenParser_Set');
73