Fatal error - The declaration of class `Freemius_Api_WordPress` is not compatible with class `Freemius_Api_Base` from the PHP SDK
🐞 bug report
Behavior:
When a plugin loads the PHP SDK before the WordPress SDK, the class Freemius_Api_Base from the former is loaded automatically. When the class Freemius_Api_WordPress is loaded, it triggers a fatal error, because methods such as Freemius_Api_Base::Test() are declared as static in the PHP SDK, and dynamic in the WordPress SDK.
Examples
- Method
Freemius_Api_Base::Test(): https://github.com/Freemius/freemius-php-sdk/blob/master/freemius/FreemiusBase.php#L157 - Method
Freemius_Api_Base::FindClockDiff(): https://github.com/Freemius/freemius-php-sdk/blob/master/freemius/FreemiusBase.php#L170
Suggested solution
The class Freemius_Api_Base in the WordPress SDK works because it doesn't declare any of the affected methods, which are implemented by class Freemius_Api_WordPress. If the class Freemius_Api_Base is supposed to be identical between the WordPress and the PHP SDK, it might be sufficient to replace the existing code with the one from the WordPress SDK.
Versions: (*)
Freemius SDK Version:2.4.3 to 2.5.2WordPress Version:5.9 to 6.1PHP Version:8.x
Plugin / Theme: (*)
Name:AnyFreemius ID:Any
Note The plugin itself is not relevant, in this case. As long as the PHP SDK is loaded before the WordPress SDK, the error will occur.