Skip to content

Commit 5b1d69f

Browse files
committed
improved phpCode::convertString
1 parent 5d6597b commit 5b1d69f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Extractors/PhpCode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ public static function fromString($string, Translations $translations = null, $f
5656
*/
5757
public static function convertString($value)
5858
{
59+
if (strpos($value, '\\') === false) {
60+
return substr($value, 1, -1);
61+
}
62+
5963
if ($value[0] === "'") {
6064
return strtr(substr($value, 1, -1), array('\\\\' => '\\', '\\\'' => '\''));
6165
}
6266

6367
$value = substr($value, 1, -1);
6468

6569
return preg_replace_callback('/\\\(n|r|t|v|e|f|\$|"|\\\|x[0-9A-Fa-f]{1,2}|u{[0-9a-f]{1,6}}|[0-7]{1,3})/', function ($match) {
66-
switch ($match[1]) {
70+
switch ($match[1][0]) {
6771
case 'n':
6872
return "\n";
6973
case 'r':
@@ -82,17 +86,13 @@ public static function convertString($value)
8286
return '"';
8387
case '\\':
8488
return '\\';
85-
}
86-
87-
switch ($match[1][0]) {
8889
case 'x':
8990
return chr(hexdec(substr($match[0], 1)));
90-
9191
case 'u':
9292
return self::unicodeChar(hexdec(substr($match[0], 1)));
93+
default:
94+
return chr(octdec($match[0]));
9395
}
94-
95-
return chr(octdec($match[0]));
9696
}, $value);
9797
}
9898

0 commit comments

Comments
 (0)