Comments (11)
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 testVersion
configuration. Once WP 5.6 comes out, we can revisit this.
For your own projects, if you so choose, you can overrule the setting by using --runtime-set testVersion 5.6-
when running the sniffs from the command-line.
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.
from wpthemereview.
To anyone who finds these comments here, the solution is to create an extra xml file (test-version-override.xml
), with the contents
<?xml version="1.0"?>
<ruleset>
<config name="testVersion" value="5.6-"/>
</ruleset>
and include it after the WPThemeReview rule:
...
<rule ref="WPThemeReview"/>
<rule ref="./test-version-override.xml"/>
from wpthemereview.
I use VSCode + ikappas.phpcs
extension, which is set up to look for a phpcs.xml
in the project root, and checks/highlights errors and warnings while typing, rather than having to running the command occasionally.
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.
from wpthemereview.
The minimal version should reflect what the code needs, not what other code needs.
Or is this config for the version to be tested?
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.
from wpthemereview.
@jrfnl Is there a - dirty - workaround to support only PHP 5.3?
Thanks.
A better one than sed -e '/name="testVersion"/d' -i vendor/wptrt/wpthemereview/WPThemeReview/ruleset.xml
from wpthemereview.
Is there a - dirty - workaround to support only PHP 5.3?
@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 testVersion
from the command-line as stated above:
# 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-
from wpthemereview.
Thank you Juliette.
from wpthemereview.
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.
from wpthemereview.
squizlabs/PHP_CodeSniffer#2197
from wpthemereview.
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.
from wpthemereview.
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 composer checkcs
🙂
from wpthemereview.
Related Issues (20)
- variables in template files are flagged as global HOT 15
- Exceptions to prefixing hook names HOT 7
- False positive on loading stylesheet in JS file HOT 4
- [New sniff] WC template versions HOT 7
- Dealing with rules that shouldn't apply to templates HOT 1
- Add sniff: WordPress.PHP.IniSet HOT 6
- [New sniff] Check if page templates are using reserved prefix HOT 1
- Detect WPTRT feature project versions HOT 3
- Add sniff documentation HOT 1
- Whitelist wp_body_open function from PrefixAllGlobals sniff HOT 5
- sniff: plugin territory - action hook wp_edit_nav_menu_walker
- File name with reserved slug in subfolder HOT 11
- Optimisation and minor grammar fixes
- [Implement sniff] Warn about short ternary usage in themes HOT 9
- Internal.Exception -- function update_current_version() should be removed.
- [Update existing sniff] Allow register_block_style HOT 1
- Allow `add_menu_page` & `add_submenu_page` HOT 9
- twentyseventeen theme: posts with no date - but date is shown in similar posts HOT 1
- 👍
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wpthemereview.