fix(writer): splice hand-written PHP and Ruby imports during overwrite#81
Merged
gjtorikian merged 1 commit intoMay 18, 2026
Conversation
Same gap as the TypeScript fix in the prior commit, applied proactively to PHP and Ruby. `spliceExtraImports` now preserves: - PHP `use Foo\\Bar;` and `use Foo\\Bar as Baz;` (namespace-qualified only — single-segment `use TraitName;` is left alone so in-class trait references aren't mistakenly hoisted to the top of the file). - Ruby `require '…'` and `require_relative '…'`. Currently latent in both languages: - workos-php's `WorkOS.php` has `@oagen-ignore-start/end` regions referencing `Passwordless`, `Vault`, `WebhookVerification`, and `Actions`, but those classes live in the same `WorkOS\\` namespace so PHP resolves them without `use`. The day any of those moves to a sub-namespace, hand-written `use` statements would have been silently dropped. - workos-ruby ships no `@oagen-ignore-start/end` regions today, but the Ruby emitter knows how to emit them; the first hand-written method needing an extra `require_relative` would have tripped the same gap. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Stacked on top of #80. Targets that branch; rebase to
mainonce #80 merges.Summary
Same gap as #80, applied proactively to PHP and Ruby.
spliceExtraImportsnow preserves:use Foo\Bar;anduse Foo\Bar as Baz;— namespace-qualified only (a backslash anywhere in the path). Single-segmentuse TraitName;is left alone so in-class trait references inside the file body aren't mistakenly hoisted to the top.require '…'andrequire_relative '…'.The
lastImportIdxloop is also widened so PHPuseand Rubyrequirelines anchor the splice position in the import block.Why now (currently latent in both)
WorkOS.phphas@oagen-ignore-start/endregions referencingPasswordless,Vault,WebhookVerification, andActions, but those classes live in the sameWorkOS\namespace so PHP resolves them withoutuse. The day any of those moves to a sub-namespace, hand-writtenusestatements would have been silently dropped.@oagen-ignore-start/endregions today, but the Ruby emitter knows how to emit them; the first hand-written method needing an extrarequire_relativewould have tripped the same gap.Test plan
npm test— 1421/1421 pass; new tests for PHPuseand Rubyrequire/require_relativepreservation inwriter-ignore.test.tsnpm run typecheck— clean🤖 Generated with Claude Code