mtdowling / cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
http://mtdowling.com/blog/2012/06/03/cron-expressions-in-php/
MIT License
4.9k stars 335 forks source link

Fix DayOfMonthField validation for just 'L' or 'W' #157

Closed danielsantiago closed 7 years ago

danielsantiago commented 7 years ago

Right now we can't use 'L' or 'W' for the DayOfMonthField. We get the following error:

Fatal error: Uncaught InvalidArgumentException: Invalid CRON field value L at position 2 in vendor/mtdowling/cron-expression/src/Cron/CronExpression.php on line 154

This pull request solve this problem

dragonmantank commented 7 years ago

Thanks @danielsantiago !

Looks like there are two failed tests according to Travis. Just take a look at those, and if needed provide some new tests for the coverage.

For DayOfMonth with L, I see where that is used by itself to signify the last day of the month, but for W can you provide documentation from an existing real cron instance (like cronie, or pixie cron) where W isn't used in conjunction with a numerical value?

There was a lot of stuff the old 1.x branch let through, so I'm trying to stick much closer to real cron implementations.

danielsantiago commented 7 years ago

@dragonmantank I made the changes to pass the test, also include new tests.

danielsantiago commented 7 years ago

See https://github.com/mtdowling/cron-expression/pull/159