igorhrcek / wp-cli-secure-command

Secure package for WP CLI, built to provide an easier way of securing your WordPress installation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wp secure all and PHP Parse error

fschmittlein opened this issue · comments

PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /.wp-cli/packages/vendor/igor/wp_cli_secure_command/src/SubCommands/SubCommand.php on line 109

PHP 7.4.28
WP-CLI 2.6.0

That's due to the usage of types for parameter and return values which are a new feature in PHP 8.

https://github.com/igorhrcek/wp-cli-secure-command/blob/master/src/SubCommands/SubCommand.php#L109

Please try to change it from

protected function setRuleContent( bool $loadVars = true, bool|string $template = false ) : string|array {

to

protected function setRuleContent( $loadVars = true, $template = false ) {

Ideally the developers should create some CI / CD setup with linting (PHP-CLI has linting built-in) and maybe phan or phpstan.

Looks like the code was not tested on PHP 7.4. There are many more files which need the proper changes:

https://github.com/wp-cli-secure/wp-cli-secure-command/runs/5798874722?check_suite_focus=true

Someone was a bit too enthusiastic to apply PHP 8 syntax (Union Types) to a PHP 7 project:

https://github.com/igorhrcek/wp-cli-secure-command/blob/master/composer.json#L13
https://stackoverflow.com/a/37033355/753676

So no one with PHP 7 can really use it with the current code.

Someone was a bit too enthusiastic to apply PHP 8 syntax (Union Types) to a PHP 7 project:

That would be me :) but we decided to add 7.4 support during Hackaton but obviously the implementation was not finished.

However, it will be finished today.

🎉 This issue has been resolved in version 1.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