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

Start using WordPressCS 3.1 #171

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 13, 2024

Composer: update to WordPressCS 3.

Composer:

  • No need for requiring the Composer PHPCS plugin anymore as it now comes automatically with WPCS and removing the requirement allows WPCS to manage the supported versions, preventing conflicts (and will update to the 1.0.0 version).

PHPCS ruleset:

  • Minor tweak for a replaced sniff as per the changes in WPCS 3.0.0.
  • Exclude one error code which would conflict with the minimum PHP requirement of this plugin.

Refs:

CS/QA: all methods should have visibility declared

To prevent any BC-breaks, all methods without explicit visibility have now been explicitly declared as public.

Mind: the set_up() and tear_down() methods in the tests should be protected, but as WP Core didn't always have this correct and this plugin still supports a large range of WP versions, so needs to take a large range of WP versions into account for the WP Core test framework on which the test suite is build, setting the visibility to public is the safer choice for now.

CS/QA: all properties should have visibility declared

To prevent any BC-breaks, all properties without explicit visibility have now been explicitly declared as public.

CS: always use parentheses for class instantiation

CS/QA: don't use reserved keywords as parameter names

... to prevent code getting really confusing when people would call it using PHP 8.0+ function calls with named arguments.

Modernize: use the magic DIR constant

CS/QA: miscellaneous other fixes

  • Use pre-increment instead of post-increment.
  • Use require for unconditional file includes.
  • No blank line at end of function.

Composer:
* No need for requiring the Composer PHPCS plugin anymore as it now comes automatically with WPCS and removing the requirement allows WPCS to manage the supported versions, preventing conflicts (and will update to the 1.0.0 version).

PHPCS ruleset:
* Minor tweak for a replaced sniff as per the changes in WPCS 3.0.0.
* Exclude one error code which would conflict with the minimum PHP requirement of this plugin.

Refs:
* https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0
* https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers
To prevent any BC-breaks, all methods without explicit visibility have now been explicitly declared as `public`.

Mind: the `set_up()` and `tear_down()` methods in the tests _should_ be `protected`, but as WP Core didn't always have this correct and this plugin still supports a large range of WP versions, so needs to take a large range of WP versions into account for the WP Core test framework on which the test suite is build, setting the visibility to `public` is the safer choice for now.
To prevent any BC-breaks, all properties without explicit visibility have now been explicitly declared as `public`.
... to prevent code getting really confusing when people would call it using PHP 8.0+ function calls with named arguments.
* Use pre-increment instead of post-increment.
* Use `require` for unconditional file includes.
* No blank line at end of function.
@jrfnl jrfnl force-pushed the feature/composer-update-for-wpcs-3 branch from 3d4705b to 6de1c35 Compare September 13, 2024 06:10
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.

1 participant