fix: generate proper PHP imports in duplicate function fixer#935
Merged
fix: generate proper PHP imports in duplicate function fixer#935
Conversation
The DuplicateFunction fixer's generate_simple_duplicate_fixes() was
generating JavaScript-style imports for all non-Rust files:
import { httpGet } from 'inc::Abilities::Fetch::FetchRssAbility.php';
This broke PHP files with syntax errors ('unexpected identifier from')
because PHP needs:
use DataMachine\Abilities\Fetch\FetchRssAbility;
Add generate_duplicate_import() that dispatches on Language enum and
reads the canonical file's namespace/class declarations to produce
correct PHP use statements. Also add extract_php_fqcn() helper.
This was the root cause of data-machine's persistent CI lint failures —
autofix was introducing PHP syntax errors via JS-style imports, which
blocked the autofix PR from being created.
Contributor
Homeboy Results —
|
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.
Summary
Cherry-picked from the stale
fix/fixability-kind-key-mismatchbranch. The other two commits on that branch (fixability key fix + test refactor) are already on main.Problem
The
DuplicateFunctionfixer was generating JavaScript-style imports for all non-Rust files:This broke PHP files with syntax errors because PHP needs:
Fix
generate_duplicate_import()dispatches onLanguageenumnamespaceandclassdeclarations to produce correctusestatementsextract_php_fqcn()helper parses PHP namespace + class nameThis was the root cause of data-machine's persistent CI lint failures — autofix was introducing PHP syntax errors via JS-style imports, blocking the autofix PR from ever passing.
Cleanup
The stale
fix/fixability-kind-key-mismatchbranch can be deleted — all its useful commits are now on main.