Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed preg_replace with /e modifier

switched from using preg_replace with /e as it's deprecated in 5.5 and
not supported in some environments;
while an anonymous function would work, by using create_function we can
stay 5.2 compatible
  • Loading branch information...
commit e975ffa6d434fb756b506e95632756eff5b553e6 1 parent 2202d3e
@caseysoftware authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 Services/Twilio/Resource.php
View
13 Services/Twilio/Resource.php
@@ -71,9 +71,12 @@ public function getResourceName($camelized = false)
public static function decamelize($word)
{
- return preg_replace(
+ $callback = create_function('$matches',
+ 'return strtolower(strlen("$matches[1]") ? "$matches[1]_$matches[2]" : "$matches[2]");');
+
+ return preg_replace_callback(
'/(^|[a-z])([A-Z])/e',
- 'strtolower(strlen("\\1") ? "\\1_\\2" : "\\2")',
+ $callback,
$word
);
}
@@ -87,7 +90,11 @@ public static function decamelize($word)
* @return string
*/
public static function camelize($word) {
- return preg_replace('/(^|_)([a-z])/e', 'strtoupper("\\2")', $word);
+ $callback = create_function('$matches', 'return strtoupper("$matches[2]");');
+
+ return preg_replace_callback('/(^|_)([a-z])/',
+ $callback,
+ $word);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.