refactor(quality): Rector wave 4 β collection, dead-code, readonly gate (AID-532) - #191
Merged
Merged
Conversation
β¦te (AID-532) Enable LARAVEL_COLLECTION, LARAVEL_TYPE_DECLARATIONS, dead-code level 50 and ReadOnlyClassRector; apply via rector with cleared cache: 6 app/ files, 6 insertions, 20 deletions. Collection (4 sites, equivalence verified per site): the three toArray()->all() rewrites operate on collections of strings or plain arrays (table rows, filenames, multiselect options) β never Arrayable objects, where the two methods genuinely differ. The filter(!empty)->reject(empty) rewrite moves the negation into the method choice without touching the predicate. Dead-code (manual review, as the ticket required): the two SimplifyUselessVariable hits are trivial intermediate variables. The RemoveUnusedPrivateProperty hit on FirewallService was verified dead repo-wide β case-insensitive grep across app/, tests/, routes/, config/ and database/ found zero callers of setModSecurityOutput() and the property is write-only. Rector only empties the orphan public setter, which would leave a silent no-op promising to store state; the empty shell (docblock claims "for testing", but no test calls it) was removed by hand in the same wave. The suite stayed green, consistent with the zero-caller finding. The two rules deferred from PR 0 both enter the gate, each proven on both sides: - ReadOnlyClassRector bites on an all-readonly app class (probe -> exit 2) and leaves a Livewire component untouched even when all its properties are readonly β a readonly class cannot extend a non-readonly parent and the rule honours that. The Filament/Livewire risk recorded at PR 0 is empirically refuted, not just assumed away. - LARAVEL_TYPE_DECLARATIONS bites via EloquentWhereTypeHintClosureParameterRector (probe -> exit 2); the Builder hints it inserts are the ones that help larastan. Wave checklist: - resized with --clear-cache first: 4 + 3, overlap 1, combined 6 - diff shape-verified: every changed line classified, none unexplained - idempotence: second rector+pint pass is a byte-level no-op - gates: check-full green, 1442 passed / 16 skipped, coverage 89.8%, refactor:dry (cleared cache) exit 0 Co-Authored-By: Claude Fable 5 <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.
Fourth and final wave of the original plan. 6 app/ files, 6 insertions, 20 deletions. Resized with
--clear-cachefirst: 4 + 3 files, overlap 1, combined 6.Collection β equivalence verified per site
The three
toArray()βall()rewrites all operate on collections of strings or plain arrays (table rows, filenames, multiselect options) β neverArrayableobjects, where the two methods genuinely differ (toArray()recurses,all()does not). Thefilter(!empty)βreject(empty)rewrite moves the negation into the method choice without touching the predicate.Dead-code β manual review, as the ticket required
SimplifyUselessVariable: trivial$marked = ...; return $markedβreturn ....RemoveUnusedPrivatePropertyonFirewallService: verified dead repo-wide β case-insensitive grep across app/, tests/, routes/, config/, database/ found zero callers ofsetModSecurityOutput()and the property is write-only. (A first case-sensitive grep missed the method name entirely β the re-check with-iis what makes the claim solid.)public function setModSecurityOutput(string $output): void {}β a silent no-op promising to store state. Its docblock says "for testing", but no test calls it. The whole method was removed in the same wave. Suite stayed green, consistent with the zero-caller finding.The two rules deferred from PR 0 both enter the gate β proven on both sides
ReadOnlyClassRectorrc=2rc=0β a readonly class cannot extend a non-readonly parent and the rule honours it. The Filament/Livewire risk recorded at PR 0 is empirically refuted, not assumed away.LARAVEL_TYPE_DECLARATIONSrc=2(EloquentWhereTypeHintClosureParameterRector)Builderhints are the ones that help larastanGates
Diff shape-verified (every changed line classified, none unexplained) Β· idempotent (second pass byte-level no-op) Β·
composer check-fullβ exit 0, 1442 passed / 16 skipped, coverage 89.8% Β·refactor:dry(cleared cache) exit 0.