PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.5
Independent Analytics – WordPress Analytics Plugin v2.15.5
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / symfony / translation / Extractor / PhpStringTokenParser.php
independent-analytics / vendor / symfony / translation / Extractor Last commit date
AbstractFileExtractor.php 1 month ago ChainExtractor.php 1 month ago ExtractorInterface.php 1 month ago PhpExtractor.php 1 month ago PhpStringTokenParser.php 1 month ago
PhpStringTokenParser.php
110 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace IAWPSCOPED\Symfony\Component\Translation\Extractor;
12
13 /*
14 * The following is derived from code at http://github.com/nikic/PHP-Parser
15 *
16 * Copyright (c) 2011 by Nikita Popov
17 *
18 * Some rights reserved.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are
22 * met:
23 *
24 * * Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 *
27 * * Redistributions in binary form must reproduce the above
28 * copyright notice, this list of conditions and the following
29 * disclaimer in the documentation and/or other materials provided
30 * with the distribution.
31 *
32 * * The names of the contributors may not be used to endorse or
33 * promote products derived from this software without specific
34 * prior written permission.
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 */
48 /** @internal */
49 class PhpStringTokenParser
50 {
51 protected static $replacements = ['\\' => '\\', '$' => '$', 'n' => "\n", 'r' => "\r", 't' => "\t", 'f' => "\f", 'v' => "\v", 'e' => "\x1b"];
52 /**
53 * Parses a string token.
54 *
55 * @param string $str String token content
56 */
57 public static function parse(string $str) : string
58 {
59 $bLength = 0;
60 if ('b' === $str[0]) {
61 $bLength = 1;
62 }
63 if ('\'' === $str[$bLength]) {
64 return \str_replace(['\\\\', '\\\''], ['\\', '\''], \substr($str, $bLength + 1, -1));
65 } else {
66 return self::parseEscapeSequences(\substr($str, $bLength + 1, -1), '"');
67 }
68 }
69 /**
70 * Parses escape sequences in strings (all string types apart from single quoted).
71 *
72 * @param string $str String without quotes
73 * @param string|null $quote Quote type
74 */
75 public static function parseEscapeSequences(string $str, string $quote = null) : string
76 {
77 if (null !== $quote) {
78 $str = \str_replace('\\' . $quote, $quote, $str);
79 }
80 return \preg_replace_callback('~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~', [__CLASS__, 'parseCallback'], $str);
81 }
82 private static function parseCallback(array $matches) : string
83 {
84 $str = $matches[1];
85 if (isset(self::$replacements[$str])) {
86 return self::$replacements[$str];
87 } elseif ('x' === $str[0] || 'X' === $str[0]) {
88 return \chr(\hexdec($str));
89 } else {
90 return \chr(\octdec($str));
91 }
92 }
93 /**
94 * Parses a constant doc string.
95 *
96 * @param string $startToken Doc string start token content (<<<SMTHG)
97 * @param string $str String token content
98 */
99 public static function parseDocString(string $startToken, string $str) : string
100 {
101 // strip last newline (thanks tokenizer for sticking it into the string!)
102 $str = \preg_replace('~(\\r\\n|\\n|\\r)$~', '', $str);
103 // nowdoc string
104 if (\str_contains($startToken, '\'')) {
105 return $str;
106 }
107 return self::parseEscapeSequences($str, null);
108 }
109 }
110