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

PHPStan issue detected

Open Mte90 opened this issue 5 years ago • 7 comments

🐞 bug report

Run a plugin or just phpstan across this project and there will be this php warning.

Versions: (*)

  • Freemius SDK Version: last version
  • WordPress Version: whatever
  • PHP Version: 7.0+
PHP Warning:  Creating default object from empty value in /plugin-name/vendor/freemius/wordpress-sdk/start.php on line 74
Warning: Creating default object from empty value in /plugin-name/vendor/freemius/wordpress-sdk/start.php on line 74
PHP Notice:  Trying to get property 'stylesheet' of non-object in /plugin-name/vendor/freemius/wordpress-sdk/includes/fs-essential-functions.php on line 354
Notice: Trying to get property 'stylesheet' of non-object in /plugin-name/vendor/freemius/wordpress-sdk/includes/fs-essential-functions.php on line 354
PHP Deprecated:  strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /plugin-name/vendor/freemius/wordpress-sdk/start.php on line 392
Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /plugin-name/vendor/freemius/wordpress-sdk/start.php on line 392

Mte90 avatar May 28 '20 12:05 Mte90

This is very annoying...

Mte90 avatar Jun 30 '20 15:06 Mte90

Could you please update your original comment with information about your environment, as per the bug report template requirements: https://github.com/Freemius/wordpress-sdk/issues/new?template=1-bug-report.md

dgwyer avatar Jun 30 '20 15:06 dgwyer

Done

Mte90 avatar Jun 30 '20 15:06 Mte90

Thanks. Are you seeing these notices only with PHPStan?

If you're seeing them in normal plugin operation can you describe the steps so I can try to replicate?

dgwyer avatar Jun 30 '20 15:06 dgwyer

No just with phpstan so is not possible to get a clean output of this tool when is used to maintain the code quality of the plugin.

Mte90 avatar Jun 30 '20 16:06 Mte90

A user reported seeing this warning PHP Warning: Creating default object from empty value in /wp-content/plugins/video-embed-thumbnail-generator/freemius/start.php on line 74 when updating my plugin to the latest version, which includes the Freemius SDK for the first time. I haven't been able to reproduce the warning myself. They opted out of Freemius but they're concerned that it means they didn't actually opt out. I'm sure that's not what's happening but warnings during activation don't inspire confidence.

kylegilman avatar Mar 28 '21 18:03 kylegilman

The line is https://github.com/Freemius/wordpress-sdk/blob/master/start.php#L74 same line at https://github.com/Freemius/wordpress-sdk/blob/master/start.php#L98

I guess that is better to run this sdk with PHPStan to understand better the issue.

Mte90 avatar Mar 29 '21 13:03 Mte90