Skip to content

Commit ce67c7f

Browse files
committed
Merge branch '9.x'
# Conflicts: # CHANGELOG.md # src/Illuminate/Foundation/Application.php
2 parents 58cbcaa + 7fa4beb commit ce67c7f

File tree

80 files changed

+1726
-258
lines changed

Some content is hidden

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

80 files changed

+1726
-258
lines changed

.github/workflows/databases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
214214

215215
- name: Execute tests
216-
run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group SkipMSSQL
216+
run: vendor/bin/phpunit tests/Integration/Database --verbose
217217
env:
218218
DB_CONNECTION: sqlsrv
219219
DB_DATABASE: master

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: shivammathur/setup-php@v2
5050
with:
5151
php-version: ${{ matrix.php }}
52-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis-phpredis/[email protected], igbinary, msgpack, lzf, zstd, lz4, memcached
52+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis-phpredis/[email protected], igbinary, msgpack, lzf, zstd, lz4, memcached, gmp
5353
ini-values: error_reporting=E_ALL
5454
tools: composer:v2
5555
coverage: none
@@ -114,7 +114,7 @@ jobs:
114114
uses: shivammathur/setup-php@v2
115115
with:
116116
php-version: ${{ matrix.php }}
117-
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, pdo_mysql, fileinfo, ftp, redis, memcached
117+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, pdo_mysql, fileinfo, ftp, redis, memcached, gmp
118118
tools: composer:v2
119119
coverage: none
120120

src/Illuminate/Bus/DatabaseBatchRepository.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,25 @@ protected function toBatch($batch)
341341
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
342342
);
343343
}
344+
345+
/**
346+
* Get the underlying database connection.
347+
*
348+
* @return \Illuminate\Database\Connection
349+
*/
350+
public function getConnection()
351+
{
352+
return $this->connection;
353+
}
354+
355+
/**
356+
* Set the underlying database connection.
357+
*
358+
* @param \Illuminate\Database\Connection $connection
359+
* @return void
360+
*/
361+
public function setConnection(Connection $connection)
362+
{
363+
$this->connection = $connection;
364+
}
344365
}

src/Illuminate/Cache/RateLimiting/Limit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Limit
77
/**
88
* The rate limit signature key.
99
*
10-
* @var mixed|string
10+
* @var mixed
1111
*/
1212
public $key;
1313

@@ -35,7 +35,7 @@ class Limit
3535
/**
3636
* Create a new limit instance.
3737
*
38-
* @param mixed|string $key
38+
* @param mixed $key
3939
* @param int $maxAttempts
4040
* @param int $decayMinutes
4141
* @return void
@@ -107,7 +107,7 @@ public static function none()
107107
/**
108108
* Set the key of the rate limit.
109109
*
110-
* @param string $key
110+
* @param mixed $key
111111
* @return $this
112112
*/
113113
public function by($key)

src/Illuminate/Collections/Enumerable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,15 @@ public function union($items);
735735
* Get the min value of a given key.
736736
*
737737
* @param (callable(TValue):mixed)|string|null $callback
738-
* @return TValue
738+
* @return mixed
739739
*/
740740
public function min($callback = null);
741741

