Skip to content
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

YoastCS: add dependency on PHPCSUtils and start using it #322

Merged
merged 4 commits into from
Nov 3, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Nov 3, 2023

Composer: add dependency on PHPCSUtils

By starting to use PHPCSUtils, we make YoastCS less dependent on WordPressCS.
PHPCSUtils brings added benefits of more stable, thoroughly tested utility methods, which all support modern PHP.

Along those lines, the utility functions in PHPCSUtils which mirror PHPCS native utility functions are generally compatible with new PHP syntaxes well before there is a PHPCS release available with such support for these utility functions.

This commit adds the dependency and updates relevant documentation and CI.

Includes removing the explicit dependency on the Composer PHPCS Installer plugin. This dependency will now be inherited from PHPCSUtils.
Letting PHPCSUtils manage the supported versions prevents conflicts.

Closes #157

YoastCS: add PHPCSUtils requirement

PHPCSUtils does not contain any sniffs, so adding this rule isn't strictly necessary, but by having the rule in the ruleset anyway, if PHPCSUtils is missing, the user will get a descriptive error message during the loading of the ruleset instead of a fatal "class not found" error once the sniffs start running.

Sniffs: switch over to using utilities from PHPCSUtils [1]

Initial switch over replacing function calls to PHPCS native utility functions with calls to the improved versions of the same in PHPCSUtils.

Sniffs: switch over to using utilities from PHPCSUtils [2]

Switch over replacing function calls to WPCS utility functions with calls to the improved versions of the same in PHPCSUtils.
These WPCS native utility functions no longer exist in WPCS 3.0.0 as WPCS is now also using PHPCSUtils.

By starting to use PHPCSUtils, we make YoastCS less dependent on WordPressCS.
PHPCSUtils brings added benefits of more stable, thoroughly tested utility methods, which all support modern PHP.

Along those lines, the utility functions in PHPCSUtils which mirror PHPCS native utility functions are generally compatible with new PHP syntaxes well before there is a PHPCS release available with such support for these utility functions.

This commit adds the dependency and updates relevant documentation and CI.

Includes removing the explicit dependency on the Composer PHPCS Installer plugin. This dependency will now be inherited from PHPCSUtils.
Letting PHPCSUtils manage the supported versions prevents conflicts.

Closes 157
PHPCSUtils does not contain any sniffs, so adding this rule isn't strictly necessary, but by having the rule in the ruleset anyway, if PHPCSUtils is missing, the user will get a descriptive error message during the loading of the ruleset instead of a fatal "class not found" error once the sniffs start running.
Initial switch over replacing function calls to PHPCS native utility functions with calls to the improved versions of the same in PHPCSUtils.
Switch over replacing function calls to WPCS utility functions with calls to the improved versions of the same in PHPCSUtils.
These WPCS native utility functions no longer exist in WPCS 3.0.0 as WPCS is now also using PHPCSUtils.
@coveralls
Copy link

Coverage Status

coverage: 97.644%. remained the same
when pulling d1d6dc6 on JRF/yoastcs-add-phpcsutils
into ea7a873 on develop.

@jrfnl jrfnl merged commit 710632b into develop Nov 3, 2023
37 checks passed
@jrfnl jrfnl deleted the JRF/yoastcs-add-phpcsutils branch November 3, 2023 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PHPCSUtils dependency and implement the use of it
2 participants