@@ -25,52 +25,52 @@ |
||
25 | 25 | */ |
26 | 26 | class FunctionNode extends AbstractNode |
27 | 27 | { |
28 | - private NodeInterface $selector; |
|
29 | - private string $name; |
|
30 | - private array $arguments; |
|
28 | + private NodeInterface $selector; |
|
29 | + private string $name; |
|
30 | + private array $arguments; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param Token[] $arguments |
|
34 | - */ |
|
35 | - public function __construct(NodeInterface $selector, string $name, array $arguments = []) |
|
36 | - { |
|
37 | - $this->selector = $selector; |
|
38 | - $this->name = strtolower($name); |
|
39 | - $this->arguments = $arguments; |
|
40 | - } |
|
32 | + /** |
|
33 | + * @param Token[] $arguments |
|
34 | + */ |
|
35 | + public function __construct(NodeInterface $selector, string $name, array $arguments = []) |
|
36 | + { |
|
37 | + $this->selector = $selector; |
|
38 | + $this->name = strtolower($name); |
|
39 | + $this->arguments = $arguments; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getSelector(): NodeInterface |
|
43 | - { |
|
44 | - return $this->selector; |
|
45 | - } |
|
42 | + public function getSelector(): NodeInterface |
|
43 | + { |
|
44 | + return $this->selector; |
|
45 | + } |
|
46 | 46 | |
47 | - public function getName(): string |
|
48 | - { |
|
49 | - return $this->name; |
|
50 | - } |
|
47 | + public function getName(): string |
|
48 | + { |
|
49 | + return $this->name; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return Token[] |
|
54 | - */ |
|
55 | - public function getArguments(): array |
|
56 | - { |
|
57 | - return $this->arguments; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return Token[] |
|
54 | + */ |
|
55 | + public function getArguments(): array |
|
56 | + { |
|
57 | + return $this->arguments; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - public function getSpecificity(): Specificity |
|
64 | - { |
|
65 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
66 | - } |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + public function getSpecificity(): Specificity |
|
64 | + { |
|
65 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
66 | + } |
|
67 | 67 | |
68 | - public function __toString(): string |
|
69 | - { |
|
70 | - $arguments = implode(', ', array_map(function (Token $token) { |
|
71 | - return "'".$token->getValue()."'"; |
|
72 | - }, $this->arguments)); |
|
68 | + public function __toString(): string |
|
69 | + { |
|
70 | + $arguments = implode(', ', array_map(function (Token $token) { |
|
71 | + return "'".$token->getValue()."'"; |
|
72 | + }, $this->arguments)); |
|
73 | 73 | |
74 | - return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); |
|
75 | - } |
|
74 | + return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); |
|
75 | + } |
|
76 | 76 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class ClassNode extends AbstractNode |
25 | 25 | { |
26 | - private NodeInterface $selector; |
|
27 | - private string $name; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $selector, string $name) |
|
30 | - { |
|
31 | - $this->selector = $selector; |
|
32 | - $this->name = $name; |
|
33 | - } |
|
34 | - |
|
35 | - public function getSelector(): NodeInterface |
|
36 | - { |
|
37 | - return $this->selector; |
|
38 | - } |
|
39 | - |
|
40 | - public function getName(): string |
|
41 | - { |
|
42 | - return $this->name; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); |
|
56 | - } |
|
26 | + private NodeInterface $selector; |
|
27 | + private string $name; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $selector, string $name) |
|
30 | + { |
|
31 | + $this->selector = $selector; |
|
32 | + $this->name = $name; |
|
33 | + } |
|
34 | + |
|
35 | + public function getSelector(): NodeInterface |
|
36 | + { |
|
37 | + return $this->selector; |
|
38 | + } |
|
39 | + |
|
40 | + public function getName(): string |
|
41 | + { |
|
42 | + return $this->name; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); |
|
56 | + } |
|
57 | 57 | } |
@@ -23,60 +23,60 @@ |
||
23 | 23 | */ |
24 | 24 | class AttributeNode extends AbstractNode |
25 | 25 | { |
26 | - private NodeInterface $selector; |
|
27 | - private ?string $namespace; |
|
28 | - private string $attribute; |
|
29 | - private string $operator; |
|
30 | - private ?string $value; |
|
26 | + private NodeInterface $selector; |
|
27 | + private ?string $namespace; |
|
28 | + private string $attribute; |
|
29 | + private string $operator; |
|
30 | + private ?string $value; |
|
31 | 31 | |
32 | - public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) |
|
33 | - { |
|
34 | - $this->selector = $selector; |
|
35 | - $this->namespace = $namespace; |
|
36 | - $this->attribute = $attribute; |
|
37 | - $this->operator = $operator; |
|
38 | - $this->value = $value; |
|
39 | - } |
|
32 | + public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) |
|
33 | + { |
|
34 | + $this->selector = $selector; |
|
35 | + $this->namespace = $namespace; |
|
36 | + $this->attribute = $attribute; |
|
37 | + $this->operator = $operator; |
|
38 | + $this->value = $value; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getSelector(): NodeInterface |
|
42 | - { |
|
43 | - return $this->selector; |
|
44 | - } |
|
41 | + public function getSelector(): NodeInterface |
|
42 | + { |
|
43 | + return $this->selector; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getNamespace(): ?string |
|
47 | - { |
|
48 | - return $this->namespace; |
|
49 | - } |
|
46 | + public function getNamespace(): ?string |
|
47 | + { |
|
48 | + return $this->namespace; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getAttribute(): string |
|
52 | - { |
|
53 | - return $this->attribute; |
|
54 | - } |
|
51 | + public function getAttribute(): string |
|
52 | + { |
|
53 | + return $this->attribute; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getOperator(): string |
|
57 | - { |
|
58 | - return $this->operator; |
|
59 | - } |
|
56 | + public function getOperator(): string |
|
57 | + { |
|
58 | + return $this->operator; |
|
59 | + } |
|
60 | 60 | |
61 | - public function getValue(): ?string |
|
62 | - { |
|
63 | - return $this->value; |
|
64 | - } |
|
61 | + public function getValue(): ?string |
|
62 | + { |
|
63 | + return $this->value; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * {@inheritdoc} |
|
68 | - */ |
|
69 | - public function getSpecificity(): Specificity |
|
70 | - { |
|
71 | - return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
72 | - } |
|
66 | + /** |
|
67 | + * {@inheritdoc} |
|
68 | + */ |
|
69 | + public function getSpecificity(): Specificity |
|
70 | + { |
|
71 | + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); |
|
72 | + } |
|
73 | 73 | |
74 | - public function __toString(): string |
|
75 | - { |
|
76 | - $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; |
|
74 | + public function __toString(): string |
|
75 | + { |
|
76 | + $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; |
|
77 | 77 | |
78 | - return 'exists' === $this->operator |
|
79 | - ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) |
|
80 | - : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); |
|
81 | - } |
|
78 | + return 'exists' === $this->operator |
|
79 | + ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) |
|
80 | + : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); |
|
81 | + } |
|
82 | 82 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class NegationNode extends AbstractNode |
25 | 25 | { |
26 | - private NodeInterface $selector; |
|
27 | - private NodeInterface $subSelector; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $selector, NodeInterface $subSelector) |
|
30 | - { |
|
31 | - $this->selector = $selector; |
|
32 | - $this->subSelector = $subSelector; |
|
33 | - } |
|
34 | - |
|
35 | - public function getSelector(): NodeInterface |
|
36 | - { |
|
37 | - return $this->selector; |
|
38 | - } |
|
39 | - |
|
40 | - public function getSubSelector(): NodeInterface |
|
41 | - { |
|
42 | - return $this->subSelector; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); |
|
56 | - } |
|
26 | + private NodeInterface $selector; |
|
27 | + private NodeInterface $subSelector; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $selector, NodeInterface $subSelector) |
|
30 | + { |
|
31 | + $this->selector = $selector; |
|
32 | + $this->subSelector = $subSelector; |
|
33 | + } |
|
34 | + |
|
35 | + public function getSelector(): NodeInterface |
|
36 | + { |
|
37 | + return $this->selector; |
|
38 | + } |
|
39 | + |
|
40 | + public function getSubSelector(): NodeInterface |
|
41 | + { |
|
42 | + return $this->subSelector; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); |
|
56 | + } |
|
57 | 57 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class SelectorNode extends AbstractNode |
25 | 25 | { |
26 | - private NodeInterface $tree; |
|
27 | - private ?string $pseudoElement; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $tree, string $pseudoElement = null) |
|
30 | - { |
|
31 | - $this->tree = $tree; |
|
32 | - $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; |
|
33 | - } |
|
34 | - |
|
35 | - public function getTree(): NodeInterface |
|
36 | - { |
|
37 | - return $this->tree; |
|
38 | - } |
|
39 | - |
|
40 | - public function getPseudoElement(): ?string |
|
41 | - { |
|
42 | - return $this->pseudoElement; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); |
|
56 | - } |
|
26 | + private NodeInterface $tree; |
|
27 | + private ?string $pseudoElement; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $tree, string $pseudoElement = null) |
|
30 | + { |
|
31 | + $this->tree = $tree; |
|
32 | + $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; |
|
33 | + } |
|
34 | + |
|
35 | + public function getTree(): NodeInterface |
|
36 | + { |
|
37 | + return $this->tree; |
|
38 | + } |
|
39 | + |
|
40 | + public function getPseudoElement(): ?string |
|
41 | + { |
|
42 | + return $this->pseudoElement; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); |
|
56 | + } |
|
57 | 57 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | */ |
24 | 24 | class HashNode extends AbstractNode |
25 | 25 | { |
26 | - private NodeInterface $selector; |
|
27 | - private string $id; |
|
28 | - |
|
29 | - public function __construct(NodeInterface $selector, string $id) |
|
30 | - { |
|
31 | - $this->selector = $selector; |
|
32 | - $this->id = $id; |
|
33 | - } |
|
34 | - |
|
35 | - public function getSelector(): NodeInterface |
|
36 | - { |
|
37 | - return $this->selector; |
|
38 | - } |
|
39 | - |
|
40 | - public function getId(): string |
|
41 | - { |
|
42 | - return $this->id; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getSpecificity(): Specificity |
|
49 | - { |
|
50 | - return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); |
|
51 | - } |
|
52 | - |
|
53 | - public function __toString(): string |
|
54 | - { |
|
55 | - return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); |
|
56 | - } |
|
26 | + private NodeInterface $selector; |
|
27 | + private string $id; |
|
28 | + |
|
29 | + public function __construct(NodeInterface $selector, string $id) |
|
30 | + { |
|
31 | + $this->selector = $selector; |
|
32 | + $this->id = $id; |
|
33 | + } |
|
34 | + |
|
35 | + public function getSelector(): NodeInterface |
|
36 | + { |
|
37 | + return $this->selector; |
|
38 | + } |
|
39 | + |
|
40 | + public function getId(): string |
|
41 | + { |
|
42 | + return $this->id; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getSpecificity(): Specificity |
|
49 | + { |
|
50 | + return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); |
|
51 | + } |
|
52 | + |
|
53 | + public function __toString(): string |
|
54 | + { |
|
55 | + return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); |
|
56 | + } |
|
57 | 57 | } |
@@ -28,27 +28,27 @@ |
||
28 | 28 | */ |
29 | 29 | class NumberHandler implements HandlerInterface |
30 | 30 | { |
31 | - private TokenizerPatterns $patterns; |
|
31 | + private TokenizerPatterns $patterns; |
|
32 | 32 | |
33 | - public function __construct(TokenizerPatterns $patterns) |
|
34 | - { |
|
35 | - $this->patterns = $patterns; |
|
36 | - } |
|
33 | + public function __construct(TokenizerPatterns $patterns) |
|
34 | + { |
|
35 | + $this->patterns = $patterns; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritdoc} |
|
40 | - */ |
|
41 | - public function handle(Reader $reader, TokenStream $stream): bool |
|
42 | - { |
|
43 | - $match = $reader->findPattern($this->patterns->getNumberPattern()); |
|
38 | + /** |
|
39 | + * {@inheritdoc} |
|
40 | + */ |
|
41 | + public function handle(Reader $reader, TokenStream $stream): bool |
|
42 | + { |
|
43 | + $match = $reader->findPattern($this->patterns->getNumberPattern()); |
|
44 | 44 | |
45 | - if (!$match) { |
|
46 | - return false; |
|
47 | - } |
|
45 | + if (!$match) { |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition())); |
|
50 | - $reader->moveForward(\strlen($match[0])); |
|
49 | + $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition())); |
|
50 | + $reader->moveForward(\strlen($match[0])); |
|
51 | 51 | |
52 | - return true; |
|
53 | - } |
|
52 | + return true; |
|
53 | + } |
|
54 | 54 | } |
@@ -29,30 +29,30 @@ |
||
29 | 29 | */ |
30 | 30 | class HashHandler implements HandlerInterface |
31 | 31 | { |
32 | - private TokenizerPatterns $patterns; |
|
33 | - private TokenizerEscaping $escaping; |
|
34 | - |
|
35 | - public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) |
|
36 | - { |
|
37 | - $this->patterns = $patterns; |
|
38 | - $this->escaping = $escaping; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * {@inheritdoc} |
|
43 | - */ |
|
44 | - public function handle(Reader $reader, TokenStream $stream): bool |
|
45 | - { |
|
46 | - $match = $reader->findPattern($this->patterns->getHashPattern()); |
|
47 | - |
|
48 | - if (!$match) { |
|
49 | - return false; |
|
50 | - } |
|
51 | - |
|
52 | - $value = $this->escaping->escapeUnicode($match[1]); |
|
53 | - $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition())); |
|
54 | - $reader->moveForward(\strlen($match[0])); |
|
55 | - |
|
56 | - return true; |
|
57 | - } |
|
32 | + private TokenizerPatterns $patterns; |
|
33 | + private TokenizerEscaping $escaping; |
|
34 | + |
|
35 | + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) |
|
36 | + { |
|
37 | + $this->patterns = $patterns; |
|
38 | + $this->escaping = $escaping; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * {@inheritdoc} |
|
43 | + */ |
|
44 | + public function handle(Reader $reader, TokenStream $stream): bool |
|
45 | + { |
|
46 | + $match = $reader->findPattern($this->patterns->getHashPattern()); |
|
47 | + |
|
48 | + if (!$match) { |
|
49 | + return false; |
|
50 | + } |
|
51 | + |
|
52 | + $value = $this->escaping->escapeUnicode($match[1]); |
|
53 | + $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition())); |
|
54 | + $reader->moveForward(\strlen($match[0])); |
|
55 | + |
|
56 | + return true; |
|
57 | + } |
|
58 | 58 | } |
@@ -31,47 +31,47 @@ |
||
31 | 31 | */ |
32 | 32 | class StringHandler implements HandlerInterface |
33 | 33 | { |
34 | - private TokenizerPatterns $patterns; |
|
35 | - private TokenizerEscaping $escaping; |
|
34 | + private TokenizerPatterns $patterns; |
|
35 | + private TokenizerEscaping $escaping; |
|
36 | 36 | |
37 | - public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) |
|
38 | - { |
|
39 | - $this->patterns = $patterns; |
|
40 | - $this->escaping = $escaping; |
|
41 | - } |
|
37 | + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) |
|
38 | + { |
|
39 | + $this->patterns = $patterns; |
|
40 | + $this->escaping = $escaping; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritdoc} |
|
45 | - */ |
|
46 | - public function handle(Reader $reader, TokenStream $stream): bool |
|
47 | - { |
|
48 | - $quote = $reader->getSubstring(1); |
|
43 | + /** |
|
44 | + * {@inheritdoc} |
|
45 | + */ |
|
46 | + public function handle(Reader $reader, TokenStream $stream): bool |
|
47 | + { |
|
48 | + $quote = $reader->getSubstring(1); |
|
49 | 49 | |
50 | - if (!\in_array($quote, ["'", '"'])) { |
|
51 | - return false; |
|
52 | - } |
|
50 | + if (!\in_array($quote, ["'", '"'])) { |
|
51 | + return false; |
|
52 | + } |
|
53 | 53 | |
54 | - $reader->moveForward(1); |
|
55 | - $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); |
|
54 | + $reader->moveForward(1); |
|
55 | + $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); |
|
56 | 56 | |
57 | - if (!$match) { |
|
58 | - throw new InternalErrorException(sprintf('Should have found at least an empty match at %d.', $reader->getPosition())); |
|
59 | - } |
|
57 | + if (!$match) { |
|
58 | + throw new InternalErrorException(sprintf('Should have found at least an empty match at %d.', $reader->getPosition())); |
|
59 | + } |
|
60 | 60 | |
61 | - // check unclosed strings |
|
62 | - if (\strlen($match[0]) === $reader->getRemainingLength()) { |
|
63 | - throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
|
64 | - } |
|
61 | + // check unclosed strings |
|
62 | + if (\strlen($match[0]) === $reader->getRemainingLength()) { |
|
63 | + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
|
64 | + } |
|
65 | 65 | |
66 | - // check quotes pairs validity |
|
67 | - if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) { |
|
68 | - throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
|
69 | - } |
|
66 | + // check quotes pairs validity |
|
67 | + if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) { |
|
68 | + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
|
69 | + } |
|
70 | 70 | |
71 | - $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); |
|
72 | - $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); |
|
73 | - $reader->moveForward(\strlen($match[0]) + 1); |
|
71 | + $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); |
|
72 | + $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); |
|
73 | + $reader->moveForward(\strlen($match[0]) + 1); |
|
74 | 74 | |
75 | - return true; |
|
76 | - } |
|
75 | + return true; |
|
76 | + } |
|
77 | 77 | } |