Skip to content

Commit

Permalink
multiplatform newline check (#36464)
Browse files Browse the repository at this point in the history
  • Loading branch information
zholzhas authored Mar 4, 2021
1 parent 34418f3 commit ddb0c5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Illuminate/Foundation/Console/PolicyMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ protected function replaceModel($stub, $model)
array_keys($replace), array_values($replace), $stub
);

return str_replace(
"use {$namespacedModel};\nuse {$namespacedModel};", "use {$namespacedModel};", $stub
return preg_replace(
vsprintf('/use %s;[\r\n]+use %s;/', [
preg_quote($namespacedModel, '/'),
preg_quote($namespacedModel, '/'),
]),
"use {$namespacedModel};",
$stub
);
}

Expand Down

0 comments on commit ddb0c5e

Please sign in to comment.