Skip to content

Add the PHPCompatibility PHPCS standard #32

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

Merged
merged 1 commit into from
Aug 8, 2021

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Aug 8, 2021

The PHPCompatibility standard is a set of sniffs which can scan a code base for a lot of typical PHP cross-version incompatibilities.

The standard works best when a testVersion configuration variable is set for the package using the standard.
As this standard is used by different repos with different requirements, this testVersion should be set in the repos using this standard, not in the ruleset.xml for this standard.

Now, there are several libraries available in the PHP world which offer polyfills for select PHP functionality. If any of these libraries are used, PHPCompatibility may throw false positives for polyfilled functionality.
To prevent receiving these false positives, a number of PHPCompatibility rulesets are available which each take a specific polyfill into account. These rulesets are non-conflicting and can be used in combination.

As some of the packages using this standard use these kind of polyfills, I'm adding the PHPCompatibilityAll package to ensure that all PHPCompatibility rulesets are available.

Repos using this package can then pick and choose to add any of the polyfill exclusion rulesets at will.

Refs:

The PHPCompatibility standard is a set of sniffs which can scan a code base for a lot of typical PHP cross-version incompatibilities.

The standard works best when a [`testVersion` configuration variable](https://github.com/PHPCompatibility/PHPCompatibility/#sniffing-your-code-for-compatibility-with-specific-php-versions) is set for the package using the standard.
As this standard is used by different repos with different requirements, this `testVersion` should be set in the repos _using_  this standard, not in the `ruleset.xml` for this standard.

Now, there are several libraries available in the PHP world which offer polyfills for select PHP functionality. If any of these libraries are used, PHPCompatibility may throw false positives for polyfilled functionality.
To prevent receiving these false positives, a number of PHPCompatibility rulesets are available which each take a specific polyfill into account. These rulesets are non-conflicting and can be used in combination.

As some of the packages using this standard use these kind of polyfills, I'm adding the `PHPCompatibilityAll` package to ensure that all PHPCompatibility rulesets are available.

Repos using this package can then pick and choose to add any of the polyfill exclusion rulesets at will.

Refs:
* https://github.com/PHPCompatibility/PHPCompatibility/
* https://github.com/PHPCompatibility/PHPCompatibilityAll
@jaapio
Copy link
Member

jaapio commented Aug 8, 2021

Wondering, should we set the default testVersion in this repo to 7.2? which is our default phpversion right now. for phpDocumentor libraries. And allow other repo's to overwrite the setting?

@jrfnl
Copy link
Contributor Author

jrfnl commented Aug 8, 2021

@jaapio Good question and the answer is "no". 😂

In contrast to ruleset info, config values can not be "overwritten" in project local rulesets.
Since PHPCS 3.3.0, it can be overruled from the command-line, which is already an improvement.

This is a known issue and will be changed in PHPCS 4.0, but for now, you're better off setting the value in the project local rulesets.

Refs:

@jaapio jaapio merged commit 86f1c65 into phpDocumentor:latest Aug 8, 2021
@jrfnl jrfnl deleted the feature/add-phpcompatibility branch August 8, 2021 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants