Skip to content

Commit 2176406

Browse files
authored
switch Collection::make() for new Collection() (#53733)
`make()` is essentially just a static alias to the constructor. it performs no logic. removing the middleman to simplify the call stack.
1 parent 7b56029 commit 2176406

File tree

24 files changed

+36
-36
lines changed

24 files changed

+36
-36
lines changed

src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function broadcast(array $channels, $event, array $payload = [])
154154

155155
$parameters = $socket !== null ? ['socket_id' => $socket] : [];
156156

157-
$channels = Collection::make($this->formatChannels($channels));
157+
$channels = new Collection($this->formatChannels($channels));
158158

159159
try {
160160
$channels->chunk(100)->each(function ($channels) use ($event, $payload, $parameters) {

src/Illuminate/Collections/Arr.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ public static function join($array, $glue, $finalGlue = '')
489489
*/
490490
public static function keyBy($array, $keyBy)
491491
{
492-
return Collection::make($array)->keyBy($keyBy)->all();
492+
return (new Collection($array))->keyBy($keyBy)->all();
493493
}
494494

495495
/**
@@ -816,7 +816,7 @@ public static function shuffle($array)
816816
*/
817817
public static function sort($array, $callback = null)
818818
{
819-
return Collection::make($array)->sortBy($callback)->all();
819+
return (new Collection($array))->sortBy($callback)->all();
820820
}
821821

822822
/**
@@ -828,7 +828,7 @@ public static function sort($array, $callback = null)
828828
*/
829829
public static function sortDesc($array, $callback = null)
830830
{
831-
return Collection::make($array)->sortByDesc($callback)->all();
831+
return (new Collection($array))->sortByDesc($callback)->all();
832832
}
833833

834834
/**

src/Illuminate/Collections/LazyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ public function zip($items)
17521752
$iterables = func_get_args();
17531753

17541754
return new static(function () use ($iterables) {
1755-
$iterators = Collection::make($iterables)->map(function ($iterable) {
1755+
$iterators = (new Collection($iterables))->map(function ($iterable) {
17561756
return $this->makeIterator($iterable);
17571757
})->prepend($this->getIterator());
17581758

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public function pipeInto($class)
794794
*/
795795
public function pipeThrough($callbacks)
796796
{
797-
return Collection::make($callbacks)->reduce(
797+
return (new Collection($callbacks))->reduce(
798798
fn ($carry, $callback) => $callback($carry),
799799
$this,
800800
);

src/Illuminate/Database/Concerns/BuildsQueries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function chunk($count, callable $callback)
8080
*/
8181
public function chunkMap(callable $callback, $count = 1000)
8282
{
83-
$collection = Collection::make();
83+
$collection = new Collection;
8484

8585
$this->chunk($count, function ($items) use ($collection, $callback) {
8686
$items->each(function ($item) use ($collection, $callback) {

src/Illuminate/Database/Console/Migrations/StatusCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function handle()
9999
*/
100100
protected function getStatusFor(array $ran, array $batches)
101101
{
102-
return Collection::make($this->getAllMigrationFiles())
102+
return (new Collection($this->getAllMigrationFiles()))
103103
->map(function ($migration) use ($ran, $batches) {
104104
$migrationName = $this->migrator->getMigrationName($migration);
105105

src/Illuminate/Database/Eloquent/Relations/MorphTo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function __construct(Builder $query, Model $parent, $foreignKey, $ownerKe
9696
#[\Override]
9797
public function addEagerConstraints(array $models)
9898
{
99-
$this->buildDictionary($this->models = Collection::make($models));
99+
$this->buildDictionary($this->models = new Collection($models));
100100
}
101101

102102
/**

src/Illuminate/Database/Migrations/Migrator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function run($paths = [], array $options = [])
134134
*/
135135
protected function pendingMigrations($files, $ran)
136136
{
137-
return Collection::make($files)
137+
return (new Collection($files))
138138
->reject(fn ($file) => in_array($this->getMigrationName($file), $ran))
139139
->values()
140140
->all();
@@ -536,7 +536,7 @@ protected function getMigrationClass(string $migrationName): string
536536
*/
537537
public function getMigrationFiles($paths)
538538
{
539-
return Collection::make($paths)
539+
return (new Collection($paths))
540540
->flatMap(fn ($path) => str_ends_with($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php'))
541541
->filter()
542542
->values()

src/Illuminate/Database/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ public function reorder($column = null, $direction = 'asc')
28722872
*/
28732873
protected function removeExistingOrdersFor($column)
28742874
{
2875-
return Collection::make($this->orders)
2875+
return (new Collection($this->orders))
28762876
->reject(function ($order) use ($column) {
28772877
return isset($order['column'])
28782878
? $order['column'] === $column : false;

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public function registered($callback)
836836
*/
837837
public function registerConfiguredProviders()
838838
{
839-
$providers = Collection::make($this->make('config')->get('app.providers'))
839+
$providers = (new Collection($this->make('config')->get('app.providers')))
840840
->partition(fn ($provider) => str_starts_with($provider, 'Illuminate\\'));
841841

842842
$providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]);

0 commit comments

Comments
 (0)