From 3226f14bf4d924dfc57e0213fd474333834ac686 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Wed, 24 Dec 2025 11:41:10 +0200 Subject: [PATCH 1/2] Work around PHPStan bug for constants from function return values --- phpstan-baseline.neon | 174 +------------------------- phpstan-stubs/wc_stripe_constants.php | 21 ++++ 2 files changed, 27 insertions(+), 168 deletions(-) create mode 100644 phpstan-stubs/wc_stripe_constants.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 33eadafed3..ed1314d4b4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -132,12 +132,6 @@ parameters: count: 2 path: includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php - - message: '#^Method WC_Stripe_Payment_Gateway_Voucher\:\:can_refund_order\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -1026,12 +1020,6 @@ parameters: count: 3 path: includes/abstracts/abstract-wc-stripe-payment-gateway.php - - - message: '#^Constant WC_STRIPE_PLUGIN_URL not found\.$#' - identifier: constant.notFound - count: 20 - path: includes/abstracts/abstract-wc-stripe-payment-gateway.php - - message: '#^Default value of the parameter \#4 \$previous_error \(false\) of method WC_Stripe_Payment_Gateway\:\:process_subscription_payment\(\) is incompatible with type object\.$#' identifier: parameter.defaultValue @@ -2778,12 +2766,6 @@ parameters: count: 1 path: includes/admin/class-wc-stripe-admin-notices.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/admin/class-wc-stripe-amazon-pay-controller.php - - message: '#^Method WC_Stripe_Amazon_Pay_Controller\:\:admin_options\(\) has no return type specified\.$#' identifier: missingType.return @@ -2862,12 +2844,6 @@ parameters: count: 2 path: includes/admin/class-wc-stripe-inbox-notes.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 4 - path: includes/admin/class-wc-stripe-inbox-notes.php - - message: '#^Method WC_Stripe_Inbox_Notes\:\:are_inbox_notes_supported\(\) has no return type specified\.$#' identifier: missingType.return @@ -2928,12 +2904,6 @@ parameters: count: 1 path: includes/admin/class-wc-stripe-inbox-notes.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/admin/class-wc-stripe-payment-gateways-controller.php - - message: '#^Method WC_Stripe_Payment_Gateways_Controller\:\:enqueue_payments_scripts\(\) has no return type specified\.$#' identifier: missingType.return @@ -2952,12 +2922,6 @@ parameters: count: 1 path: includes/admin/class-wc-stripe-payment-gateways-controller.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/admin/class-wc-stripe-payment-requests-controller.php - - message: '#^Method WC_Stripe_Payment_Requests_Controller\:\:admin_options\(\) has no return type specified\.$#' identifier: missingType.return @@ -3144,12 +3108,6 @@ parameters: count: 1 path: includes/admin/class-wc-stripe-rest-oc-setting-toggle-controller.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 2 - path: includes/admin/class-wc-stripe-rest-upe-flag-toggle-controller.php - - message: '#^Method WC_Stripe_REST_UPE_Flag_Toggle_Controller\:\:register_routes\(\) has no return type specified\.$#' identifier: missingType.return @@ -3180,12 +3138,6 @@ parameters: count: 2 path: includes/admin/class-wc-stripe-settings-controller.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/admin/class-wc-stripe-settings-controller.php - - message: '#^Method WC_Stripe_Settings_Controller\:\:admin_options\(\) has no return type specified\.$#' identifier: missingType.return @@ -4452,18 +4404,6 @@ parameters: count: 1 path: includes/class-wc-stripe-blocks-support.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 2 - path: includes/class-wc-stripe-blocks-support.php - - - - message: '#^Constant WC_STRIPE_PLUGIN_URL not found\.$#' - identifier: constant.notFound - count: 10 - path: includes/class-wc-stripe-blocks-support.php - - message: '#^Method WC_Stripe_Blocks_Support\:\:__construct\(\) has parameter \$express_checkout_configuration with no type specified\.$#' identifier: missingType.parameter @@ -7125,12 +7065,6 @@ parameters: count: 1 path: includes/class-wc-stripe.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 125 - path: includes/class-wc-stripe.php - - message: '#^Method WC_Stripe\:\:add_gateways\(\) has no return type specified\.$#' identifier: missingType.return @@ -8097,6 +8031,12 @@ parameters: count: 1 path: includes/connect/class-wc-stripe-connect.php + - + message: '#^Constant WC_Stripe_Express_Checkout_Button_States\:\:STATES type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: includes/constants/class-wc-stripe-express-checkout-button-states.php + - message: '#^Constant WC_Stripe_Intent_Status\:\:SUCCESSFUL_STATUSES type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -8607,12 +8547,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-alipay.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-alipay.php - - message: '#^Method WC_Gateway_Stripe_Alipay\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -8745,12 +8679,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-bancontact.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-bancontact.php - - message: '#^Method WC_Gateway_Stripe_Bancontact\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -8979,12 +8907,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-eps.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-eps.php - - message: '#^Method WC_Gateway_Stripe_Eps\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -9117,12 +9039,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-giropay.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-giropay.php - - message: '#^Method WC_Gateway_Stripe_Giropay\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -9255,12 +9171,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-ideal.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-ideal.php - - message: '#^Method WC_Gateway_Stripe_Ideal\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -9429,12 +9339,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-multibanco.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-multibanco.php - - message: '#^Method WC_Gateway_Stripe_Multibanco\:\:email_instructions\(\) has no return type specified\.$#' identifier: missingType.return @@ -9663,12 +9567,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-p24.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-p24.php - - message: '#^Method WC_Gateway_Stripe_P24\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -9795,12 +9693,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-sepa.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-sepa.php - - message: '#^Method WC_Gateway_Stripe_Sepa\:\:form\(\) has no return type specified\.$#' identifier: missingType.return @@ -9987,12 +9879,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-gateway-stripe-sofort.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-gateway-stripe-sofort.php - - message: '#^Method WC_Gateway_Stripe_Sofort\:\:get_supported_currency\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -10119,12 +10005,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php - - message: '#^Method WC_Stripe_Express_Checkout_Ajax_Handler\:\:ajax_add_to_cart\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -10359,18 +10239,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-stripe-express-checkout-element.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-stripe-express-checkout-element.php - - - - message: '#^Constant WC_STRIPE_PLUGIN_URL not found\.$#' - identifier: constant.notFound - count: 2 - path: includes/payment-methods/class-wc-stripe-express-checkout-element.php - - message: '#^Method WC_Stripe_Express_Checkout_Element\:\:add_order_meta\(\) has parameter \$posted_data with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -10641,12 +10509,6 @@ parameters: count: 2 path: includes/payment-methods/class-wc-stripe-express-checkout-helper.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 3 - path: includes/payment-methods/class-wc-stripe-express-checkout-helper.php - - message: '#^Method WC_Stripe_Express_Checkout_Helper\:\:build_display_items\(\) has no return type specified\.$#' identifier: missingType.return @@ -11229,12 +11091,6 @@ parameters: count: 3 path: includes/payment-methods/class-wc-stripe-payment-request.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 3 - path: includes/payment-methods/class-wc-stripe-payment-request.php - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -12057,18 +11913,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-stripe-upe-payment-gateway.php - - - message: '#^Constant WC_STRIPE_PLUGIN_PATH not found\.$#' - identifier: constant.notFound - count: 2 - path: includes/payment-methods/class-wc-stripe-upe-payment-gateway.php - - - - message: '#^Constant WC_STRIPE_PLUGIN_URL not found\.$#' - identifier: constant.notFound - count: 2 - path: includes/payment-methods/class-wc-stripe-upe-payment-gateway.php - - message: '#^Method WC_Stripe_UPE_Payment_Gateway\:\:add_bnpl_debug_metadata\(\) has parameter \$metadata with no type specified\.$#' identifier: missingType.parameter @@ -14361,12 +14205,6 @@ parameters: count: 1 path: includes/payment-methods/class-wc-stripe-upe-payment-method-acss.php - - - message: '#^Constant WC_STRIPE_PLUGIN_URL not found\.$#' - identifier: constant.notFound - count: 1 - path: includes/payment-methods/class-wc-stripe-upe-payment-method-afterpay-clearpay.php - - message: '#^Method WC_Stripe_UPE_Payment_Method_Afterpay_Clearpay\:\:get_title\(\) has parameter \$payment_details with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue diff --git a/phpstan-stubs/wc_stripe_constants.php b/phpstan-stubs/wc_stripe_constants.php new file mode 100644 index 0000000000..11a12ef983 --- /dev/null +++ b/phpstan-stubs/wc_stripe_constants.php @@ -0,0 +1,21 @@ + Date: Wed, 24 Dec 2025 11:42:34 +0200 Subject: [PATCH 2/2] Changelog --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 8f45e5bdfd..886f70146f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -17,6 +17,7 @@ * Fix - Update Ukraine state mapping list * Fix - Use same default locations for Amazon Pay express checkout * Dev - Add configuration and workflow for PHPStan +* Dev - Improve PHPStan handling of plugin constants = 10.2.0 - 2025-12-08 = * Dev - Refactor display logic for payment method issue pills diff --git a/readme.txt b/readme.txt index 4faee16c9d..d33ad37413 100644 --- a/readme.txt +++ b/readme.txt @@ -156,5 +156,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Fix - Update Ukraine state mapping list * Fix - Use same default locations for Amazon Pay express checkout * Dev - Add configuration and workflow for PHPStan +* Dev - Improve PHPStan handling of plugin constants [See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).