You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Freemius composer package causes conflict by stopping composer scripts from running as intended.
When PHPCodeSniffer is installed via composer using composer require --dev dealerdirect/phpcodesniffer-composer-installer the bin files it creates phpcbf and phpcs should be able to be referenced like this vendor/bin/phpcbf -p that will cause the library to run its behavior. However with the latest version of the SDK this doesn't work.
I reported to the PHPCodeSniffer team and they helped identify the issue. The discussion and reason for the issue can be seen here: PHPCSStandards/PHP_CodeSniffer#781
Versions: (*)
Freemius SDK Version: 2.10.1
WordPress Version: N/A
PHP Version: 8.1 (tried different versions, no difference)
The text was updated successfully, but these errors were encountered:
To add to this bug report, I see that it also affects PHP unit tests in a plugin. Previously, running the unit tests script via command line at the plugin root directory would run without any issues.
However, unit tests won't run if we load the Freemius SDK (version 2.10.1) via the composer vendor directory (autoloaded). I debugged this, and this is the issue: (start.php of Freemius SDK)
if ( ! defined( 'ABSPATH' ) ) { exit; }
The problem is that when we execute tests in a command line environment - WordPress is never loaded, ABSPATH is never defined, and the tests will terminate.
However, if you change the above line from exit to return, the test will now work. If ABSPATH is not defined, it will simply bail out and run the rest (including tests).
Proposed solution:
if ( ! defined( 'ABSPATH' ) ) { return; }
Though I'm not sure about the consequences of using return for the rest of the Freemius SDK functionalities, this change requires thorough testing if we would like to adopt this approach.
I can confirm the proposal of @codex-m solves the issue for phpstan and phpcs.
In this context, I would propose to also add typings to the default sdk script output on the ui like this:
/** * Freemius init function * * @return Freemius * @throws Freemius_Exception Thrown when an API call returns an exception. */functionmy_fs(): Freemius {
}
🐞 bug report
Behavior:
Freemius composer package causes conflict by stopping composer scripts from running as intended.
When PHPCodeSniffer is installed via composer using
composer require --dev dealerdirect/phpcodesniffer-composer-installer
the bin files it createsphpcbf
andphpcs
should be able to be referenced like thisvendor/bin/phpcbf -p
that will cause the library to run its behavior. However with the latest version of the SDK this doesn't work.I reported to the PHPCodeSniffer team and they helped identify the issue. The discussion and reason for the issue can be seen here: PHPCSStandards/PHP_CodeSniffer#781
Versions: (*)
Freemius SDK Version:
2.10.1WordPress Version:
N/APHP Version:
8.1 (tried different versions, no difference)The text was updated successfully, but these errors were encountered: