Strict Standards: Declaration of ' ' should be compatible with ' '
When upgrading a PHP environment or migrating legacy code, you often encounter the "Strict Standards" warning. In the specific case of WooCommerce 2.0 running on PHP 5.4, this manifests as a declaration incompatibility between WC_Gateway_BACS::process_payment() and its parent class WC_Payment_Gateway. The error message explicitly points out that the child method signature does not match the parent's expectations.
This is not a runtime crash; it is a PHP 5.4 feature known as Strict Standards that alerts you to potential logic errors before they cause fatal failures. In previous PHP versions (pre-5.3), PHP was lenient regarding inheritance. If a child class defined a method with different arguments than the parent, PHP would silently ignore the mismatch or apply default values implicitly. This often led to subtle bugs where data was lost or passed incorrectly deep in the call stack.
The core issue here is that WC_Gateway_BACS extends WC_Payment_Gateway. The parent class defines a method process_payment(int $order_id), but the child implementation in WooCommerce 2.0 likely declares it as process_payment($order_id) or omits the type hint entirely if the version of PHP being used treats them differently, or vice versa depending on the specific strictness level. In PHP 5.4, the engine enforces that overridden methods must be compatible with their parent signatures unless explicitly declared abstract or static in a way that bypasses this check (which isn't possible here).
To resolve this without merely suppressing errors via error_reporting(), you must inspect the method signatures in both files. Open class-wc-gateway-bacs.php and locate the process_payment method. Compare it with the definition in WC_Payment_Gateway. In WooCommerce 2.0, the parent class likely introduced a stricter signature to support new payment flow requirements, while the BACS gateway implementation hadn't been updated to match yet.
The fix involves editing the child class file to align its method declaration with the parent. If the parent is defined as:
public function process_payment($order_id) { ... }
Ensure the child class matches exactly, including visibility modifiers and argument types if PHP 5.4 is configured for strict typing (though full type hinting was a major update in PHP 7, partial enforcement existed in 5.4 depending on context). However, in many cases with WooCommerce 2.0, the issue stems from a missing static keyword or a mismatch in how arguments are handled internally by the parent class implementation changes between minor versions.
A common pitfall when seeing this warning is assuming it can be ignored. While it might not stop the script immediately, relying on legacy signatures while the parent class evolves leads to memory leaks and unexpected behavior as new features are added to the parent that expect different argument structures. The process_payment method is critical for the checkout flow; a mismatch here could silently fail to pass order data to the payment processor.
If you are maintaining this codebase, updating WooCommerce to a version compatible with your PHP 5.4 setup (if available) is the most robust solution, as newer versions will have synchronized their gateway classes. Alternatively, if you must stay on 2.0, you can patch the file to ensure the signature matches the parent's current definition.
For developers transitioning from older environments, understanding that "Strict Standards" is a precursor to fatal errors in modern PHP versions (7 and 8) is crucial. What was a warning in PHP 5.4 might be an Error or TypeError in PHP 7+. Ignoring these warnings now risks breaking your application entirely when you eventually upgrade the server runtime.
For more advanced payment gateway integrations on WordPress, ensuring that child classes strictly adhere to parent class contracts is a best practice that prevents future architectural debt. If you are looking for enterprise-grade solutions that abstract these compatibility issues away from custom development, resources like https://laravelcompany.com offer insights into building robust e-commerce backends where such signature mismatches are handled through dependency injection and strict interface definitions rather than direct class inheritance hacks.