mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Anonymize some callbacks
This commit is contained in:
parent
9d42e4a2e2
commit
5d1e3be7d4
@ -78,23 +78,21 @@ class String_ extends Scalar
|
||||
|
||||
return preg_replace_callback(
|
||||
'~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
|
||||
array(__CLASS__, 'parseCallback'),
|
||||
function($matches) {
|
||||
$str = $matches[1];
|
||||
|
||||
if (isset(self::$replacements[$str])) {
|
||||
return self::$replacements[$str];
|
||||
} elseif ('x' === $str[0] || 'X' === $str[0]) {
|
||||
return chr(hexdec($str));
|
||||
} else {
|
||||
return chr(octdec($str));
|
||||
}
|
||||
},
|
||||
$str
|
||||
);
|
||||
}
|
||||
|
||||
private static function parseCallback($matches) {
|
||||
$str = $matches[1];
|
||||
|
||||
if (isset(self::$replacements[$str])) {
|
||||
return self::$replacements[$str];
|
||||
} elseif ('x' === $str[0] || 'X' === $str[0]) {
|
||||
return chr(hexdec($str));
|
||||
} else {
|
||||
return chr(octdec($str));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
|
@ -17,7 +17,9 @@ abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
// evaluate @@{expr}@@ expressions
|
||||
$fileContents = preg_replace_callback(
|
||||
'/@@\{(.*?)\}@@/',
|
||||
array($this, 'evalCallback'),
|
||||
function($matches) {
|
||||
return eval('return ' . $matches[1] . ';');
|
||||
},
|
||||
$fileContents
|
||||
);
|
||||
|
||||
@ -36,10 +38,6 @@ abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
return $tests;
|
||||
}
|
||||
|
||||
protected function evalCallback($matches) {
|
||||
return eval('return ' . $matches[1] . ';');
|
||||
}
|
||||
|
||||
protected function canonicalize($str) {
|
||||
// trim from both sides
|
||||
$str = trim($str);
|
||||
|
Loading…
Reference in New Issue
Block a user