GithubHelp home page GithubHelp logo

Minimal PHP version about wpthemereview HOT 11 OPEN

zimnyd avatar zimnyd commented on July 24, 2024
Minimal PHP version

from wpthemereview.

Comments (11)

jrfnl avatar jrfnl commented on July 24, 2024 1

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.

WraithKenny avatar WraithKenny commented on July 24, 2024 1

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.

WraithKenny avatar WraithKenny commented on July 24, 2024 1

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.

joyously avatar joyously commented on July 24, 2024

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.

szepeviktor avatar szepeviktor commented on July 24, 2024

@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.

jrfnl avatar jrfnl commented on July 24, 2024

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.

szepeviktor avatar szepeviktor commented on July 24, 2024

Thank you Juliette.

from wpthemereview.

WraithKenny avatar WraithKenny commented on July 24, 2024

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.

WraithKenny avatar WraithKenny commented on July 24, 2024

squizlabs/PHP_CodeSniffer#2197

from wpthemereview.

WraithKenny avatar WraithKenny commented on July 24, 2024

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.

dingo-d avatar dingo-d commented on July 24, 2024

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:

https://github.com/WordPress/twentytwenty/blob/f257dfff755c415dadc56a2c70a412421f39aad7/composer.json#L25-L28:

"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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.