This repository was archived by the owner on Aug 23, 2026. It is now read-only.
Repository navigation
refactor(quality): Rector wave 3 — equivalence-safe cosmetics only (AID-531) - #190
Merged
Merged
Conversation
…ID-531) Enable the five equivalence-preserving cosmetic rules from LARAVEL_CODE_QUALITY + codeQuality level 50, applied via composer refactor across 16 app/ files: ObjectExplicitBoolCompare, ExplicitBoolCompare, SimplifyIfReturnBool, StrlenZeroToIdenticalEmptyString, CombineIf. The set is NOT mechanical as the ticket assumed. Measured with --clear-cache, the full set touches 40 files and mixes three risk profiles: 27 model scopes flipped public->protected (public surface), Carbon->Date facade + now()->startOfDay()->today() (runtime class and temporal semantics), and ApplyDefaultInsteadOfNullCoalesce (?? vs ?:, which differs on false/0/''). Those are split out by risk profile into AID-540 (scopes), AID-541 (Carbon/temporal), AID-542 (?? default — touches the recorded ??/?: lesson), AID-543 (helpers/exceptions, each transform to prove equivalence). A PR must be revertible without dragging another risk profile with it. Every transform that landed was diff-verified equivalence-preserving: - ExplicitBoolCompare's `if ($s)` -> `$s !== '' && $s !== '0'` fires only on string-typed vars; the three sites (keyName, keyPath, companyName) all originate from '' or a string-returning call. Rector left the ?string option() path (UserCreateCommand:139) untouched and only rewrote the text()-sourced companyName at :272. - ObjectExplicitBoolCompare's `if ($obj)` -> `instanceof` is equivalent for the declared nullable-object type. - strlen($s)===0 -> $s==='' , CombineIf (short-circuit preserved), SimplifyIfReturnBool: all shape-only. Two Rector-cache traps hit and worked around, both from the wave-2 lesson: measuring several configs back-to-back without --clear-cache returns stale zeros; and `composer refactor` (no --clear-cache) after a measuring session under-applied — 16 files measured, only 3 written — until the cache was cleared and it re-applied all 16. Noted in the rector.php header for the remaining waves. Wave checklist: - clean tree at start; applied via composer refactor with cleared cache - shape-verified: zero non-cosmetic transforms leaked (0 scopes, 0 Carbon, 0 ??, 0 to_route); patterns are 12 instanceof + 5 === '' + 3 !== '' && !== '0' - rule bites, attributably: a new if/return-bool file -> exit 2 naming app/ProbeCq.php:10 (SimplifyIfReturnBoolRector) - gates: check-full green, coverage 89.7%, PHPStan clean, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Third wave. 16 app/ files, five equivalence-preserving cosmetic rules from
LARAVEL_CODE_QUALITY+codeQualitylevel 50.The set is NOT mechanical — it was split by risk profile
Re-measured with
--clear-cache, the full set touches 40 files and mixes three risk profiles. This PR ships only the equivalence-safe cosmetics; everything with a semantic or public-surface footprint went to its own ticket, so each PR is revertible without dragging another risk profile:MakeModelAttributesAndScopesProtectedCarbonToDateFacade+Now→TodayApplyDefaultInsteadOfNullCoalesce??vs?:— differs onfalse/0/''DispatchToHelper/RedirectRouteToToRoute/Compact/ThrowWithPreviousEvery landed transform verified equivalence-preserving
ExplicitBoolCompare:if ($s)→$s !== '' && $s !== '0'fires only on string-typed vars. The 3 sites (keyName,keyPath,companyName) all originate from''or astring-returning call. Rector left the?stringoption()path untouched (UserCreateCommand:139) and rewrote only thetext()-sourcedcompanyNameat:272— confirmed by inspecting the exact transformed line.ObjectExplicitBoolCompare:if ($obj)→instanceof— equivalent for the declared nullable-object type (12 occurrences).strlen($s)===0→$s==='',CombineIf(short-circuit preserved),SimplifyIfReturnBool— shape-only.Shape-verify of the applied diff: 0 scopes, 0 Carbon, 0
??, 0to_routeleaked; patterns are 12instanceof+ 5=== ''+ 3!== '' && !== '0'.Two Rector-cache traps hit (and worked around)
--clear-cachereturns stale zeros (wave-2 lesson).composer refactorunder-applied: 16 files measured, only 3 written, because it does not pass--clear-cacheand the cache from the measuring session marked the other 13 as processed. Cleared the cache → all 16 applied. Noted in therector.phpheader for the remaining waves.Gates
composer check-full→ exit 0, coverage 89.7%, PHPStan clean,refactor:dry(cleared cache) exit 0. Violation probe →rc=2namingapp/ProbeCq.php:10.