Skip to content

Upgrade slevomat/coding-standard to 8.31.* and add ReadonlyClass sniff - #16

Merged
spajxo merged 2 commits into
0.xfrom
chore/maintenance-2026-10-slevomat
Oct 15, 2026
Merged

spajxo merged 2 commits into
0.xfrom
chore/maintenance-2026-10-slevomat

Conversation

@spajxo

@spajxo spajxo commented Oct 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Bump slevomat/coding-standard 8.29.* → 8.31.* (8.30.0 – 8.31.1: bug fixes and new opt-in options only; no rule this ruleset references changed its defaults).
  • Enable SlevomatCodingStandard.Classes.ReadonlyClass (new in 8.30). It reports a final class whose properties are all readonly and asks for readonly class instead (auto-fixable by phpcbf). Abstract and non-final classes are left alone (defaults). The sniff only runs when the target PHP version is ≥ 8.2.

Impact on consuming projects

After updating, projects on PHP ≥ 8.2 will get new errors for such classes; vendor/bin/phpcbf fixes them.

Tests

  • testModernPhpFeaturesPass sample changed to final readonly class — the old sample is exactly what the new rule rejects.
  • No dedicated violation fixture: the sniff is disabled on the PHP 7.4–8.1 CI runners, so such a test would fail there. Verified manually on PHP 8.5 that a final class with only readonly promoted properties is reported as ReadonlyClass.ClassCanBeReadonly.
  • Locally (PHP 8.5): composer test 18/18 OK, composer cs-check clean, composer audit clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VLJt2ZvzYnHTxUzSugcWkk

spajxo and others added 2 commits October 15, 2026 16:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VLJt2ZvzYnHTxUzSugcWkk
Requires final classes whose properties are all readonly to be declared
as readonly classes (PHP >= 8.2 only; the sniff disables itself on older
PHP versions). The modern PHP compliance sample is updated to the style
the rule now enforces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VLJt2ZvzYnHTxUzSugcWkk
@spajxo
spajxo marked this pull request as ready for review October 15, 2026 14:43
@spajxo spajxo mentioned this pull request Oct 15, 2026
@spajxo
spajxo merged commit 9f66c87 into 0.x Oct 15, 2026
7 checks passed
@spajxo
spajxo deleted the chore/maintenance-2026-10-slevomat branch October 15, 2026 14:56
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