From ea81951228160c9d9e817ac61053b73406f4cc9b Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 7 Jan 2025 15:58:57 +0100 Subject: [PATCH] Fix cs, composer update --- composer.lock | 38 +++++++------------ src/Gateway/GatewayModule.php | 2 - src/Gateway/MolliePaymentGatewayHandler.php | 2 +- src/Gateway/inc/services.php | 8 ++-- src/Payment/MollieSubscription.php | 2 +- src/Payment/PaymentProcessor.php | 5 ++- .../AddCustomRequestFieldsMiddleware.php | 2 +- .../Request/Middleware/MiddlewareHandler.php | 6 +-- .../Middleware/RequestMiddlewareInterface.php | 4 +- .../OrderInstructionsManager.php | 7 ++-- .../BillieFieldsStrategy.php | 4 +- .../CreditcardFieldsStrategy.php | 1 - 12 files changed, 35 insertions(+), 46 deletions(-) diff --git a/composer.lock b/composer.lock index 23ed66a9..ecefdabf 100644 --- a/composer.lock +++ b/composer.lock @@ -199,16 +199,6 @@ "type": "zip", "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/b6e9848e4893d1d306fba54da3ac6f4a31a40368", "reference": "b6e9848e4893d1d306fba54da3ac6f4a31a40368", - "version": "v2.75.0", - "source": { - "type": "git", - "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "ac2052855c631b90092768cf6657f6d5b2f5dd9f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/ac2052855c631b90092768cf6657f6d5b2f5dd9f", - "reference": "ac2052855c631b90092768cf6657f6d5b2f5dd9f", "shasum": "" }, "require": { @@ -285,10 +275,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - - "source": "https://github.com/mollie/mollie-api-php/tree/v2.75.0" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.76.0" }, - "time": "2024-11-21T10:33:16+00:00" + "time": "2024-12-18T12:26:03+00:00" }, { "name": "psr/container", @@ -2361,16 +2350,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.0", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { @@ -2419,9 +2408,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2024-11-12T11:25:25+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3690,16 +3679,16 @@ }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.21", + "version": "v2.11.22", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "eb2b351927098c24860daa7484e290d3eed693be" + "reference": "ffb6f16c6033ec61ed84446b479a31d6529f0eb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/eb2b351927098c24860daa7484e290d3eed693be", - "reference": "eb2b351927098c24860daa7484e290d3eed693be", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/ffb6f16c6033ec61ed84446b479a31d6529f0eb7", + "reference": "ffb6f16c6033ec61ed84446b479a31d6529f0eb7", "shasum": "" }, "require": { @@ -3711,7 +3700,6 @@ "phpcsstandards/phpcsdevcs": "^1.1", "phpstan/phpstan": "^1.7", "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0 || ^10.5.32 || ^11.3.3", - "sirbrillig/phpcs-import-detection": "^1.1", "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0" }, "type": "phpcodesniffer-standard", @@ -3744,7 +3732,7 @@ "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2024-12-02T16:37:49+00:00" + "time": "2025-01-06T17:54:24+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 7143da94..b42107d2 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -93,7 +93,6 @@ static function ($gateways) use ($container) { 30 ); - // Disable SEPA as payment option in WooCommerce checkout add_filter( 'woocommerce_available_payment_gateways', @@ -188,7 +187,6 @@ static function ($paymentContext) { return $fields; }, 10, 3); - return true; } diff --git a/src/Gateway/MolliePaymentGatewayHandler.php b/src/Gateway/MolliePaymentGatewayHandler.php index de26f862..1473714d 100644 --- a/src/Gateway/MolliePaymentGatewayHandler.php +++ b/src/Gateway/MolliePaymentGatewayHandler.php @@ -36,7 +36,7 @@ class MolliePaymentGatewayHandler /** * @var PaymentMethodI */ - public $paymentMethod; + protected PaymentMethodI $paymentMethod; /** * @var string */ diff --git a/src/Gateway/inc/services.php b/src/Gateway/inc/services.php index 9129d8dc..49d76530 100644 --- a/src/Gateway/inc/services.php +++ b/src/Gateway/inc/services.php @@ -285,7 +285,7 @@ $deprecatedGatewayHelper = $oldGatewayInstances[$gatewayId]; add_action( 'woocommerce_thankyou_' . $paymentGateway->id, - function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { + static function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { $order = wc_get_order($order_id); // Order not found @@ -318,7 +318,7 @@ function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGate $deprecatedGatewayHelper = $oldGatewayInstances[$gatewayId]; add_action( 'woocommerce_email_after_order_table', - function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { + static function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { $instructionsManager->displayInstructions( $paymentGateway, $deprecatedGatewayHelper, @@ -333,7 +333,7 @@ function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $payme add_action( 'woocommerce_email_order_meta', - function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { + static function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) { $instructionsManager->displayInstructions( $paymentGateway, $deprecatedGatewayHelper, @@ -354,7 +354,7 @@ function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $payme if ($paymentGateway->supports('subscriptions')) { add_filter( $pluginId . '_is_subscription_payment', - function ($isSubscription, $orderId) use ($pluginId, $dataHelper) { + static function ($isSubscription, $orderId) use ($pluginId, $dataHelper) { if ($dataHelper->isWcSubscription($orderId)) { add_filter( $pluginId . '_is_automatic_payment_disabled', diff --git a/src/Payment/MollieSubscription.php b/src/Payment/MollieSubscription.php index 6bf7515e..8d9707af 100644 --- a/src/Payment/MollieSubscription.php +++ b/src/Payment/MollieSubscription.php @@ -93,7 +93,7 @@ protected function getRecurringPaymentDescription($order, $option, $initialPayme $middleware = new PaymentDescriptionMiddleware($this->dataHelper); $requestData = []; $context = 'payment'; - $result = $middleware->__invoke($requestData, $order, $context, function($requestData) { + $result = $middleware->__invoke($requestData, $order, $context, static function ($requestData) { return $requestData; }); return $result['description']; diff --git a/src/Payment/PaymentProcessor.php b/src/Payment/PaymentProcessor.php index 412ed5ac..db09eff0 100644 --- a/src/Payment/PaymentProcessor.php +++ b/src/Payment/PaymentProcessor.php @@ -87,8 +87,9 @@ public function __construct( public function setGatewayHelper(string $paymentGatewayId) { - $this->deprecatedGatewayHelper = $this->deprecatedGatewayInstances[$paymentGatewayId]??false; + $this->deprecatedGatewayHelper = $this->deprecatedGatewayInstances[$paymentGatewayId] ?? false; } + public function setGateway(PaymentGateway $gateway) { $this->gateway = $gateway; @@ -99,7 +100,7 @@ public function processPayment($order, $paymentGateway): array $orderId = $order->get_id(); $this->setGateway($paymentGateway); $this->setGatewayHelper($paymentGateway->id); - if($this->deprecatedGatewayHelper === false){ + if ($this->deprecatedGatewayHelper === false) { return ['result' => 'failure']; } diff --git a/src/Payment/Request/Middleware/AddCustomRequestFieldsMiddleware.php b/src/Payment/Request/Middleware/AddCustomRequestFieldsMiddleware.php index 2ac3de1a..5cab99f3 100644 --- a/src/Payment/Request/Middleware/AddCustomRequestFieldsMiddleware.php +++ b/src/Payment/Request/Middleware/AddCustomRequestFieldsMiddleware.php @@ -52,7 +52,7 @@ public function __invoke(array $requestData, WC_Order $order, $context, $next): if (class_exists($middlewareClass)) { $middleware = $this->container->get($middlewareClass); if ($middleware instanceof RequestMiddlewareInterface) { - $requestData = $middleware->__invoke($requestData, $order); + $requestData = $middleware->__invoke($requestData, $order, $context, $next); } } } diff --git a/src/Payment/Request/Middleware/MiddlewareHandler.php b/src/Payment/Request/Middleware/MiddlewareHandler.php index 1a733825..61aae086 100644 --- a/src/Payment/Request/Middleware/MiddlewareHandler.php +++ b/src/Payment/Request/Middleware/MiddlewareHandler.php @@ -54,12 +54,12 @@ private function createMiddlewareChain(array $middlewares): callable { return array_reduce( array_reverse($middlewares), - function ($next, $middleware) { - return function ($requestData, $order, $context) use ($middleware, $next) { + static function ($next, $middleware) { + return static function ($requestData, $order, $context) use ($middleware, $next) { return $middleware($requestData, $order, $context, $next); }; }, - function ($requestData) { + static function ($requestData) { return $requestData; } ); diff --git a/src/Payment/Request/Middleware/RequestMiddlewareInterface.php b/src/Payment/Request/Middleware/RequestMiddlewareInterface.php index 52e595f6..4916d9d4 100644 --- a/src/Payment/Request/Middleware/RequestMiddlewareInterface.php +++ b/src/Payment/Request/Middleware/RequestMiddlewareInterface.php @@ -9,11 +9,11 @@ interface RequestMiddlewareInterface /** * Invoke the middleware. * - * @param array $requestData The request data to be modified. + * @param array $requestData The request data to be modified. * @param WC_Order $order The WooCommerce order object. * @param string $context Additional context for the middleware. * @param callable $next The next middleware to be called. - * @return array The modified request data. + * @return array The modified request data. */ public function __invoke(array $requestData, WC_Order $order, string $context, callable $next): array; } diff --git a/src/PaymentMethods/InstructionStrategies/OrderInstructionsManager.php b/src/PaymentMethods/InstructionStrategies/OrderInstructionsManager.php index b7b06918..e8f39fb5 100644 --- a/src/PaymentMethods/InstructionStrategies/OrderInstructionsManager.php +++ b/src/PaymentMethods/InstructionStrategies/OrderInstructionsManager.php @@ -48,6 +48,7 @@ public function displayInstructions( $admin_instructions = false, $plain_text = false ) { + if ( ($admin_instructions && !self::$alreadyDisplayedAdminInstructions) || (!$admin_instructions && !self::$alreadyDisplayedCustomerInstructions) @@ -55,18 +56,18 @@ public function displayInstructions( $order_payment_method = $order->get_payment_method(); // Invalid gateway - if ($deprecatedGatewayHelper->id !== $order_payment_method) { + if ($paymentGateway->id !== $order_payment_method) { return; } $payment = $deprecatedGatewayHelper->paymentObject()->getActiveMolliePayment( $order->get_id() ); - + $methodId = str_replace('mollie_wc_gateway_', '', $paymentGateway->id); // Mollie payment not found or invalid gateway if ( !$payment - || $payment->method !== $deprecatedGatewayHelper->paymentMethod->getProperty('id') + || $payment->method !== $methodId ) { return; } diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php index ea8e8842..adda4a40 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php @@ -10,7 +10,9 @@ class BillieFieldsStrategy extends AbstractPaymentFieldsRenderer implements Paym { const FIELD_COMPANY = "billing_company"; - public function renderFields(): string { + public function renderFields(): string + { + $showCompanyField = false; if (is_checkout_pay_page()) { diff --git a/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php index ba239091..aaa58656 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php @@ -14,7 +14,6 @@ public function renderFields(): string if (!$this->isMollieComponentsEnabled($this->deprecatedHelperGateway->paymentMethod())) { return ''; } - $this->deprecatedHelperGateway->has_fields = true; $allowedHtml = $this->svgAllowedHtml(); $output = '
';