Skip to content

Commit 7a732d5

Browse files
committed
Merge remote-tracking branch 'upstream/12.x'
Signed-off-by: Mior Muhammad Zaki <[email protected]>
2 parents 6c26422 + 912ab40 commit 7a732d5

28 files changed

+319
-149
lines changed

.github/workflows/tests.yml

+4-22
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
fail-fast: true
4141
matrix:
4242
php: [8.3, 8.4]
43-
phpunit: ['10.5.35', '11.5.3', '12.0.0']
43+
phpunit: ['10.5.35', '11.5.3', '12.0.0', '12.1.0']
4444
stability: [prefer-lowest, prefer-stable]
4545

4646
name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }}
@@ -64,19 +64,12 @@ jobs:
6464
- name: Set Framework version
6565
run: composer config version "13.x-dev"
6666

67-
- name: Set PHPUnit
68-
uses: nick-fields/retry@v3
69-
with:
70-
timeout_minutes: 5
71-
max_attempts: 5
72-
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
73-
7467
- name: Install dependencies
7568
uses: nick-fields/retry@v3
7669
with:
7770
timeout_minutes: 5
7871
max_attempts: 5
79-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
72+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
8073

8174
- name: Execute tests
8275
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
@@ -103,11 +96,8 @@ jobs:
10396
fail-fast: true
10497
matrix:
10598
php: [8.3, 8.4]
106-
phpunit: ['11.5.3']
99+
phpunit: ['10.5.35', '11.5.3', '12.0.0', '12.1.0']
107100
stability: [prefer-lowest, prefer-stable]
108-
exclude:
109-
- php: 8.4
110-
stability: prefer-lowest
111101

112102
name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }} - Windows
113103

@@ -131,20 +121,12 @@ jobs:
131121
- name: Set Framework version
132122
run: composer config version "13.x-dev"
133123

134-
- name: Set PHPUnit
135-
uses: nick-fields/retry@v3
136-
with:
137-
timeout_minutes: 5
138-
max_attempts: 5
139-
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
140-
shell: bash
141-
142124
- name: Install dependencies
143125
uses: nick-fields/retry@v3
144126
with:
145127
timeout_minutes: 5
146128
max_attempts: 5
147-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
129+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
148130

149131
- name: Execute tests
150132
run: vendor/bin/phpunit

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Release Notes for 12.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v12.7.1...12.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v12.7.2...12.x)
4+
5+
## [v12.7.2](https://github.com/laravel/framework/compare/v12.7.1...v12.7.2) - 2025-04-03
46

57
## [v12.7.1](https://github.com/laravel/framework/compare/v12.7.0...v12.7.1) - 2025-04-03
68

src/Illuminate/Collections/Traits/EnumeratesValues.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ public static function times($number, ?callable $callback = null)
179179
->map($callback);
180180
}
181181

