Require PHP_CodeSniffer 4, migrate CI to GitHub Actions (BC break, v3.0.0)#53
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the Graze PHPCS ruleset to PHP_CodeSniffer 4, dropping PHPCS 3 compatibility as a BC break for the planned v3.0.0 release.
Changes:
- Updates the PHPCS dev constraint from
^3.0to^4.0. - Converts the
ScopeIndentarray property format inruleset.xmland removes a PHPCS 4-removed sniff reference. - Adds
: arrayreturn types to custom sniffregister()methods to match the PHPCS 4 interface.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
composer.json |
Bumps PHPCS dev dependency to v4. |
PHP/CodeSniffer/Graze/ruleset.xml |
Updates ruleset XML for PHPCS 4 compatibility. |
PHP/CodeSniffer/Graze/Sniffs/Commenting/InvalidTypeSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/Commenting/MissingFunctionCommentSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/ControlStructures/IfVariableAssignmentSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/ControlStructures/NegationNoSpacesSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/ControlStructures/NestedTernarySniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/Files/DoubleBlankLineSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/Naming/AbstractClassNamingSniff.php |
Adds PHPCS 4-compatible register() return type. |
PHP/CodeSniffer/Graze/Sniffs/Naming/InterfaceNamingSniff.php |
Adds PHPCS 4-compatible register() return type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PHPCS 4 introduced two breaking changes that prevented this ruleset from loading on 4.x: 1. `Generic.WhiteSpace.ScopeIndent` no longer accepts comma-separated strings for the `ignoreIndentationTokens` array property. Migrated to the `<element value="..."/>` form. 2. `Generic.Functions.CallTimePassByReference` (deprecated since PHPCS 3.12) was removed in 4.0. Dropped the reference; modern PHP already disallows call-time pass-by-reference at the language level, so the sniff was redundant. In addition, PHPCS 4 tightened the `Sniff` interface to declare `register(): array`. Added the matching return type to all 8 custom `Graze.*` sniffs (the 9th, `InlineVariableCommentSniff`, inherits from `AbstractVariableSniff` and is unaffected). PHPCS 4 also requires PHP >=7.2. Made that floor explicit by adding `"php": ">=7.2"` to composer.json `require`, and regenerated composer.lock so it pins squizlabs/php_codesniffer to 4.0.1 instead of the previous 3.5.5 (a committed lock that contradicts the constraint). Migrated CI from Travis to GitHub Actions: matrix PHP 7.2 through 8.3 running phpcs and markdown lint, plus a docs-deploy job that builds the mkdocs site and publishes to the gh-pages branch on push to main (preserving the existing deployment mechanism via peaceiris/actions-gh-pages). This is a BC break for any consumer still on PHPCS 3 -- consumers must upgrade their `squizlabs/php_codesniffer` to ^4.0 alongside bumping `graze/standards` to ^3.0. Constraint narrowed to `^4.0` rather than dual-compat `^3.0 | ^4.0` to keep one supported PHPCS API surface going forward. Verified locally against PHPCS 4.0.1: ruleset loads, and running phpcs against `examples/` reports the same intentional fixture violations as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for PHP_CodeSniffer 4, drops PHPCS 3, and migrates CI from Travis to GitHub Actions. The PHPCS bump is a BC break intended for a
v3.0.0release.Background
PHPCS 4 introduced two breaking changes that prevented this ruleset from loading at all on 4.x — they're load-time XML/sniff errors, so they couldn't be worked around from a downstream ruleset.
Changes
PHP/CodeSniffer/Graze/ruleset.xmlGeneric.WhiteSpace.ScopeIndent'signoreIndentationTokensmigrated from comma-separated string to<element value="..."/>nodesPHP/CodeSniffer/Graze/ruleset.xml<rule ref="Generic.Functions.CallTimePassByReference" />PHP/CodeSniffer/Graze/Sniffs/**/*.php: arrayreturn type toregister()Sniffinterface toregister(): array; child class must declare a compatible return type. The 9th sniff (InlineVariableCommentSniff) inherits fromAbstractVariableSniffand is unaffectedcomposer.jsonsquizlabs/php_codesniffer: ^3.0→^4.0.travis.yml→.github/workflows/ci.ymlphpcs, plus markdown lint andgh-pagesmkdocs deploy onmain)Verification
Tested locally with PHPCS 4.0.1: ruleset loads cleanly, and running
phpcsagainst the repo's ownexamples/reports the same intentional fixture violations as it did under PHPCS 3 — so behaviour against valid input is unchanged.Downstream impact
This breaks anyone using
graze/standardswith PHPCS 3. They will need to upgrade bothsquizlabs/php_codesnifferto^4.0andgraze/standardsto^3.0together.Release
Suggested tag:
v3.0.0(major bump; BC break).🤖 Generated with Claude Code