wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

PHP 7.0+ warning with __fs in SDK: double underscore prefix for method names reserved

Open presswizards opened this issue 8 years ago • 5 comments

Actual Behavior:

  • What is the issue? (*) PHP v7 warnings in SDK
  • What is the expected behavior? No warnings

From a recent support thread regarding SDK and PHP 7.0:

PHP 7 warning: Function name “__fs” is discouraged; PHP has reserved all method names with a double underscore prefix for future use

"Ran the PHP 7.0 Compatibility Checker plugin that can be found here https://wordpress.org/plugins/php-compatibility-checker/

FILE: …./wp-content/plugins/pluginname/includes/freemius/includes/fs-essential-functions.php ——————————————————————————————————————————————— FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE ——————————————————————————————————————————————— 165 | WARNING | Function name “__fs” is discouraged; PHP has reserved all method names with a double underscore prefix for future use ———————————————————————————————————————————————

presswizards avatar Mar 01 '17 06:03 presswizards

+1

bfintal avatar Mar 09 '17 01:03 bfintal

We are working on this.

vovafeldman avatar Jun 22 '17 19:06 vovafeldman

+1 plugin users raising support issues on this

alanef avatar Oct 19 '17 18:10 alanef

@vovafeldman what about using PHP magic methods to remove this now? The following during my testing won't trigger PHP 7 notices, but should theoretically work the same.

public function __call( $method, $args ) {
    if ( $method == '__fs' ) {
        // Do translation here.
    }
}

For reference: http://php.net/manual/en/language.oop5.overloading.php#object.call

danieliser avatar Feb 10 '18 02:02 danieliser

@danieliser as far as I know magic methods are for classes, the __fs() is a global function, not a class' method.

vovafeldman avatar Dec 30 '18 08:12 vovafeldman