Skip to content

Commit 5babbe7

Browse files
Merge branch '9.x'
2 parents 538bc3f + 8f9b14f commit 5babbe7

File tree

112 files changed

+610
-181
lines changed

Some content is hidden

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

112 files changed

+610
-181
lines changed

src/Illuminate/Auth/Console/ClearResetsCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace Illuminate\Auth\Console;
44

55
use Illuminate\Console\Command;
6-
use Symfony\Component\Console\Attribute\AsCommand;
76

8-
#[AsCommand(name: 'auth:clear-resets')]
97
class ClearResetsCommand extends Command
108
{
119
/**

src/Illuminate/Cache/Console/CacheTableCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
77
use Illuminate\Support\Composer;
8-
use Symfony\Component\Console\Attribute\AsCommand;
98

10-
#[AsCommand(name: 'cache:table')]
119
class CacheTableCommand extends Command
1210
{
1311
/**

src/Illuminate/Cache/Console/ClearCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
use Illuminate\Cache\CacheManager;
66
use Illuminate\Console\Command;
77
use Illuminate\Filesystem\Filesystem;
8-
use Symfony\Component\Console\Attribute\AsCommand;
98
use Symfony\Component\Console\Input\InputArgument;
109
use Symfony\Component\Console\Input\InputOption;
1110

12-
#[AsCommand(name: 'cache:clear')]
1311
class ClearCommand extends Command
1412
{
1513
/**

src/Illuminate/Cache/Console/ForgetCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
use Illuminate\Cache\CacheManager;
66
use Illuminate\Console\Command;
7-
use Symfony\Component\Console\Attribute\AsCommand;
87

9-
#[AsCommand(name: 'cache:forget')]
108
class ForgetCommand extends Command
119
{
1210
/**

src/Illuminate/Cache/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ protected function getSeconds($ttl)
529529
$duration = Carbon::now()->diffInRealSeconds($duration, false);
530530
}
531531

532-
return (int) $duration > 0 ? $duration : 0;
532+
return (int) ($duration > 0 ? $duration : 0);
533533
}
534534

535535
/**

src/Illuminate/Collections/Collection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,11 @@ public function groupBy($groupBy, $preserveKeys = false)
488488
}
489489

490490
foreach ($groupKeys as $groupKey) {
491-
$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
491+
$groupKey = match (true) {
492+
is_bool($groupKey) => (int) $groupKey,
493+
$groupKey instanceof \Stringable => (string) $groupKey,
494+
default => $groupKey,
495+
};
492496

493497
if (! array_key_exists($groupKey, $results)) {
494498
$results[$groupKey] = new static;
@@ -842,8 +846,8 @@ public function nth($step, $offset = 0)
842846

843847
$position = 0;
844848

845-
foreach ($this->items as $item) {
846-
if ($position % $step === $offset) {
849+
foreach ($this->slice($offset)->items as $item) {
850+
if ($position % $step === 0) {
847851
$new[] = $item;
848852
}
849853

src/Illuminate/Collections/Enumerable.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,10 @@ public function whereNotInStrict($key, $values);
460460
/**
461461
* Filter the items, removing any items that don't match the given type(s).
462462
*
463-
* @param class-string|array<array-key, class-string> $type
464-
* @return static
463+
* @template TWhereInstanceOf
464+
*
465+
* @param class-string<TWhereInstanceOf>|array<array-key, class-string<TWhereInstanceOf>> $type
466+
* @return static<TKey, TWhereInstanceOf>
465467
*/
466468
public function whereInstanceOf($type);
467469

src/Illuminate/Collections/LazyCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,8 @@ public function nth($step, $offset = 0)
848848
return new static(function () use ($step, $offset) {
849849
$position = 0;
850850

851-
foreach ($this as $item) {
852-
if ($position % $step === $offset) {
851+
foreach ($this->slice($offset) as $item) {
852+
if ($position % $step === 0) {
853853
yield $item;
854854
}
855855

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,10 @@ public function whereNotInStrict($key, $values)
679679
/**
680680
* Filter the items, removing any items that don't match the given type(s).
681681
*
682-
* @param class-string|array<array-key, class-string> $type
683-
* @return static
682+
* @template TWhereInstanceOf
683+
*
684+
* @param class-string<TWhereInstanceOf>|array<array-key, class-string<TWhereInstanceOf>> $type
685+
* @return static<TKey, TWhereInstanceOf>
684686
*/
685687
public function whereInstanceOf($type)
686688
{

src/Illuminate/Console/Command.php

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

55
use Illuminate\Support\Traits\Macroable;
6+
use ReflectionClass;
67
use Symfony\Component\Console\Command\Command as SymfonyCommand;
78
use Symfony\Component\Console\Input\InputInterface;
89
use Symfony\Component\Console\Output\OutputInterface;
@@ -86,6 +87,40 @@ public function __construct()
8687
}
8788
}
8889

90+
/**
91+
* Return the command name.
92+
*
93+
* @return string|null
94+
*/
95+
public static function getDefaultName(): ?string
96+
{
97+
$class = static::class;
98+
99+
$signature = (new ReflectionClass($class))->getDefaultProperties()['signature'] ?? null;
100+
101+
if (isset($signature)) {
102+
return Parser::parse($signature)[0];
103+
}
104+
105+
$name = (new ReflectionClass($class))->getDefaultProperties()['name'] ?? null;
106+
107+
return $name ?: parent::getDefaultName();
108+
}
109+
110+
/**
111+
* Return the command description.
112+
*
113+
* @return string|null
114+
*/
115+
public static function getDefaultDescription(): ?string
116+
{
117+
$class = static::class;
118+
119+
$description = (new ReflectionClass($class))->getDefaultProperties()['description'] ?? null;
120+
121+
return $description ?: parent::getDefaultDescription();
122+
}
123+
89124
/**
90125
* Configure the console command using a fluent definition.
91126
*

0 commit comments

Comments
 (0)