/** * Formatting helpers that keep emitted PHP byte-stable under Laravel Pint. * * Issue #174: `omnify generate` wrote PHP that Pint immediately rewrote, so a * version bump with no schema change produced hundreds of modified files that * a formatter pass then reverted. Consumers running Pint paid review noise; * consumers without it kept the churn forever. Codegen a formatter rewrites * can never be verified byte-for-byte, so the generators emit Pint's own shape * instead of relying on the post-generate Pint pass to fix it up. */ /** * Collects `use` imports for the classes a Resource references, so the emitted * file matches what Laravel Pint's `laravel` preset produces. * * Issue #174: the generator emitted inline `\App\Http\Resources\FooResource`, * which Pint rewrites into an import plus the short name. Every consumer with * Pint therefore saw the whole Resource layer change on `generate` and change * back on `pint` — 315 files of churn per run on the reporting project — and * every consumer WITHOUT Pint kept the churn permanently. Codegen a formatter * immediately rewrites can never be verified byte-for-byte. * * Two cases keep the FQCN, because an import would be wrong rather than noisy: * - the short name is already taken by a different FQN (a genuine collision); * - the class lives in this file's own namespace, where PHP resolves the * short name without an import and Pint adds none. */ export declare function createClassImporter(currentNamespace: string, reserved?: string[]): { /** Reference `fqn` the way Pint would: short name + import when possible. */ ref(fqn: string): string; /** Every FQN to import, minus the reserved ones the template writes itself. */ list(): string[]; }; export type ClassImporter = ReturnType; /** * Render a `use` block in Pint's `ordered_imports` order. PHP-CS-Fixer's alpha * algorithm compares with `\` replaced by a space, so a shorter namespace * sorts before a longer one sharing its prefix. */ export declare function renderUseBlock(fqns: string[]): string; /** * Rewrite a file's top-level `use` block the way Pint's `ordered_imports` and * `no_unused_imports` would: drop imports nothing in the file references, then * sort what is left. * * Applied to every generated PHP file rather than to each template, because * every template that grew an import grew the same two violations (#174). Only * `use` at column 0 is touched — a trait `use` inside a class body is indented, * and grouped or function/const imports are left exactly as written. */ export declare function normalizeTopLevelUses(content: string): string; /** * The blank-line half of Pint's `laravel` preset, applied to every generated * PHP file (#174): * * - `no_extra_blank_lines` — never two blank lines in a row, and none left * hanging before a closing brace; * - `class_attributes_separation` — one blank line between a class's trait * `use` group and the member that follows it. * * Templates composed from optional sections (a `$incrementing` block that is * usually absent, a trait list that is sometimes empty) produce these by * construction, which is why this is central rather than per template. */ export declare function normalizePhpBlankLines(content: string): string; /** * The remaining whole-file rules from Pint's `laravel` preset that templates * kept getting wrong (#174): * * - `function_declaration` — an arrow function is `fn () =>`, not `fn() =>`; * - `blank_line_before_statement` — a `return` that follows a statement gets * a blank line before it. */ export declare function normalizePhpStatements(content: string): string; /** * `not_operator_with_successor_space` — Laravel's preset writes `! $x`, not * `!$x` (#174). * * Done with a scanner rather than a regex because the same character is * ordinary text inside a string literal, and generated services embed SQL and * message strings. Only code outside quotes is touched, and `!=` / `!==` are * comparisons, not negations. */ export declare function normalizeNotOperator(content: string): string;