Skip to content

fix: sort generator imports in templates with CRLF line endings - #10622

Merged
paulbalandan merged 1 commit into
codeigniter4:developfrom
paulbalandan:crlf-import-sorting
Oct 13, 2026
Merged

paulbalandan merged 1 commit into
codeigniter4:developfrom
paulbalandan:crlf-import-sorting

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description
GeneratorTrait::buildContent() finds the import block with /(?:^use [^;]+;$\n?)+/m. In multiline mode $ only matches before \n, so on a template with CRLF line endings the \r after each ; breaks the match and the imports are left unsorted. This hits custom generator views set in Config\Generators::$views and saved with CRLF, for example on Windows.

The pattern now allows \r? before the line end. The imports are split on normalized \n and rejoined with the template's own line ending, so CRLF output stays CRLF.

The publish:language test fixture gains a --crlf flag that converts its template to CRLF, and ConfigurableSortImportsTest covers the sorted CRLF output. A follow-up PR on 4.8 applies the same fix to AbstractGeneratorCommand.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 12, 2026
@paulbalandan
paulbalandan merged commit b7e115b into codeigniter4:develop Oct 13, 2026
64 of 65 checks passed
@paulbalandan
paulbalandan deleted the crlf-import-sorting branch October 13, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants