Skip to content

Commit

Permalink
Avoid matching multi-line imports (#43093)
Browse files Browse the repository at this point in the history
Multi-line imports are broken:
```
use Illuminate\Foundation\Testing\{
    DatabaseTransactions,
    WithFaker,
};
```
Results in output:
```
    DatabaseTransactions,
    WithFaker,
use Illuminate\Foundation\Testing\{
};
```
  • Loading branch information
n8man authored Jul 12, 2022
1 parent 14893ea commit ca490ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ protected function replaceClass($stub, $name)
*/
protected function sortImports($stub)
{
if (preg_match('/(?P<imports>(?:use [^;]+;$\n?)+)/m', $stub, $match)) {
if (preg_match('/(?P<imports>(?:use [^;{]+;$\n?)+)/m', $stub, $match)) {
$imports = explode("\n", trim($match['imports']));

sort($imports);
Expand Down

0 comments on commit ca490ca

Please sign in to comment.