Skip to content

Commit 718b4b6

Browse files
committed
Merge branch '9.x'
# Conflicts: # CHANGELOG.md # src/Illuminate/Foundation/Application.php
2 parents cbc54eb + 8c20201 commit 718b4b6

File tree

32 files changed

+334
-60
lines changed

32 files changed

+334
-60
lines changed

src/Illuminate/Auth/Notifications/ResetPassword.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class ResetPassword extends Notification
1818
/**
1919
* The callback that should be used to create the reset password URL.
2020
*
21-
* @var \Closure|null
21+
* @var (\Closure(mixed, string): string)|null
2222
*/
2323
public static $createUrlCallback;
2424

2525
/**
2626
* The callback that should be used to build the mail message.
2727
*
28-
* @var \Closure|null
28+
* @var (\Closure(mixed, string): \Illuminate\Notifications\Messages\MailMessage)|null
2929
*/
3030
public static $toMailCallback;
3131

@@ -103,7 +103,7 @@ protected function resetUrl($notifiable)
103103
/**
104104
* Set a callback that should be used when creating the reset password button URL.
105105
*
106-
* @param \Closure $callback
106+
* @param \Closure(mixed, string): string $callback
107107
* @return void
108108
*/
109109
public static function createUrlUsing($callback)
@@ -114,7 +114,7 @@ public static function createUrlUsing($callback)
114114
/**
115115
* Set a callback that should be used when building the notification mail message.
116116
*
117-
* @param \Closure $callback
117+
* @param \Closure(mixed, string): \Illuminate\Notifications\Messages\MailMessage $callback
118118
* @return void
119119
*/
120120
public static function toMailUsing($callback)

src/Illuminate/Bus/PendingBatch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function __construct(Container $container, Collection $jobs)
5757
/**
5858
* Add jobs to the batch.
5959
*
60-
* @param iterable $jobs
60+
* @param \Illuminate\Support\Enumerable|object|array $jobs
6161
* @return $this
6262
*/
6363
public function add($jobs)
6464
{
65-
foreach ($jobs as $job) {
65+
foreach (Arr::wrap($jobs) as $job) {
6666
$this->jobs->push($job);
6767
}
6868

src/Illuminate/Collections/Arr.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function accessible($value)
2525
* Add an element to an array using "dot" notation if it doesn't exist.
2626
*
2727
* @param array $array
28-
* @param string $key
28+
* @param string|int|float $key
2929
* @param mixed $value
3030
* @return array
3131
*/
@@ -142,7 +142,7 @@ public static function undot($array)
142142
* Get all of the given array except for a specified array of keys.
143143
*
144144
* @param array $array
145-
* @param array|string $keys
145+
* @param array|string|int|float $keys
146146
* @return array
147147
*/
148148
public static function except($array, $keys)
@@ -169,6 +169,10 @@ public static function exists($array, $key)
169169
return $array->offsetExists($key);
170170
}
171171

172+
if (is_float($key)) {
173+
$key = (string) $key;
174+
}
175+
172176
return array_key_exists($key, $array);
173177
}
174178

@@ -252,7 +256,7 @@ public static function flatten($array, $depth = INF)
252256
* Remove one or many array items from a given array using "dot" notation.
253257
*
254258
* @param array $array
255-
* @param array|string $keys
259+
* @param array|string|int|float $keys
256260
* @return void
257261
*/
258262
public static function forget(&$array, $keys)
@@ -597,7 +601,7 @@ public static function random($array, $number = null, $preserveKeys = false)
597601
* If no key is given to the method, the entire array will be replaced.
598602
*
599603
* @param array $array
600-
* @param string|null $key
604+
* @param string|int|null $key
601605
* @param mixed $value
602606
* @return array
603607
*/

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public function hasAny($key)
583583
*/
584584
public function implode($value, $glue = null)
585585
{
586-
if (is_callable($value)) {
586+
if ($this->useAsCallable($value)) {
587587
return implode($glue ?? '', $this->map($value)->all());
588588
}
589589

src/Illuminate/Console/Scheduling/ScheduleListCommand.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Illuminate\Console\Application;
88
use Illuminate\Console\Command;
99
use Illuminate\Support\Carbon;
10+
use ReflectionClass;
11+
use ReflectionFunction;
1012
use Symfony\Component\Console\Terminal;
1113

1214
class ScheduleListCommand extends Command
@@ -50,6 +52,7 @@ public function handle(Schedule $schedule)
5052
$expression = $this->formatCronExpression($event->expression, $expressionSpacing);
5153

5254
$command = $event->command;
55+
$description = $event->description;
5356

5457
if (! $this->output->isVerbose()) {
5558
$command = str_replace(
@@ -59,6 +62,15 @@ public function handle(Schedule $schedule)
5962
);
6063
}
6164

65+
if ($event instanceof CallbackEvent) {
66+
if (class_exists($event->description)) {
67+
$command = $event->description;
68+
$description = '';
69+
} else {
70+
$command = 'Closure at: '.$this->getClosureLocation($event);
71+
}
72+
}
73+
6274
$command = mb_strlen($command) > 1 ? "{$command} " : '';
6375

6476
$nextDueDateLabel = 'Next Due:';
@@ -89,11 +101,11 @@ public function handle(Schedule $schedule)
89101
$hasMutex,
90102
$nextDueDateLabel,
91103
$nextDueDate
92-
), $this->output->isVerbose() && mb_strlen($event->description) > 1 ? sprintf(
104+
), $this->output->isVerbose() && mb_strlen($description) > 1 ? sprintf(
93105
' <fg=#6C7280>%s%s %s</>',
94106
str_repeat(' ', mb_strlen($expression) + 2),
95107
'',
96-
$event->description
108+
$description
97109
) : ''];
98110
});
99111

@@ -135,6 +147,25 @@ private function formatCronExpression($expression, $spacing)
135147
->implode(' ');
136148
}
137149

150+
/**
151+
* Get the file and line number for the event closure.
152+
*
153+
* @param \Illuminate\Console\Scheduling\CallbackEvent $event
154+
* @return string
155+
*/
156+
private function getClosureLocation(CallbackEvent $event)
157+
{
158+
$function = new ReflectionFunction(tap((new ReflectionClass($event))->getProperty('callback'))
159+
->setAccessible(true)
160+
->getValue($event));
161+
162+
return sprintf(
163+
'%s:%s',
164+
str_replace($this->laravel->basePath().DIRECTORY_SEPARATOR, '', $function->getFileName() ?: ''),
165+
$function->getStartLine()
166+
);
167+
}
168+
138169
/**
139170
* Get the terminal width.
140171
*

src/Illuminate/Database/Connectors/ConnectionFactory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function createPdoResolver(array $config)
177177
protected function createPdoResolverWithHosts(array $config)
178178
{
179179
return function () use ($config) {
180-
foreach (Arr::shuffle($hosts = $this->parseHosts($config)) as $key => $host) {
180+
foreach (Arr::shuffle($this->parseHosts($config)) as $host) {
181181
$config['host'] = $host;
182182

183183
try {
@@ -218,9 +218,7 @@ protected function parseHosts(array $config)
218218
*/
219219
protected function createPdoResolverWithoutHosts(array $config)
220220
{
221-
return function () use ($config) {
222-
return $this->createConnector($config)->connect($config);
223-
};
221+
return fn () => $this->createConnector($config)->connect($config);
224222
}
225223

226224
/**

src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\Database\Console\Seeds;
44

55
use Illuminate\Console\GeneratorCommand;
6+
use Illuminate\Support\Str;
67

78
class SeederMakeCommand extends GeneratorCommand
89
{
@@ -77,21 +78,22 @@ protected function resolveStubPath($stub)
7778
*/
7879
protected function getPath($name)
7980
{
81+
$name = str_replace('\\', '/', Str::replaceFirst($this->rootNamespace(), '', $name));
82+
8083
if (is_dir($this->laravel->databasePath().'/seeds')) {
8184
return $this->laravel->databasePath().'/seeds/'.$name.'.php';
82-
} else {
83-
return $this->laravel->databasePath().'/seeders/'.$name.'.php';
8485
}
86+
87+
return $this->laravel->databasePath().'/seeders/'.$name.'.php';
8588
}
8689

8790
/**
88-
* Parse the class name and format according to the root namespace.
91+
* Get the root namespace for the class.
8992
*
90-
* @param string $name
9193
* @return string
9294
*/
93-
protected function qualifyClass($name)
95+
protected function rootNamespace()
9496
{
95-
return $name;
97+
return 'Database\Seeders\\';
9698
}
9799
}

src/Illuminate/Database/Console/Seeds/stubs/seeder.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Database\Seeders;
3+
namespace {{ namespace }};
44

55
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
66
use Illuminate\Database\Seeder;

src/Illuminate/Database/DatabaseTransactionsManager.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ public function begin($connection, $level)
4444
*/
4545
public function rollback($connection, $level)
4646
{
47-
$this->transactions = $this->transactions->reject(function ($transaction) use ($connection, $level) {
48-
return $transaction->connection == $connection &&
49-
$transaction->level > $level;
50-
})->values();
47+
$this->transactions = $this->transactions->reject(
48+
fn ($transaction) => $transaction->connection == $connection && $transaction->level > $level
49+
)->values();
5150
}
5251

5352
/**
@@ -59,9 +58,7 @@ public function rollback($connection, $level)
5958
public function commit($connection)
6059
{
6160
[$forThisConnection, $forOtherConnections] = $this->transactions->partition(
62-
function ($transaction) use ($connection) {
63-
return $transaction->connection == $connection;
64-
}
61+
fn ($transaction) => $transaction->connection == $connection
6562
);
6663

6764
$this->transactions = $forOtherConnections->values();

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ protected function callScope(callable $scope, array $parameters = [])
12461246
$originalWhereCount = is_null($query->wheres)
12471247
? 0 : count($query->wheres);
12481248

1249-
$result = $scope(...array_values($parameters)) ?? $this;
1249+
$result = $scope(...$parameters) ?? $this;
12501250

12511251
if (count((array) $query->wheres) > $originalWhereCount) {
12521252
$this->addNewWheresWithinGroup($query, $originalWhereCount);

0 commit comments

Comments
 (0)