Conversation
When a file is moved or refactored, the hash in generated import paths changes. Previously the generator would add the new correct import but leave the old stale import behind, forcing manual cleanup and leaving CI in a bad state. This re-introduces `StaleImportRemover` (reverted in #35) with a fix for the regression that caused the original rollback: it now only removes imports whose leaf class is the operation's own `Query`, `Mutation`, or matching `FailedException`. Sibling classes under the same operation namespace (`Data\...`, `Error\...`) are left untouched because the remover has no way to tell whether they are still in use. `PlanExecutor` also now collects the full set of valid operation FQCNs across the entire plan — not just the ones injected into the current file — so an `@throws SomeQueryFailedException` in a file that does not itself use the query is preserved as long as the hash still points to a planned operation.
When `--ensure-sync` detected drift between generated and on-disk files, it only printed `<path> content does not match expectations`. In practice you still had to run the generator locally to understand what actually changed — CI logs were useless for diagnosing why a file was out of sync. Render a colorized unified diff (red/green, `@@` hunks) for every mismatched file so the CI log alone makes the cause obvious. Uses `sebastian/diff`, which is already available transitively via PHPUnit; promoted to a direct runtime dependency.
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.
This PR improves code maintenance by automatically removing stale generated imports and enhances the developer experience by showing diffs when
--ensure-syncdetects mismatches, making it easier to understand and fix synchronization issues.Introduce stale generated import removal
When a file is moved or refactored, the hash in generated import paths changes. Previously the generator would add the new correct import but leave the old stale import behind, forcing manual cleanup and leaving CI in a bad state.
This re-introduces
StaleImportRemover(reverted in #35) with a fix for the regression that caused the original rollback: it now only removes imports whose leaf class is the operation's ownQuery,Mutation, or matchingFailedException. Sibling classes under the same operation namespace (Data\...,Error\...) are left untouched because the remover has no way to tell whether they are still in use.PlanExecutoralso now collects the full set of valid operation FQCNs across the entire plan — not just the ones injected into the current file — so an@throws SomeQueryFailedExceptionin a file that does not itself use the query is preserved as long as the hash still points to a planned operation.Show diff on --ensure-sync mismatch
When
--ensure-syncdetected drift between generated and on-disk files, it only printed<path> content does not match expectations. In practice you still had to run the generator locally to understand what actually changed — CI logs were useless for diagnosing why a file was out of sync.Render a colorized unified diff (red/green,
@@hunks) for every mismatched file so the CI log alone makes the cause obvious. Usessebastian/diff, which is already available transitively via PHPUnit; promoted to a direct runtime dependency.