Fix Month enum argument deprecations within the library itself. #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @BenMorel ,
I tried upgrading to 0.6.1 in our project, but it broke our Behat test suite because the library in itself is now triggering tons of deprecations via
trigger_error()
. Anyway, I tried to "finish the job" of usingMonth
wherever there is a month concerned within the library itself, while leaving the usages of the|int
alternative in the tests to make sure it still works.I also had to use the
Field\MonthOfYear::check($month);
line before creating the Enum to keep the currently thrownedDateTimeException
, otherwise it would throw a PHPValueError
when given invalid values toBackendEnum::from()
.Let me know what you think. I had to rush it quite a bit, so there's probably room for improvements. I'm not a fan of how the code looks right now, because of this compatibility layer, and even more because we don't store the Month instance internally, forcing to recreate it in a lot of places. But I'm also glad we don't change that, as already discussed. 😅