Repository navigation
Upgrade slevomat/coding-standard to 8.31.* and add ReadonlyClass sniff - #16
Merged
Merged
Conversation
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
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
slevomat/coding-standard8.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).SlevomatCodingStandard.Classes.ReadonlyClass(new in 8.30). It reports a final class whose properties are allreadonlyand asks forreadonly classinstead (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/phpcbffixes them.Tests
testModernPhpFeaturesPasssample changed tofinal readonly class— the old sample is exactly what the new rule rejects.ReadonlyClass.ClassCanBeReadonly.composer test18/18 OK,composer cs-checkclean,composer auditclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01VLJt2ZvzYnHTxUzSugcWkk