742742
/**
743743
* Get the max value of a given key.
744744
*
745745
* @param (callable(TValue):mixed)|string|null $callback
746-
* @return TValue
746+
* @return mixed
747747
*/
748748
public function max($callback = null);
749749

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function mapInto($class)
409409
* Get the min value of a given key.
410410
*
411411
* @param (callable(TValue):mixed)|string|null $callback
412-
* @return TValue
412+
* @return mixed
413413
*/
414414
public function min($callback = null)
415415
{
@@ -424,7 +424,7 @@ public function min($callback = null)
424424
* Get the max value of a given key.
425425
*
426426
* @param (callable(TValue):mixed)|string|null $callback
427-
* @return TValue
427+
* @return mixed
428428
*/
429429
public function max($callback = null)
430430
{

src/Illuminate/Console/Command.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Command extends SymfonyCommand
1313
use Concerns\CallsCommands,
1414
Concerns\HasParameters,
1515
Concerns\InteractsWithIO,
16+
Concerns\InteractsWithSignals,
1617
Macroable;
1718

1819
/**
@@ -120,9 +121,13 @@ public function run(InputInterface $input, OutputInterface $output): int
120121

121122
$this->components = $this->laravel->make(Factory::class, ['output' => $this->output]);
122123

123-
return parent::run(
124-
$this->input = $input, $this->output
125-
);
124+
try {
125+
return parent::run(
126+
$this->input = $input, $this->output
127+
);
128+
} finally {
129+
$this->untrap();
130+
}
126131
}
127132

128133
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Illuminate\Console\Concerns;
4+
5+
use Illuminate\Console\Signals;
6+
use Illuminate\Support\Arr;
7+
8+
trait InteractsWithSignals
9+
{
10+
/**
11+
* The signal registrar instance.
12+
*
13+
* @var \Illuminate\Console\Signals|null
14+
*/
15+
protected $signals;
16+
17+
/**
18+
* Define a callback to be run when the given signal(s) occurs.
19+
*
20+
* @param iterable<array-key, int>|int $signals
21+
* @param callable(int $signal): void $callback
22+
* @return void
23+
*/
24+
public function trap($signals, $callback)
25+
{
26+
Signals::whenAvailable(function () use ($signals, $callback) {
27+
$this->signals ??= new Signals(
28+
$this->getApplication()->getSignalRegistry(),
29+
);
30+
31+
collect(Arr::wrap($signals))
32+
->each(fn ($signal) => $this->signals->register($signal, $callback));
33+
});
34+
}
35+
36+
/**
37+
* Untrap signal handlers set within the command's handler.
38+
*
39+
* @return void
40+
*
41+
* @internal
42+
*/
43+
public function untrap()
44+
{
45+
if (! is_null($this->signals)) {
46+
$this->signals->unregister();
47+
48+
$this->signals = null;
49+
}
50+
}
51+
}

src/Illuminate/Console/Signals.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
3+
namespace Illuminate\Console;
4+
5+
/**
6+
* @internal
7+
*/
8+
class Signals
9+
{
10+
/**
11+
* The signal registry instance.
12+
*
13+
* @var \Symfony\Component\Console\SignalRegistry\SignalRegistry
14+
*/
15+
protected $registry;
16+
17+
/**
18+
* The signal registry's previous list of handlers.
19+
*
20+
* @var array<int, array<int, callable>>|null
21+
*/
22+
protected $previousHandlers;
23+
24+
/**
25+
* The current availability resolver, if any.
26+
*
27+
* @var (callable(): bool)|null
28+
*/
29+
protected static $availabilityResolver;
30+
31+
/**
32+
* Create a new signal registrar instance.
33+
*
34+
* @param \Symfony\Component\Console\SignalRegistry\SignalRegistry $registry
35+
* @return void
36+
*/
37+
public function __construct($registry)
38+
{
39+
$this->registry = $registry;
40+
41+
$this->previousHandlers = $this->getHandlers();
42+
}
43+
44+
/**
45+
* Register a new signal handler.
46+
*
47+
* @param int $signal
48+
* @param callable(int $signal): void $callback
49+
* @return void
50+
*/
51+
public function register($signal, $callback)
52+
{
53+
$this->previousHandlers[$signal] ??= $this->initializeSignal($signal);
54+
55+
with($this->getHandlers(), function ($handlers) use ($signal) {
56+
$handlers[$signal] ??= $this->initializeSignal($signal);
57+
58+
$this->setHandlers($handlers);
59+
});
60+
61+
$this->registry->register($signal, $callback);
62+
63+
with($this->getHandlers(), function ($handlers) use ($signal) {
64+
$lastHandlerInserted = array_pop($handlers[$signal]);
65+
66+
array_unshift($handlers[$signal], $lastHandlerInserted);
67+
68+
$this->setHandlers($handlers);
69+
});
70+
}
71+
72+
/**
73+
* Gets the signal's existing handler in array format.
74+
*
75+
* @return array<int, callable(int $signal): void>
76+
*/
77+
protected function initializeSignal($signal)
78+
{
79+
return is_callable($existingHandler = pcntl_signal_get_handler($signal))
80+
? [$existingHandler]
81+
: null;
82+
}
83+
84+
/**
85+
* Unregister the current signal handlers.
86+
*
87+
* @return array<int, array<int, callable(int $signal): void>>
88+
*/
89+
public function unregister()
90+
{
91+
$previousHandlers = $this->previousHandlers;
92+
93+
foreach ($previousHandlers as $signal => $handler) {
94+
if (is_null($handler)) {
95+
pcntl_signal($signal, SIG_DFL);
96+
97+
unset($previousHandlers[$signal]);
98+
}
99+
}
100+
101+
$this->setHandlers($previousHandlers);
102+
}
103+
104+
/**
105+
* Execute the given callback if "signals" should be used and are available.
106+
*
107+
* @param callable $callback
108+
* @return void
109+
*/
110+
public static function whenAvailable($callback)
111+
{
112+
$resolver = static::$availabilityResolver;
113+
114+
if ($resolver()) {
115+
$callback();
116+
}
117+
}
118+
119+
/**
120+
* Get the registry's handlers.
121+
*
122+
* @return array<int, array<int, callable>>
123+
*/
124+
protected function getHandlers()
125+
{
126+
return (fn () => $this->signalHandlers)
127+
->call($this->registry);
128+
}
129+
130+
/**
131+
* Set the registry's handlers.
132+
*
133+
* @param array<int, array<int, callable(int $signal):void>> $handlers
134+
* @return void
135+
*/
136+
protected function setHandlers($handlers)
137+
{
138+
(fn () => $this->signalHandlers = $handlers)
139+
->call($this->registry);
140+
}
141+
142+
/**
143+
* Set the availability resolver.
144+
*
145+
* @param callable(): bool
146+
* @return void
147+
*/
148+
public static function resolveAvailabilityUsing($resolver)
149+
{
150+
static::$availabilityResolver = $resolver;
151+
}
152+
}

src/Illuminate/Cookie/CookieJar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null,
7171
}
7272

7373
/**
74-
* Create a cookie that lasts "forever" (five years).
74+
* Create a cookie that lasts "forever" (400 days).
7575
*
7676
* @param string $name
7777
* @param string $value
@@ -85,7 +85,7 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null,
8585
*/
8686
public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null)
8787
{
88-
return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
88+
return $this->make($name, $value, 576000, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
8989
}
9090

9191
/**

0 commit comments

Comments
 (0)