Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12x.] Add month enum to scheduler cron method yearlyOn() #53976

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Illuminate/Console/Enums/ScheduledMonth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Illuminate\Console\Enums;

enum ScheduledMonth: string
shaedrich marked this conversation as resolved.
Show resolved Hide resolved
{
case January = 1;

Check failure on line 7 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::January value 1 does not match the "string" type.
case February = 2;

Check failure on line 8 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::February value 2 does not match the "string" type.
case March = 3;

Check failure on line 9 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::March value 3 does not match the "string" type.
case April = 4;

Check failure on line 10 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::April value 4 does not match the "string" type.
case May = 5;

Check failure on line 11 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::May value 5 does not match the "string" type.
case June = 6;

Check failure on line 12 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::June value 6 does not match the "string" type.
case July = 7;

Check failure on line 13 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::July value 7 does not match the "string" type.
case August = 8;

Check failure on line 14 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::August value 8 does not match the "string" type.
case September = 9;

Check failure on line 15 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::September value 9 does not match the "string" type.
case October = 10;

Check failure on line 16 in src/Illuminate/Console/Enums/ScheduledMonth.php

View workflow job for this annotation

GitHub Actions / Source Code

Enum case Illuminate\Console\Enums\ScheduledMonth::October value 10 does not match the "string" type.
case November = 11;
case December = 12;
}
7 changes: 5 additions & 2 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Scheduling\Enums\ScheduledMonth;
use Illuminate\Support\Carbon;
use InvalidArgumentException;

use function Illuminate\Support\enum_value;

trait ManagesFrequencies
{
/**
Expand Down Expand Up @@ -610,7 +613,7 @@ public function yearly()
/**
* Schedule the event to run yearly on a given month, day, and time.
*
* @param int $month
* @param int|\Illuminate\Console\Scheduling\Enums\ScheduledMonth $month
* @param int|string $dayOfMonth
* @param string $time
* @return $this
Expand All @@ -620,7 +623,7 @@ public function yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')
$this->dailyAt($time);

return $this->spliceIntoPosition(3, $dayOfMonth)
->spliceIntoPosition(4, $month);
->spliceIntoPosition(4, enum_value($month));
}

/**
Expand Down
Loading