Skip to content

Commit

Permalink
Fix PHP 8.2 deprecation and bump min PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
nocive committed Oct 20, 2023
1 parent 01ee18c commit dac1496
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
56 changes: 28 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "simplesurance/paypal-rest-api-sdk-php",
"description": "PayPal's PHP SDK for REST APIs",
"keywords": ["paypal", "payments", "rest", "sdk"],
"type": "library",
"license": "Apache-2.0",
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
"authors": [
{
"name": "PayPal",
"homepage": "https://github.com/paypal/rest-api-sdk-php/contributors"
}
],
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"psr/log": "^1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"autoload": {
"psr-0": {
"PayPal": "lib/"
}
}
}
{
"name": "simplesurance/paypal-rest-api-sdk-php",
"description": "PayPal's PHP SDK for REST APIs",
"keywords": ["paypal", "payments", "rest", "sdk"],
"type": "library",
"license": "Apache-2.0",
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
"authors": [
{
"name": "PayPal",
"homepage": "https://github.com/paypal/rest-api-sdk-php/contributors"
}
],
"require": {
"php": ">=8.1.0",
"ext-curl": "*",
"ext-json": "*",
"psr/log": "^1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"autoload": {
"psr-0": {
"PayPal": "lib/"
}
}
}
17 changes: 5 additions & 12 deletions lib/PayPal/Common/ReflectionUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,6 @@ public static function propertyAnnotations($class, $propertyName)
return $annotations;
}

/**
* preg_replace_callback callback function
*
* @param $match
* @return string
*/
private static function replace_callback($match)
{
return ucwords($match[2]);
}

/**
* Returns the properly formatted getter function name based on class name and property
* Formats the property name to a standard getter function
Expand All @@ -148,8 +137,12 @@ private static function replace_callback($match)
*/
public static function getter($class, $propertyName)
{
$callback = function (array $matches) {
return ucwords($matches[2]);
};

return method_exists($class, "get" . ucfirst($propertyName)) ?
"get" . ucfirst($propertyName) :
"get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", "self::replace_callback", $propertyName);
"get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", $callback, $propertyName);
}
}

0 comments on commit dac1496

Please sign in to comment.