Skip to content

Require PHP_CodeSniffer 4, migrate CI to GitHub Actions (BC break, v3.0.0)#53

Merged
rick-lam merged 4 commits into
mainfrom
phpcs-4-support
May 28, 2026
Merged

Require PHP_CodeSniffer 4, migrate CI to GitHub Actions (BC break, v3.0.0)#53
rick-lam merged 4 commits into
mainfrom
phpcs-4-support

Conversation

@rick-lam
Copy link
Copy Markdown
Contributor

@rick-lam rick-lam commented May 28, 2026

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.0 release.

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

File(s) Change Why
PHP/CodeSniffer/Graze/ruleset.xml Generic.WhiteSpace.ScopeIndent's ignoreIndentationTokens migrated from comma-separated string to <element value="..."/> nodes PHPCS 4 no longer accepts the legacy comma-separated form
PHP/CodeSniffer/Graze/ruleset.xml Removed <rule ref="Generic.Functions.CallTimePassByReference" /> Sniff removed in PHPCS 4 (deprecated since 3.12); modern PHP already disallows call-time pass-by-reference at the language level, so the sniff was redundant
8 sniffs under PHP/CodeSniffer/Graze/Sniffs/**/*.php Added : array return type to register() PHPCS 4 tightened the Sniff interface to register(): array; child class must declare a compatible return type. The 9th sniff (InlineVariableCommentSniff) inherits from AbstractVariableSniff and is unaffected
composer.json squizlabs/php_codesniffer: ^3.0^4.0 Drop PHPCS 3 entirely to avoid maintaining two PHPCS API surfaces going forward
.travis.yml.github/workflows/ci.yml Replaced Travis config with a GitHub Actions workflow (PHP 7.2–8.5 matrix runs phpcs, plus markdown lint and gh-pages mkdocs deploy on main) Travis CI is no longer in use; move CI to GitHub Actions where the rest of the org runs

Verification

Tested locally with PHPCS 4.0.1: ruleset loads cleanly, and running phpcs against the repo's own examples/ 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/standards with PHPCS 3. They will need to upgrade both squizlabs/php_codesniffer to ^4.0 and graze/standards to ^3.0 together.

Release

Suggested tag: v3.0.0 (major bump; BC break).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 28, 2026 09:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0 to ^4.0.
  • Converts the ScopeIndent array property format in ruleset.xml and removes a PHPCS 4-removed sniff reference.
  • Adds : array return types to custom sniff register() 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.

Comment thread composer.json
Comment thread composer.json Outdated
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>
rick-lam and others added 3 commits May 28, 2026 11:05
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>
@rick-lam rick-lam changed the title Require PHP_CodeSniffer 4 (BC break, v3.0.0) Require PHP_CodeSniffer 4, migrate CI to GitHub Actions (BC break, v3.0.0) May 28, 2026
@rick-lam rick-lam requested a review from Copilot May 28, 2026 10:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/ci.yml
@rick-lam rick-lam merged commit df8a5d9 into main May 28, 2026
12 checks passed
@rick-lam rick-lam deleted the phpcs-4-support branch May 28, 2026 10:14
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