Skip to content

Commit 1212afe

Browse files
committed
fix conflicts
2 parents 8dde5dc + d3586eb commit 1212afe

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ public function value($key, $default = null)
298298
/**
299299
* Ensure that every item in the collection is of the expected type.
300300
*
301-
* @template TEnforceIntoValue
301+
* @template TEnsureOfType
302302
*
303-
* @param class-string<TEnforceIntoValue> $type
304-
* @return static<mixed, TEnforceIntoValue>
303+
* @param class-string<TEnsureOfType> $type
304+
* @return static<mixed, TEnsureOfType>
305305
*
306306
* @throws \UnexpectedValueException
307307
*/
@@ -310,8 +310,10 @@ public function ensure($type)
310310
return $this->each(function ($item) use ($type) {
311311
$itemType = get_debug_type($item);
312312

313-
if ($itemType !== $type) {
314-
throw new UnexpectedValueException("Collection should only include '{$type}' items, but '{$itemType}' found.");
313+
if ($itemType !== $type && ! $item instanceof $type) {
314+
throw new UnexpectedValueException(
315+
sprintf("Collection should only include '%s' items, but '%s' found.", $type, $itemType)
316+
);
315317
}
316318
});
317319
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function handle()
6161

6262
if ($this->laravel->bound(Dispatcher::class)) {
6363
$this->laravel[Dispatcher::class]->dispatch(
64-
new DatabaseRefreshed
64+
new DatabaseRefreshed($database, $this->needsSeeding())
6565
);
6666
}
6767

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function handle()
6767

6868
if ($this->laravel->bound(Dispatcher::class)) {
6969
$this->laravel[Dispatcher::class]->dispatch(
70-
new DatabaseRefreshed
70+
new DatabaseRefreshed($database, $this->needsSeeding())
7171
);
7272
}
7373

src/Illuminate/Database/Events/DatabaseRefreshed.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,17 @@
66

77
class DatabaseRefreshed implements MigrationEventContract
88
{
9-
//
9+
/**
10+
* Create a new event instance.
11+
*
12+
* @param string|null $database
13+
* @param bool seeding
14+
* @return void
15+
*/
16+
public function __construct(
17+
public ?string $database = null,
18+
public bool $seeding = false
19+
) {
20+
//
21+
}
1022
}

tests/Support/SupportCollectionTest.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5598,17 +5598,40 @@ public function testDot($collection)
55985598
/**
55995599
* @dataProvider collectionClassProvider
56005600
*/
5601-
public function testEnsure($collection)
5601+
public function testEnsureForScalar($collection)
56025602
{
56035603
$data = $collection::make([1, 2, 3]);
5604-
56055604
$data->ensure('int');
56065605

56075606
$data = $collection::make([1, 2, 3, 'foo']);
5607+
$this->expectException(UnexpectedValueException::class);
5608+
$data->ensure('int');
5609+
}
5610+
5611+
/**
5612+
* @dataProvider collectionClassProvider
5613+
*/
5614+
public function testEnsureForObjects($collection)
5615+
{
5616+
$data = $collection::make([new stdClass, new stdClass, new stdClass]);
5617+
$data->ensure(stdClass::class);
56085618

5619+
$data = $collection::make([new stdClass, new stdClass, new stdClass, $collection]);
56095620
$this->expectException(UnexpectedValueException::class);
5621+
$data->ensure(stdClass::class);
5622+
}
56105623

5611-
$data->ensure('int');
5624+
/**
5625+
* @dataProvider collectionClassProvider
5626+
*/
5627+
public function testEnsureForInheritance($collection)
5628+
{
5629+
$data = $collection::make([new \Error, new \Error]);
5630+
$data->ensure(\Throwable::class);
5631+
5632+
$data = $collection::make([new \Error, new \Error, new $collection]);
5633+
$this->expectException(UnexpectedValueException::class);
5634+
$data->ensure(\Throwable::class);
56125635
}
56135636

56145637
/**

0 commit comments

Comments
 (0)