Skip to content

Project xml file not overwriting the defined testVersion in the upstream ruleset? #7

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

Closed
dingo-d opened this issue Oct 24, 2018 · 2 comments
Labels

Comments

@dingo-d
Copy link
Contributor

dingo-d commented Oct 24, 2018

Hi!

I updated the companies ruleset to check the code against PHP 7.0 code and up, with

<!-- Check code for cross-version PHP compatibility. -->
<config name="testVersion" value="7.0-"/>
<rule ref="PHPCompatibilityWP"/>

So in my project's phpcs.xml.dist I added

<?xml version="1.0"?>
<ruleset name="My Project">

  <rule ref="Infinum" />

  <config name="testVersion" value="7.2-"/>
  <rule ref="PHPCompatibilityWP"/>

</ruleset>

because I'm actually working on PHP 7.2, and I'm using things like typehinting a void return value of a method.

The problem is that the config set in my project's ruleset is not overwritten and I'm getting errors like

error - void return type is not present in PHP version 7.0 or earlier (PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound)

Am I doing something wrong? This should be like any other rule for PHPCS.

@jrfnl jrfnl added the question label Oct 25, 2018
@jrfnl
Copy link
Member

jrfnl commented Oct 25, 2018

This is a known issue in PHPCS - see: squizlabs/PHP_CodeSniffer#1821 and squizlabs/PHP_CodeSniffer#2197

Since PHPCS 3.3.0, you can, at least, overrule the testVersion set in a ruleset by using the command line, which for now is the only solution (or use the hack described in 2197 above).
See: https://github.com/PHPCompatibility/PHPCompatibility#testversion-in-the-ruleset-versus-command-line

@dingo-d
Copy link
Contributor Author

dingo-d commented Oct 25, 2018

Oh, that's a shame. I'll wait for the fix then, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants