Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/css-selector/Parser/Handler/StringHandler.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
13 | 13 |
14 use Symfony\Component\CssSelector\Exception\InternalErrorException; | 14 use Symfony\Component\CssSelector\Exception\InternalErrorException; |
15 use Symfony\Component\CssSelector\Exception\SyntaxErrorException; | 15 use Symfony\Component\CssSelector\Exception\SyntaxErrorException; |
16 use Symfony\Component\CssSelector\Parser\Reader; | 16 use Symfony\Component\CssSelector\Parser\Reader; |
17 use Symfony\Component\CssSelector\Parser\Token; | 17 use Symfony\Component\CssSelector\Parser\Token; |
18 use Symfony\Component\CssSelector\Parser\TokenStream; | |
19 use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; | 18 use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; |
20 use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; | 19 use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; |
20 use Symfony\Component\CssSelector\Parser\TokenStream; | |
21 | 21 |
22 /** | 22 /** |
23 * CSS selector comment handler. | 23 * CSS selector comment handler. |
24 * | 24 * |
25 * This component is a port of the Python cssselect library, | 25 * This component is a port of the Python cssselect library, |
45 */ | 45 */ |
46 public function handle(Reader $reader, TokenStream $stream) | 46 public function handle(Reader $reader, TokenStream $stream) |
47 { | 47 { |
48 $quote = $reader->getSubstring(1); | 48 $quote = $reader->getSubstring(1); |
49 | 49 |
50 if (!in_array($quote, array("'", '"'))) { | 50 if (!\in_array($quote, ["'", '"'])) { |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 $reader->moveForward(1); | 54 $reader->moveForward(1); |
55 $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); | 55 $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); |
57 if (!$match) { | 57 if (!$match) { |
58 throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition())); | 58 throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition())); |
59 } | 59 } |
60 | 60 |
61 // check unclosed strings | 61 // check unclosed strings |
62 if (strlen($match[0]) === $reader->getRemainingLength()) { | 62 if (\strlen($match[0]) === $reader->getRemainingLength()) { |
63 throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); | 63 throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
64 } | 64 } |
65 | 65 |
66 // check quotes pairs validity | 66 // check quotes pairs validity |
67 if ($quote !== $reader->getSubstring(1, strlen($match[0]))) { | 67 if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) { |
68 throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); | 68 throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); |
69 } | 69 } |
70 | 70 |
71 $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); | 71 $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); |
72 $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); | 72 $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); |
73 $reader->moveForward(strlen($match[0]) + 1); | 73 $reader->moveForward(\strlen($match[0]) + 1); |
74 | 74 |
75 return true; | 75 return true; |
76 } | 76 } |
77 } | 77 } |