Freemius / wordpress-sdk

https://freemius.com
GNU General Public License v3.0
267 stars 77 forks source link

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

Open presswizards opened 7 years ago

presswizards commented 7 years ago

Actual Behavior:

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 ———————————————————————————————————————————————

bfintal commented 7 years ago

+1

vovafeldman commented 7 years ago

We are working on this.

alanef commented 7 years ago

+1 plugin users raising support issues on this

danieliser commented 6 years ago

@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

vovafeldman commented 5 years ago

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