class TokenizerEscaping in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php \Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping
CSS selector tokenizer escaping applier.
This component is a port of the Python cssselect library, which is copyright Ian Bicking, @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
Hierarchy
- class \Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping
Expanded class hierarchy of TokenizerEscaping
See also
https://github.com/SimonSapin/cssselect.
6 files declare their use of TokenizerEscaping
- HashHandler.php in vendor/
symfony/ css-selector/ Parser/ Handler/ HashHandler.php - HashHandlerTest.php in vendor/
symfony/ css-selector/ Tests/ Parser/ Handler/ HashHandlerTest.php - IdentifierHandler.php in vendor/
symfony/ css-selector/ Parser/ Handler/ IdentifierHandler.php - IdentifierHandlerTest.php in vendor/
symfony/ css-selector/ Tests/ Parser/ Handler/ IdentifierHandlerTest.php - StringHandler.php in vendor/
symfony/ css-selector/ Parser/ Handler/ StringHandler.php
File
- vendor/
symfony/ css-selector/ Parser/ Tokenizer/ TokenizerEscaping.php, line 22
Namespace
Symfony\Component\CssSelector\Parser\TokenizerView source
class TokenizerEscaping {
/**
* @var TokenizerPatterns
*/
private $patterns;
/**
* @param TokenizerPatterns $patterns
*/
public function __construct(TokenizerPatterns $patterns) {
$this->patterns = $patterns;
}
/**
* @param string $value
*
* @return string
*/
public function escapeUnicode($value) {
$value = $this
->replaceUnicodeSequences($value);
return preg_replace($this->patterns
->getSimpleEscapePattern(), '$1', $value);
}
/**
* @param string $value
*
* @return string
*/
public function escapeUnicodeAndNewLine($value) {
$value = preg_replace($this->patterns
->getNewLineEscapePattern(), '', $value);
return $this
->escapeUnicode($value);
}
/**
* @param string $value
*
* @return string
*/
private function replaceUnicodeSequences($value) {
return preg_replace_callback($this->patterns
->getUnicodeEscapePattern(), function ($match) {
$c = hexdec($match[1]);
if (0x80 > ($c %= 0x200000)) {
return chr($c);
}
if (0x800 > $c) {
return chr(0xc0 | $c >> 6) . chr(0x80 | $c & 0x3f);
}
if (0x10000 > $c) {
return chr(0xe0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3f) . chr(0x80 | $c & 0x3f);
}
}, $value);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TokenizerEscaping:: |
private | property | ||
TokenizerEscaping:: |
public | function | ||
TokenizerEscaping:: |
public | function | ||
TokenizerEscaping:: |
private | function | ||
TokenizerEscaping:: |
public | function |