From dac149617c48a405c83da7ce33dc32369a0fa439 Mon Sep 17 00:00:00 2001 From: Jose' Pedro Saraiva Date: Fri, 20 Oct 2023 09:49:55 +0200 Subject: [PATCH] Fix PHP 8.2 deprecation and bump min PHP version --- .gitignore | 1 + composer.json | 56 ++++++++++++++-------------- lib/PayPal/Common/ReflectionUtil.php | 17 +++------ 3 files changed, 34 insertions(+), 40 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a09c56d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea diff --git a/composer.json b/composer.json index a0b6f39..36d0f97 100644 --- a/composer.json +++ b/composer.json @@ -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/" + } + } +} diff --git a/lib/PayPal/Common/ReflectionUtil.php b/lib/PayPal/Common/ReflectionUtil.php index f7b397a..c661934 100644 --- a/lib/PayPal/Common/ReflectionUtil.php +++ b/lib/PayPal/Common/ReflectionUtil.php @@ -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 @@ -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); } }