From 1a3184608f60874af5aabb30825938d8f8332445 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sun, 12 Apr 2026 22:43:34 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20address=20PR=20#781=20review=20feedback?= =?UTF-8?q?=20=E2=80=94=20restore=20param=20types=20and=20fix=20return=20t?= =?UTF-8?q?ype=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restores parameter type declarations that were incorrectly removed in PR #781: - Base_Gateway::verify_and_complete_payment() — restore int $payment_id - Base_Gateway::redirect_with_error() — restore string $message - Capability_Module::supports() — restore string $feature PHP contravariance rule: if a parent/interface has untyped parameters, child classes cannot declare narrower types (e.g. int) without a fatal 'Declaration must be compatible' error. Keeping types in the parent allows addons to use matching types safely. Also removes remaining missed return type declarations from extensible classes: - CPanel_Host_Provider::detect() — remove : bool - CPanel_Host_Provider::get_site_url() — remove : string - Cloudflare_Host_Provider::detect() — remove : bool PHPDoc fix: - Billing_Info_Element::output() — @return void (was incorrectly @return string) Documentation fix (AGENTS.md): - Expand scope from inc/checkout/signup-fields/ to inc/checkout/ to match the actual guideline (all checkout classes, not just signup-fields subdir) Closes #809 --- AGENTS.md | 2 +- inc/gateways/class-base-gateway.php | 4 ++-- .../host-providers/class-cloudflare-host-provider.php | 2 +- .../host-providers/class-cpanel-host-provider.php | 4 ++-- inc/integrations/interface-capability-module.php | 2 +- inc/ui/class-billing-info-element.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c4b3e044b..9c78bd3c5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -91,7 +91,7 @@ assets/ # JS, CSS, images, fonts classes or interfaces** — external addons extend these classes and PHP will fatal if the child class doesn't declare the same return type. Use `@return` PHPDoc tags instead. This applies to all classes in `inc/gateways/`, `inc/ui/class-base-element.php`, - `inc/models/class-base-model.php`, `inc/integrations/`, and `inc/checkout/signup-fields/`. + `inc/models/class-base-model.php`, `inc/integrations/`, and `inc/checkout/`. Private and final methods may use PHP return types freely. - **PHPDoc**: Required on classes and public methods in `inc/`. Not required in `tests/`. Every file header: `@package WP_Ultimo`, `@subpackage`, `@since`. diff --git a/inc/gateways/class-base-gateway.php b/inc/gateways/class-base-gateway.php index 65cf58bb5..a03981b5a 100644 --- a/inc/gateways/class-base-gateway.php +++ b/inc/gateways/class-base-gateway.php @@ -594,7 +594,7 @@ public function supports_payment_polling() { * @param int $payment_id The local payment ID to verify. * @return array{success: bool, status: string, message: string} */ - public function verify_and_complete_payment($payment_id) { + public function verify_and_complete_payment(int $payment_id) { unset($payment_id); @@ -823,7 +823,7 @@ public function get_confirm_url() { * @param string $message The error message. * @return void */ - public function redirect_with_error($message) { + public function redirect_with_error(string $message) { $url = remove_query_arg(['wu-confirm', 'payment', 'token', 'PayerID', 'ba_token', 'subscription_id', 'status'], $this->return_url ?: wu_get_current_url()); diff --git a/inc/integrations/host-providers/class-cloudflare-host-provider.php b/inc/integrations/host-providers/class-cloudflare-host-provider.php index 3e373fd7e..acf404baa 100644 --- a/inc/integrations/host-providers/class-cloudflare-host-provider.php +++ b/inc/integrations/host-providers/class-cloudflare-host-provider.php @@ -144,7 +144,7 @@ public function add_cloudflare_dns_entries($dns_records, $domain) { * * @since 2.0.0 */ - public function detect(): bool { + public function detect() { /** * As Cloudflare recently enabled wildcards for all customers, this integration is no longer required. * https://blog.cloudflare.com/wildcard-proxy-for-everyone/ diff --git a/inc/integrations/host-providers/class-cpanel-host-provider.php b/inc/integrations/host-providers/class-cpanel-host-provider.php index 929bdbf1b..12e83afe6 100644 --- a/inc/integrations/host-providers/class-cpanel-host-provider.php +++ b/inc/integrations/host-providers/class-cpanel-host-provider.php @@ -97,7 +97,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { * * @since 2.0.0 */ - public function detect(): bool { + public function detect() { return false; } @@ -262,7 +262,7 @@ public function load_api() { * @since 1.6.2 * @param null|int $site_id The site id. */ - public function get_site_url($site_id = null): string { + public function get_site_url($site_id = null) { return trim(preg_replace('#^https?://#', '', get_site_url($site_id)), '/'); } diff --git a/inc/integrations/interface-capability-module.php b/inc/integrations/interface-capability-module.php index 4107bec5b..2741ded2e 100644 --- a/inc/integrations/interface-capability-module.php +++ b/inc/integrations/interface-capability-module.php @@ -56,7 +56,7 @@ public function get_supported_features(); * @param string $feature Feature identifier to check. * @return bool */ - public function supports($feature); + public function supports(string $feature); /** * Registers WordPress hooks for this capability. diff --git a/inc/ui/class-billing-info-element.php b/inc/ui/class-billing-info-element.php index 1f8da7b74..e073b7b2c 100644 --- a/inc/ui/class-billing-info-element.php +++ b/inc/ui/class-billing-info-element.php @@ -266,7 +266,7 @@ public function setup_preview() { * * @param array $atts Parameters of the block/shortcode. * @param string|null $content The content inside the shortcode. - * @return string + * @return void */ public function output($atts, $content = null) {