Skip to content

Commit 2c682e4

Browse files
authored
[12.x] Add unified enum support across framework docs (#56271)
* add enum support for storage * add enum support for DB * add enum support for redis * add enum support for helpers * add enum support for scheduler * add enum support for broadcast * fix docblock order * add enum support for scheduler timezone() method * add enum support for request date() method * fix docblock order * fix style ci
1 parent 59b1dff commit 2c682e4

File tree

19 files changed

+58
-31
lines changed

19 files changed

+58
-31
lines changed

src/Illuminate/Broadcasting/InteractsWithBroadcasting.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Illuminate\Support\Arr;
66

7+
use function Illuminate\Support\enum_value;
8+
79
trait InteractsWithBroadcasting
810
{
911
/**
@@ -16,11 +18,13 @@ trait InteractsWithBroadcasting
1618
/**
1719
* Broadcast the event using a specific broadcaster.
1820
*
19-
* @param array|string|null $connection
21+
* @param \UnitEnum|array|string|null $connection
2022
* @return $this
2123
*/
2224
public function broadcastVia($connection = null)
2325
{
26+
$connection = enum_value($connection);
27+
2428
$this->broadcastConnection = is_null($connection)
2529
? [null]
2630
: Arr::wrap($connection);

src/Illuminate/Broadcasting/PendingBroadcast.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Illuminate\Contracts\Events\Dispatcher;
66

7+
use function Illuminate\Support\enum_value;
8+
79
class PendingBroadcast
810
{
911
/**
@@ -35,13 +37,13 @@ public function __construct(Dispatcher $events, $event)
3537
/**
3638
* Broadcast the event using a specific broadcaster.
3739
*
38-
* @param string|null $connection
40+
* @param \UnitEnum|string|null $connection
3941
* @return $this
4042
*/
4143
public function via($connection = null)
4244
{
4345
if (method_exists($this->event, 'broadcastVia')) {
44-
$this->event->broadcastVia($connection);
46+
$this->event->broadcastVia(enum_value($connection));
4547
}
4648

4749
return $this;

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Support\Carbon;
66
use InvalidArgumentException;
77

8+
use function Illuminate\Support\enum_value;
9+
810
trait ManagesFrequencies
911
{
1012
/**
@@ -639,12 +641,12 @@ public function days($days)
639641
/**
640642
* Set the timezone the date should be evaluated on.
641643
*
642-
* @param \DateTimeZone|string $timezone
644+
* @param \UnitEnum|\DateTimeZone|string $timezone
643645
* @return $this
644646
*/
645647
public function timezone($timezone)
646648
{
647-
$this->timezone = $timezone;
649+
$this->timezone = enum_value($timezone);
648650

649651
return $this;
650652
}

src/Illuminate/Console/Scheduling/Schedule.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Illuminate\Support\Traits\Macroable;
2020
use RuntimeException;
2121

22+
use function Illuminate\Support\enum_value;
23+
2224
/**
2325
* @mixin \Illuminate\Console\Scheduling\PendingEventAttributes
2426
*/
@@ -170,14 +172,17 @@ public function command($command, array $parameters = [])
170172
* Add a new job callback event to the schedule.
171173
*
172174
* @param object|string $job
173-
* @param string|null $queue
174-
* @param string|null $connection
175+
* @param \UnitEnum|string|null $queue
176+
* @param \UnitEnum|string|null $connection
175177
* @return \Illuminate\Console\Scheduling\CallbackEvent
176178
*/
177179
public function job($job, $queue = null, $connection = null)
178180
{
179181
$jobName = $job;
180182

183+
$queue = enum_value($queue);
184+
$connection = enum_value($connection);
185+
181186
if (! is_string($job)) {
182187
$jobName = method_exists($job, 'displayName')
183188
? $job->displayName()

src/Illuminate/Contracts/Filesystem/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Factory
77
/**
88
* Get a filesystem implementation.
99
*
10-
* @param string|null $name
10+
* @param \UnitEnum|string|null $name
1111
* @return \Illuminate\Contracts\Filesystem\Filesystem
1212
*/
1313
public function disk($name = null);

src/Illuminate/Contracts/Redis/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Factory
77
/**
88
* Get a Redis connection by name.
99
*
10-
* @param string|null $name
10+
* @param \UnitEnum|string|null $name
1111
* @return \Illuminate\Redis\Connections\Connection
1212
*/
1313
public function connection($name = null);

src/Illuminate/Database/Connection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
use PDOStatement;
2626
use RuntimeException;
2727

28+
use function Illuminate\Support\enum_value;
29+
2830
class Connection implements ConnectionInterface
2931
{
3032
use DetectsConcurrencyErrors,
@@ -307,13 +309,13 @@ public function getSchemaBuilder()
307309
/**
308310
* Begin a fluent query against a database table.
309311
*
310-
* @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Contracts\Database\Query\Expression|string $table
312+
* @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Contracts\Database\Query\Expression|\UnitEnum|string $table
311313
* @param string|null $as
312314
* @return \Illuminate\Database\Query\Builder
313315
*/
314316
public function table($table, $as = null)
315317
{
316-
return $this->query()->from($table, $as);
318+
return $this->query()->from(enum_value($table), $as);
317319
}
318320

319321
/**

src/Illuminate/Database/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ConnectionInterface
99
/**
1010
* Begin a fluent query against a database table.
1111
*
12-
* @param \Closure|\Illuminate\Database\Query\Builder|string $table
12+
* @param \Closure|\Illuminate\Database\Query\Builder|\UnitEnum|string $table
1313
* @param string|null $as
1414
* @return \Illuminate\Database\Query\Builder
1515
*/

src/Illuminate/Database/ConnectionResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ConnectionResolverInterface
77
/**
88
* Get a database connection instance.
99
*
10-
* @param string|null $name
10+
* @param \UnitEnum|string|null $name
1111
* @return \Illuminate\Database\ConnectionInterface
1212
*/
1313
public function connection($name = null);

src/Illuminate/Database/DatabaseManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use PDO;
1414
use RuntimeException;
1515

16+
use function Illuminate\Support\enum_value;
17+
1618
/**
1719
* @mixin \Illuminate\Database\Connection
1820
*/
@@ -85,12 +87,12 @@ public function __construct($app, ConnectionFactory $factory)
8587
/**
8688
* Get a database connection instance.
8789
*
88-
* @param string|null $name
90+
* @param \UnitEnum|string|null $name
8991
* @return \Illuminate\Database\Connection
9092
*/
9193
public function connection($name = null)
9294
{
93-
$name = $name ?: $this->getDefaultConnection();
95+
$name = enum_value($name) ?: $this->getDefaultConnection();
9496

9597
[$database, $type] = $this->parseConnectionName($name);
9698

0 commit comments

Comments
 (0)