182+
/**
183+
* Create a new collection by decoding a JSON string.
184+
*
185+
* @param string $json
186+
* @param int $depth
187+
* @param int $flags
188+
* @return static<TKey, TValue>
189+
*/
190+
public static function fromJson($json, $depth = 512, $flags = 0)
191+
{
192+
return new static(json_decode($json, true, $depth, $flags));
193+
}
194+
182195
/**
183196
* Get the average value of a given key.
184197
*
@@ -1046,11 +1059,8 @@ public function __get($key)
10461059
*/
10471060
protected function getArrayableItems($items)
10481061
{
1049-
if (is_array($items)) {
1050-
return $items;
1051-
}
1052-
10531062
return match (true) {
1063+
is_array($items) => $items,
10541064
$items instanceof WeakMap => throw new InvalidArgumentException('Collections can not be created using instances of WeakMap.'),
10551065
$items instanceof Enumerable => $items->all(),
10561066
$items instanceof Arrayable => $items->toArray(),

src/Illuminate/Collections/Traits/TransformsToResourceCollection.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminate\Support\Traits;
44

55
use Illuminate\Database\Eloquent\Model;
6-
use Illuminate\Http\Resources\Json\JsonResource;
76
use Illuminate\Http\Resources\Json\ResourceCollection;
87
use LogicException;
98

@@ -12,8 +11,8 @@ trait TransformsToResourceCollection
1211
/**
1312
* Create a new resource collection instance for the given resource.
1413
*
15-
* @param class-string<JsonResource>|null $resourceClass
16-
* @return ResourceCollection
14+
* @param class-string<\Illuminate\Http\Resources\Json\JsonResource>|null $resourceClass
15+
* @return \Illuminate\Http\Resources\Json\ResourceCollection
1716
*
1817
* @throws \Throwable
1918
*/
@@ -29,7 +28,7 @@ public function toResourceCollection(?string $resourceClass = null): ResourceCol
2928
/**
3029
* Guess the resource collection for the items.
3130
*
32-
* @return ResourceCollection
31+
* @return \Illuminate\Http\Resources\Json\ResourceCollection
3332
*
3433
* @throws \Throwable
3534
*/

src/Illuminate/Collections/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
}
3535
},
3636
"suggest": {
37+
"illuminate/http": "Required to convert collections to API resources (^12.0).",
3738
"symfony/var-dumper": "Required to use the dump method (^7.2)."
3839
},
3940
"config": {

src/Illuminate/Http/Resources/TransformsToResource.php renamed to src/Illuminate/Database/Eloquent/Concerns/TransformsToResource.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Illuminate\Http\Resources;
3+
namespace Illuminate\Database\Eloquent\Concerns;
44

55
use Illuminate\Http\Resources\Json\JsonResource;
66
use Illuminate\Support\Str;
@@ -11,8 +11,8 @@ trait TransformsToResource
1111
/**
1212
* Create a new resource object for the given resource.
1313
*
14-
* @param class-string<JsonResource>|null $resourceClass
15-
* @return JsonResource
14+
* @param class-string<\Illuminate\Http\Resources\Json\JsonResource>|null $resourceClass
15+
* @return \Illuminate\Http\Resources\Json\JsonResource
1616
*
1717
* @throws \Throwable
1818
*/
@@ -28,7 +28,7 @@ public function toResource(?string $resourceClass = null): JsonResource
2828
/**
2929
* Guess the resource class for the model.
3030
*
31-
* @return JsonResource
31+
* @return \Illuminate\Http\Resources\Json\JsonResource
3232
*
3333
* @throws \Throwable
3434
*/
@@ -46,7 +46,7 @@ protected function guessResource(): JsonResource
4646
/**
4747
* Guess the resource class name for the model.
4848
*
49-
* @return array<class-string<JsonResource>>
49+
* @return array<class-string<\Illuminate\Http\Resources\Json\JsonResource>>
5050
*/
5151
public static function guessResourceName(): array
5252
{

src/Illuminate/Database/Eloquent/MassPrunable.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public function pruneAll(int $chunkSize = 1000)
2323

2424
$total = 0;
2525

26+
$softDeletable = in_array(SoftDeletes::class, class_uses_recursive(get_class($this)));
27+
2628
do {
27-
$total += $count = in_array(SoftDeletes::class, class_uses_recursive(get_class($this)))
29+
$total += $count = $softDeletable
2830
? $query->forceDelete()
2931
: $query->delete();
3032

src/Illuminate/Database/Eloquent/Model.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot;
1818
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
1919
use Illuminate\Database\Eloquent\Relations\Pivot;
20-
use Illuminate\Http\Resources\TransformsToResource;
2120
use Illuminate\Support\Arr;
2221
use Illuminate\Support\Collection as BaseCollection;
2322
use Illuminate\Support\Str;
@@ -40,8 +39,8 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt
4039
Concerns\HidesAttributes,
4140
Concerns\GuardsAttributes,
4241
Concerns\PreventsCircularRecursion,
43-
ForwardsCalls,
44-
TransformsToResource;
42+
Concerns\TransformsToResource,
43+
ForwardsCalls;
4544
/** @use HasCollection<\Illuminate\Database\Eloquent\Collection<array-key, static & self>> */
4645
use HasCollection;
4746

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

+28
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,34 @@ public function createManyQuietly(iterable $records)
436436
return Model::withoutEvents(fn () => $this->createMany($records));
437437
}
438438

439+
/**
440+
* Create a Collection of new instances of the related model, allowing mass-assignment.
441+
*
442+
* @param iterable $records
443+
* @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
444+
*/
445+
public function forceCreateMany(iterable $records)
446+
{
447+
$instances = $this->related->newCollection();
448+
449+
foreach ($records as $record) {
450+
$instances->push($this->forceCreate($record));
451+
}
452+
453+
return $instances;
454+
}
455+
456+
/**
457+
* Create a Collection of new instances of the related model, allowing mass-assignment and without raising any events to the parent model.
458+
*
459+
* @param iterable $records
460+
* @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
461+
*/
462+
public function forceCreateManyQuietly(iterable $records)
463+
{
464+
return Model::withoutEvents(fn () => $this->forceCreateMany($records));
465+
}
466+
439467
/**
440468
* Set the foreign ID for creating a related model.
441469
*

src/Illuminate/Database/Query/Grammars/Grammar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ public function compileInsertOrIgnore(Builder $query, array $values)
12031203
*
12041204
* @param \Illuminate\Database\Query\Builder $query
12051205
* @param array $values
1206-
* @param string $sequence
1206+
* @param string|null $sequence
12071207
* @return string
12081208
*/
12091209
public function compileInsertGetId(Builder $query, $values, $sequence)

src/Illuminate/Database/Query/Grammars/PostgresGrammar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public function compileInsertOrIgnoreUsing(Builder $query, array $columns, strin
383383
*
384384
* @param \Illuminate\Database\Query\Builder $query
385385
* @param array $values
386-
* @param string $sequence
386+
* @param string|null $sequence
387387
* @return string
388388
*/
389389
public function compileInsertGetId(Builder $query, $values, $sequence)

src/Illuminate/Database/Schema/Grammars/Grammar.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function compileForeignKeys($schema, $table)
169169
*
170170
* @param \Illuminate\Database\Schema\Blueprint $blueprint
171171
* @param \Illuminate\Support\Fluent $command
172-
* @return array|string
172+
* @return list<string>|string
173173
*/
174174
public function compileRenameColumn(Blueprint $blueprint, Fluent $command)
175175
{
@@ -185,7 +185,7 @@ public function compileRenameColumn(Blueprint $blueprint, Fluent $command)
185185
*
186186
* @param \Illuminate\Database\Schema\Blueprint $blueprint
187187
* @param \Illuminate\Support\Fluent $command
188-
* @return array|string
188+
* @return list<string>|string
189189
*
190190
* @throws \RuntimeException
191191
*/
@@ -427,8 +427,8 @@ protected function hasCommand(Blueprint $blueprint, $name)
427427
* Add a prefix to an array of values.
428428
*
429429
* @param string $prefix
430-
* @param array $values
431-
* @return array
430+
* @param array<string> $values
431+
* @return array<string>
432432
*/
433433
public function prefixArray($prefix, array $values)
434434
{

src/Illuminate/Database/Schema/Grammars/MariaDbGrammar.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77

88
class MariaDbGrammar extends MySqlGrammar
99
{
10-
/**
11-
* Compile a rename column command.
12-
*
13-
* @param \Illuminate\Database\Schema\Blueprint $blueprint
14-
* @param \Illuminate\Support\Fluent $command
15-
* @return array|string
16-
*/
10+
/** @inheritDoc */
1711
public function compileRenameColumn(Blueprint $blueprint, Fluent $command)
1812
{
1913
if (version_compare($this->connection->getServerVersion(), '10.5.2', '<')) {

src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php

+6-18
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,7 @@ public function compileAutoIncrementStartingValues(Blueprint $blueprint, Fluent
331331
}
332332
}
333333

334-
/**
335-
* Compile a rename column command.
336-
*
337-
* @param \Illuminate\Database\Schema\Blueprint $blueprint
338-
* @param \Illuminate\Support\Fluent $command
339-
* @return array|string
340-
*/
334+
/** @inheritDoc */
341335
public function compileRenameColumn(Blueprint $blueprint, Fluent $command)
342336
{
343337
$isMaria = $this->connection->isMaria();
@@ -396,13 +390,7 @@ protected function compileLegacyRenameColumn(Blueprint $blueprint, Fluent $comma
396390
);
397391
}
398392

399-
/**
400-
* Compile a change column command into a series of SQL statements.
401-
*
402-
* @param \Illuminate\Database\Schema\Blueprint $blueprint
403-
* @param \Illuminate\Support\Fluent $command
404-
* @return array|string
405-
*/
393+
/** @inheritDoc */
406394
public function compileChange(Blueprint $blueprint, Fluent $command)
407395
{
408396
$column = $command->column;
@@ -650,7 +638,7 @@ public function compileRenameIndex(Blueprint $blueprint, Fluent $command)
650638
/**
651639
* Compile the SQL needed to drop all tables.
652640
*
653-
* @param array $tables
641+
* @param array<string> $tables
654642
* @return string
655643
*/
656644
public function compileDropAllTables($tables)
@@ -661,7 +649,7 @@ public function compileDropAllTables($tables)
661649
/**
662650
* Compile the SQL needed to drop all views.
663651
*
664-
* @param array $views
652+
* @param array<string> $views
665653
* @return string
666654
*/
667655
public function compileDropAllViews($views)
@@ -707,8 +695,8 @@ public function compileTableComment(Blueprint $blueprint, Fluent $command)
707695
/**
708696
* Quote-escape the given tables, views, or types.
709697
*
710-
* @param array $names
711-
* @return array
698+
* @param array<string> $names
699+
* @return array<string>
712700
*/
713701
public function escapeNames($names)
714702
{

0 commit comments

Comments
 (0)