-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal PHP version #228
Comments
The minimal version should reflect what the code needs, not what other code needs. It doesn't make sense to bump it up if it's not needed, because those people trying to move to more recent versions may need to run the tool in order to get there. |
Themes normally support multiple versions of WordPress, so while the minimum PHP requirement for WP 5.2 is now PHP 5.6.20, for WP < 5.2, it still is PHP 5.2.6. The default presumption made by WPThemeReview is that a theme will support up to three WP versions before the current WP version. So, no, at this moment it is too early to change the default For your own projects, if you so choose, you can overrule the setting by using As for that the minimum PHP version for running WPThemeReview is PHP 5.4: that's neither here nor there. While the sniffs are designed to check code in WP Themes, for running the sniffs, there is no dependency on WordPress, only on PHP_CodeSniffer and the current version of PHP_CodeSniffer has a minimum requirement of PHP 5.4. |
@jrfnl Is there a - dirty - workaround to support only PHP 5.3? A better one than |
@szepeviktor You mean for the sniffs to run on PHP 5.3 or for your code to be tested for compatibility with PHP 5.3 ? If the former, no, PHP 5.4 is the minimum PHP version needed to run the sniffs. If the latter, you can overrule the # Only check for compatibility with PHP 5.3
phpcs . --standard=WPThemeReview --runtime-set testVersion 5.3
# Check for compatibility with PHP 5.3 and higher
phpcs . --standard=WPThemeReview --runtime-set testVersion 5.3- |
Thank you Juliette. |
Is there a way to override this in your own theme's phpcs.xml file? I've tried to include the config value in my ruleset, but it seems to be ignored. I'd love to be able to use this, but I use the file based config, not the command line. |
Seems that, currently, it's not possible to change the minimum php value from a ruleset that includes the theme review ruleset. That's super disappointing. |
To anyone who finds these comments here, the solution is to create an extra xml file (
and include it after the WPThemeReview rule:
|
This is a known bug and Juliette mentioned how to override it in her comment above. Another thing you can do is what we've done in Twenty Twenty theme: "scripts": {
"checkcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 5.6-",
"fixcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --runtime-set testVersion 5.6-",
"lint": "@php ./vendor/bin/parallel-lint --exclude .git --exclude vendor ."
}, Then run your sniffs using |
I use VSCode + Your solution is good for other workflows/environments, and especially Theme Reviewing, definitely! But if anyone needs my workaround to get their own setup working, I hope it's useful. |
https://github.com/WPTRT/WPThemeReview/blob/5a223995395a41c05c9e35cb3651f6d9e60ff786/WPThemeReview/ruleset.xml#L8
Please change minimal PHP higher than 5.2, because even minimal php for The WPThemeReview Standard is 5.4 and now for Wordpress the minimal PHP is 5.6 See:
https://wordpress.org/news/2019/04/minimum-php-version-update/
The text was updated successfully, but these errors were encountered: