Skip to content

Commit 1e51a5a

Browse files
committed
Merge branch '9.x'
# Conflicts: # CHANGELOG.md # src/Illuminate/Foundation/Application.php
2 parents 042ed1e + 6809eef commit 1e51a5a

File tree

57 files changed

+1461
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1461
-107
lines changed

src/Illuminate/Auth/SessionGuard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function attempt(array $credentials = [], $remember = false)
401401
* Attempt to authenticate a user with credentials and additional callbacks.
402402
*
403403
* @param array $credentials
404-
* @param array|callable $callbacks
404+
* @param array|callable|null $callbacks
405405
* @param bool $remember
406406
* @return bool
407407
*/

src/Illuminate/Bus/Batchable.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public function withBatchId(string $batchId)
7474
* @param int $failedJobs
7575
* @param array $failedJobIds
7676
* @param array $options
77+
* @param \Carbon\CarbonImmutable $createdAt
78+
* @param \Carbon\CarbonImmutable|null $cancelledAt
79+
* @param \Carbon\CarbonImmutable|null $finishedAt
7780
* @return array{0: $this, 1: \Illuminate\Support\Testing\BatchFake}
7881
*/
7982
public function withFakeBatch(string $id = '',

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ public function reduceWithKeys(callable $callback, $initial = null)
780780
/**
781781
* Create a collection of all elements that do not pass a given truth test.
782782
*
783-
* @param (callable(TValue, TKey): bool)|bool $callback
783+
* @param (callable(TValue, TKey): bool)|bool|TValue $callback
784784
* @return static
785785
*/
786786
public function reject($callback = true)

src/Illuminate/Collections/helpers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ function last($array)
180180
* Return the default value of the given value.
181181
*
182182
* @param mixed $value
183+
* @param mixed $args
183184
* @return mixed
184185
*/
185186
function value($value, ...$args)

src/Illuminate/Console/Command.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ public function __construct()
7979
// Once we have constructed the command, we'll set the description and other
8080
// related properties of the command. If a signature wasn't used to build
8181
// the command we'll set the arguments and the options on this command.
82-
$this->setDescription((string) $this->description);
82+
if (! isset($this->description)) {
83+
$this->setDescription((string) static::getDefaultDescription());
84+
} else {
85+
$this->setDescription((string) $this->description);
86+
}
8387

8488
$this->setHelp((string) $this->help);
8589

src/Illuminate/Console/Scheduling/Event.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ class Event
149149
*/
150150
public $mutex;
151151

152+
/**
153+
* The mutex name resolver callback.
154+
*
155+
* @var \Closure|null
156+
*/
157+
public $mutexNameResolver;
158+
152159
/**
153160
* The exit status code of the command.
154161
*
@@ -935,9 +942,28 @@ public function preventOverlapsUsing(EventMutex $mutex)
935942
*/
936943
public function mutexName()
937944
{
945+
$mutexNameResolver = $this->mutexNameResolver;
946+
947+
if (! is_null($mutexNameResolver) && is_callable($mutexNameResolver)) {
948+
return $mutexNameResolver($this);
949+
}
950+
938951
return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command);
939952
}
940953

954+
/**
955+
* Set the mutex name or name resolver callback.
956+
*
957+
* @param \Closure|string $mutexName
958+
* @return $this
959+
*/
960+
public function createMutexNameUsing(Closure|string $mutexName)
961+
{
962+
$this->mutexNameResolver = is_string($mutexName) ? fn () => $mutexName : $mutexName;
963+
964+
return $this;
965+
}
966+
941967
/**
942968
* Delete the mutex for the event.
943969
*

src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function handle()
3333
{
3434
$this->components->info('Running schedule tasks every minute.');
3535

36-
[$lastExecutionStartedAt, $keyOfLastExecutionWithOutput, $executions] = [null, null, []];
36+
[$lastExecutionStartedAt, $executions] = [null, []];
3737

3838
while (true) {
3939
usleep(100 * 1000);

src/Illuminate/Database/Concerns/CompilesJsonPaths.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function wrapJsonPath($value, $delimiter = '->')
3535
$value = preg_replace("/([\\\\]+)?\\'/", "''", $value);
3636

3737
$jsonPath = collect(explode($delimiter, $value))
38-
->map(fn ($segment) => $this->wrapJsonPathSegment($segment))
38+
->map(fn ($segment) => $this->wrapJsonPathSegment($segment))
3939
->join('.');
4040

4141
return "'$".(str_starts_with($jsonPath, '[') ? '' : '.').$jsonPath."'";

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public function isRelation($key)
532532
}
533533

534534
return method_exists($this, $key) ||
535-
(static::$relationResolvers[get_class($this)][$key] ?? null);
535+
$this->relationResolver(static::class, $key);
536536
}
537537

538538
/**

src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ trait HasRelationships
5454
*/
5555
protected static $relationResolvers = [];
5656

57+
/**
58+
* Get the dynamic relation resolver if defined or inherited, or return null.
59+
*
60+
* @param string $class
61+
* @param string $key
62+
* @return mixed
63+
*/
64+
public function relationResolver($class, $key)
65+
{
66+
if ($resolver = static::$relationResolvers[$class][$key] ?? null) {
67+
return $resolver;
68+
}
69+
70+
if ($parent = get_parent_class($class)) {
71+
return $this->relationResolver($parent, $key);
72+
}
73+
74+
return null;
75+
}
76+
5777
/**
5878
* Define a dynamic relation resolver.
5979
*

0 commit comments

Comments
 (0)