Skip to content

Commit

Permalink
Replace deprecated preg_replace() with /e with preg_replace_callback().
Browse files Browse the repository at this point in the history
  • Loading branch information
LawnGnome authored and sebastianbergmann committed Dec 10, 2012
1 parent 2f08eea commit b3e92b2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions PHPUnit/Util/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ class PHPUnit_Util_XML
*/
public static function prepareString($string)
{
return preg_replace(
'([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])e',
'sprintf( "&#x%02x;", ord( "\\1" ) )',
return preg_replace_callback(
'([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])',
function ($matches)
{
return sprintf('&#x%02x;', ord($matches[1]));
},
htmlspecialchars(
PHPUnit_Util_String::convertToUtf8($string), ENT_COMPAT, 'UTF-8'
)
Expand Down

0 comments on commit b3e92b2

Please sign in to comment.