-
-
Notifications
You must be signed in to change notification settings - Fork 86
Fix After/Before expanders error message when date/time is equal to boundary #478
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Hey @StephaneLeveugle good catch!!
Normally I'm not a huge fan of abstract classes since I prefer composition over inheritance but I don't mind it here that much. If you could extract common logic to a standalone, testable class and then pass it to different types of comparisons it would be perfect but that's not blocking merging of this PR from my point of view. |
What do you think of traits? The abstract class could easily be a trait. To be honest I'd rather have a trait because I don't really like inheritance as well, a glorified copy paste is more what I had in mind originally. I'll take a look at the tests, that's weird because I had php 8.3 installed locally 🤔 |
trait works as well, I prefer it over abstract class 👍 |
The tests fail because I used the non deprecated method So we can:
I'd rather use option 1 but that's up to you |
lets go with option number one |
huh I have no idea what's happening with the mutation tests, @StephaneLeveugle let me know if you need any help with resolving that |
I'll take a look, hopefully tonight |
There was an incompatibility between nikic/php-parser which has been upgraded to v5 and infection/infection which was still in v0.26 I tried to upgrade infection to v0.28 to support nikic/php-parser v5, but I couldn't because of vimeo/psalm which requires v4 of nikic/php-parser So I decided to lock nikic/php-parser to v4 in the project, are you fine with it? |
That's perfectly fine, I'm anyway going to split tools into standalone composer.json files like I did here to avoid such conflicts. Thanks for your contribution! |
Change Log
Added
Fixed
Changed
Removed
Deprecated
Security
Description
Hi,
I encountered a bug trying to use the after/before expanders when it wouldn't match because the value was equals to the boundary.
No error was set by the expander, which would result to a type error in DateMatcher line 54 (matcherFailed method expected a string as its 4th parameter and null was given)
While trying to fix it I saw that the explicit handling of Time was never reached because in the constructor it first checks if the boundary is a DateTime and any Time will be a valid DateTime as we can see in the Time::fromString method
I added tests to increase the coverage of the expanders and removed any explicit handling of Time.
Finally, given how similar the expanders were I created an abstract class to remove the code duplication I hope that's fine by you.
Please tell me if I missed something and thank you for this much needed library!