Skip to content

Commit 0abc9f6

Browse files
committed
Merge branch '10.x'
2 parents a3fc3f2 + 5985650 commit 0abc9f6

File tree

19 files changed

+369
-50
lines changed

19 files changed

+369
-50
lines changed

src/Illuminate/Auth/Passwords/PasswordBrokerManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function createTokenRepository(array $config)
103103
* Get the password broker configuration.
104104
*
105105
* @param string $name
106-
* @return array
106+
* @return array|null
107107
*/
108108
protected function getConfig($name)
109109
{

src/Illuminate/Collections/helpers.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,42 @@ function data_set(&$target, $key, $value, $overwrite = true)
149149
}
150150
}
151151

152+
if (! function_exists('data_forget')) {
153+
/**
154+
* Remove / unset an item from an array or object using "dot" notation.
155+
*
156+
* @param mixed $target
157+
* @param string|array|int|null $key
158+
* @return mixed
159+
*/
160+
function data_forget(&$target, $key)
161+
{
162+
$segments = is_array($key) ? $key : explode('.', $key);
163+
164+
if (($segment = array_shift($segments)) === '*' && Arr::accessible($target)) {
165+
if ($segments) {
166+
foreach ($target as &$inner) {
167+
data_forget($inner, $segments);
168+
}
169+
}
170+
} elseif (Arr::accessible($target)) {
171+
if ($segments && Arr::exists($target, $segment)) {
172+
data_forget($target[$segment], $segments);
173+
} else {
174+
Arr::forget($target, $segment);
175+
}
176+
} elseif (is_object($target)) {
177+
if ($segments && isset($target->{$segment})) {
178+
data_forget($target->{$segment}, $segments);
179+
} elseif (isset($target->{$segment})) {
180+
unset($target->{$segment});
181+
}
182+
}
183+
184+
return $target;
185+
}
186+
}
187+
152188
if (! function_exists('head')) {
153189
/**
154190
* Get the first element of an array. Useful for method chaining.

src/Illuminate/Database/Console/PruneCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Illuminate\Database\Eloquent\MassPrunable;
88
use Illuminate\Database\Eloquent\Prunable;
99
use Illuminate\Database\Eloquent\SoftDeletes;
10+
use Illuminate\Database\Events\ModelPruningFinished;
11+
use Illuminate\Database\Events\ModelPruningStarting;
1012
use Illuminate\Database\Events\ModelsPruned;
1113
use Illuminate\Support\Str;
1214
use InvalidArgumentException;
@@ -70,10 +72,14 @@ public function handle(Dispatcher $events)
7072
$this->components->twoColumnDetail($event->model, "{$event->count} records");
7173
});
7274

75+
$events->dispatch(new ModelPruningStarting($models->all()));
76+
7377
$models->each(function ($model) {
7478
$this->pruneModel($model);
7579
});
7680

81+
$events->dispatch(new ModelPruningFinished($models->all()));
82+
7783
$events->forget(ModelsPruned::class);
7884
}
7985

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Illuminate\Database\Events;
4+
5+
class ModelPruningFinished
6+
{
7+
/**
8+
* The class names of the models that were pruned.
9+
*
10+
* @var array<class-string>
11+
*/
12+
public $models;
13+
14+
/**
15+
* Create a new event instance.
16+
*
17+
* @param array<class-string> $models
18+
* @return void
19+
*/
20+
public function __construct($models)
21+
{
22+
$this->models = $models;
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Illuminate\Database\Events;
4+
5+
class ModelPruningStarting
6+
{
7+
/**
8+
* The class names of the models that will be pruned.
9+
*
10+
* @var array<class-string>
11+
*/
12+
public $models;
13+
14+
/**
15+
* Create a new event instance.
16+
*
17+
* @param array<class-string> $models
18+
* @return void
19+
*/
20+
public function __construct($models)
21+
{
22+
$this->models = $models;
23+
}
24+
}

src/Illuminate/Foundation/Console/Kernel.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Illuminate\Support\InteractsWithTime;
2121
use Illuminate\Support\Str;
2222
use ReflectionClass;
23+
use SplFileInfo;
2324
use Symfony\Component\Console\ConsoleEvents;
2425
use Symfony\Component\Console\Event\ConsoleCommandEvent;
2526
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
@@ -339,12 +340,8 @@ protected function load($paths)
339340

340341
$namespace = $this->app->getNamespace();
341342

342-
foreach ((new Finder)->in($paths)->files() as $command) {
343-
$command = $namespace.str_replace(
344-
['/', '.php'],
345-
['\\', ''],
346-
Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR)
347-
);
343+
foreach ((new Finder)->in($paths)->files() as $file) {
344+
$command = $this->commandClassFromFile($file, $namespace);
348345

349346
if (is_subclass_of($command, Command::class) &&
350347
! (new ReflectionClass($command))->isAbstract()) {
@@ -355,6 +352,22 @@ protected function load($paths)
355352
}
356353
}
357354

355+
/**
356+
* Extract the command class name from the given file path.
357+
*
358+
* @param \SplFileInfo $file
359+
* @param string $namespace
360+
* @return string
361+
*/
362+
protected function commandClassFromFile(SplFileInfo $file, string $namespace): string
363+
{
364+
return $namespace.str_replace(
365+
['/', '.php'],
366+
['\\', ''],
367+
Str::after($file->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR)
368+
);
369+
}
370+
358371
/**
359372
* Register the given command with the console application.
360373
*

src/Illuminate/Foundation/Vite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,15 +673,15 @@ protected function assetPath($path, $secure = null)
673673
* @param string $buildDirectory
674674
* @return array
675675
*
676-
* @throws \Exception
676+
* @throws \Illuminate\Foundation\ViteManifestNotFoundException
677677
*/
678678
protected function manifest($buildDirectory)
679679
{
680680
$path = $this->manifestPath($buildDirectory);
681681

682682
if (! isset(static::$manifests[$path])) {
683683
if (! is_file($path)) {
684-
throw new Exception("Vite manifest not found at: {$path}");
684+
throw new ViteManifestNotFoundException("Vite manifest not found at: $path");
685685
}
686686

687687
static::$manifests[$path] = json_decode(file_get_contents($path), true);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation;
4+
5+
use Exception;
6+
7+
class ViteManifestNotFoundException extends Exception
8+
{
9+
//
10+
}

src/Illuminate/Log/LogManager.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,7 @@ protected function prepareHandler(HandlerInterface $handler, array $config = [])
471471
*/
472472
protected function formatter()
473473
{
474-
return tap(new LineFormatter(null, $this->dateFormat, true, true), function ($formatter) {
475-
$formatter->includeStacktraces();
476-
});
474+
return new LineFormatter(null, $this->dateFormat, true, true, true);
477475
}
478476

479477
/**

src/Illuminate/Support/Str.php

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ public static function isAscii($value)
421421
}
422422

423423
/**
424-
* Determine if a given string is valid JSON.
424+
* Determine if a given value is valid JSON.
425425
*
426-
* @param string $value
426+
* @param mixed $value
427427
* @return bool
428428
*/
429429
public static function isJson($value)
@@ -442,9 +442,47 @@ public static function isJson($value)
442442
}
443443

444444
/**
445-
* Determine if a given string is a valid UUID.
445+
* Determine if a given value is a valid URL.
446446
*
447-
* @param string $value
447+
* @param mixed $value
448+
* @return bool
449+
*/
450+
public static function isUrl($value)
451+
{
452+
if (! is_string($value)) {
453+
return false;
454+
}
455+
456+
/*
457+
* This pattern is derived from Symfony\Component\Validator\Constraints\UrlValidator (5.0.7).
458+
*
459+
* (c) Fabien Potencier <[email protected]> http://symfony.com
460+
*/
461+
$pattern = '~^
462+
(aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|chrome-extension|cid|coap|coap\+tcp|coap\+ws|coaps|coaps\+tcp|coaps\+ws|com-eventbrite-attendee|content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|irc6|ircs|iris|iris\.beep|iris\.lwz|iris\.xpc|iris\.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|smb|sms|smtp|snews|snmp|soap\.beep|soap\.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|wyciwyg|xcon|xcon-userid|xfire|xmlrpc\.beep|xmlrpc\.beeps|xmpp|xri|ymsgr|z39\.50|z39\.50r|z39\.50s):// # protocol
463+
(((?:[\_\.\pL\pN-]|%[0-9A-Fa-f]{2})+:)?((?:[\_\.\pL\pN-]|%[0-9A-Fa-f]{2})+)@)? # basic auth
464+
(
465+
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
466+
| # or
467+
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
468+
| # or
469+
\[
470+
(?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|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(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::))))
471+
\] # an IPv6 address
472+
)
473+
(:[0-9]+)? # a port (optional)
474+
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%[0-9A-Fa-f]{2})* )* # a path
475+
(?:\? (?:[\pL\pN\-._\~!$&\'\[\]()*+,;=:@/?]|%[0-9A-Fa-f]{2})* )? # a query (optional)
476+
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%[0-9A-Fa-f]{2})* )? # a fragment (optional)
477+
$~ixu';
478+
479+
return preg_match($pattern, $value) > 0;
480+
}
481+
482+
/**
483+
* Determine if a given value is a valid UUID.
484+
*
485+
* @param mixed $value
448486
* @return bool
449487
*/
450488
public static function isUuid($value)
@@ -457,9 +495,9 @@ public static function isUuid($value)
457495
}
458496

459497
/**
460-
* Determine if a given string is a valid ULID.
498+
* Determine if a given value is a valid ULID.
461499
*
462-
* @param string $value
500+
* @param mixed $value
463501
* @return bool
464502
*/
465503
public static function isUlid($value)

0 commit comments

Comments
 (0)