Check for mismatches in the mixin classes#1628
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1628 +/- ##
=========================================
Coverage 97.93% 97.93%
Complexity 960 960
=========================================
Files 197 197
Lines 2230 2230
=========================================
Hits 2184 2184
Misses 46 46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR converts the existing mixin generator into a linter that verifies the mixin interfaces stay in sync with the validator constructors, and wires it into the tooling/CI pipeline. It also centralizes console diff rendering and aligns command names and scripts around a consistent lint:* naming scheme.
Changes:
- Refactors all mixin interfaces (
Chain,Builder, and the various*Chain/*Buildervariants) to the format produced by the new linter: single‑line method signatures, consistent nullable union types (e.g.,string|null), and cleaned docblocks. - Introduces a reusable console differ (
ConsoleDiffer+Item) and uses it in both the docs and mixin linters to render colored, path‑relative unified diffs. - Replaces the old
create:mixin,docs:lint, andspdx:lintcommands with newlint:mixin,lint:docs, andlint:spdxcommands, updates composer scripts and GitHub Actions workflows, and adds a CI step to run the mixin linter.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Mixins/UndefOrChain.php |
Reflows undefOrBase/undefOrDateTimeDiff signatures into single lines and aligns types with validator constructors. |
src/Mixins/UndefOrBuilder.php |
Same as above for the static builder variants, plus other composite/variadic methods now on single lines. |
src/Mixins/PropertyChain.php |
Rewrites various composite/property-based methods (e.g., propertyAllOf, propertyDateTimeDiff) to the linter’s normalized signature format. |
src/Mixins/PropertyBuilder.php |
Normalizes static property-based builder methods and their parameter/return type declarations. |
src/Mixins/NullOrChain.php |
Normalizes nullOrBase and nullOrDateTimeDiff signatures and nullable union hints. |
src/Mixins/NullOrBuilder.php |
Same normalization for the nullOr* builder methods, including nullOrDateTimeDiff. |
src/Mixins/NotChain.php |
Reflows notBase and notDateTimeDiff to single-line signatures with explicit nullable unions. |
src/Mixins/NotBuilder.php |
Applies the same signature and type normalization for not* builder methods. |
src/Mixins/KeyChain.php |
Rewrites composite key-based methods (keyAllOf, keyDateTimeDiff, etc.) to linter-produced signatures. |
src/Mixins/KeyBuilder.php |
Normalizes corresponding static key-based builder methods in line with the new generator rules. |
src/Mixins/Chain.php |
Flattens the interface Chain extends … list to a single line and normalizes base/dateTimeDiff signatures and docblocks. |
src/Mixins/Builder.php |
Same as Chain for the static Builder interface, including refactored base/dateTimeDiff methods. |
src/Mixins/AllChain.php |
Normalizes allBase/allDateTimeDiff and related methods to the new style. |
src/Mixins/AllBuilder.php |
Aligns all* builder methods (including allDateTimeDiff) with the linter’s generated signatures and types. |
src-dev/Differ/Item.php |
Adds a simple Item value object encapsulating a diff “headline” and its textual content for console diffing. |
src-dev/Differ/ConsoleDiffer.php |
Renames/refactors the old differ to ConsoleDiffer in a dedicated namespace, operating on Item instances and producing colored unified diffs with relative paths. |
src-dev/Commands/LintSpdxCommand.php |
Renames the SPDX command class and console name to LintSpdxCommand / lint:spdx without altering validation behavior. |
src-dev/Commands/LintMixinCommand.php |
Converts the old mixin generator into a lint:mixin command that reflects validator constructors, computes the canonical mixin interface definitions, shows diffs via ConsoleDiffer, and optionally writes fixes when --fix is provided. |
src-dev/Commands/LintDocsCommand.php |
Renames the docs linter command to LintDocsCommand / lint:docs and switches it to use ConsoleDiffer/Item while preserving existing linting/fix behavior. |
phpcs.xml.dist |
Excludes src/Mixins/ from the line-length sniff to accommodate intentionally long generated method signatures. |
composer.json |
Updates composer scripts to call the new lint:docs and lint:spdx commands. |
bin/console |
Wires in ConsoleDiffer, registers the new Lint*Command classes, and removes references to the old command names. |
.github/workflows/reuse.yml |
Updates the SPDX workflow step to call bin/console lint:spdx. |
.github/workflows/continuous-integration-docs.yml |
Updates the docs workflow to call bin/console lint:docs. |
.github/workflows/continuous-integration-code.yml |
Adds a static-analysis step running bin/console lint:mixin to enforce mixin/validator consistency in CI. |
Comments suppressed due to low confidence (1)
src-dev/Commands/LintMixinCommand.php:74
- The description string in the AsCommand attribute is ungrammatical: "Apply linters to the generate mixin interfaces" should be "Apply linters to the generated mixin interfaces" (or similar wording). Updating this will make the CLI help output clearer and more professional.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9ea68be to
d320a4f
Compare
Since we have so many lint-related commands now, it makes sense to group them together to it's easier to spot them.
When we change the contract of a validator, or create a new one, we need to ensure that the mixin for the validator is present and matches the validator's constructor. This commit changes the current class that generates those mixin classes, converting it into a linter so we can run it in the GitHub workflow to check for missing changes.
d320a4f to
819d734
Compare
When we change the contract of a validator, or create a new one, we need to ensure that the mixin for the validator is present and matches the validator's constructor.
This commit changes the current class that generates those mixin classes, converting it into a linter so we can run it in the GitHub workflow to check for missing changes.