Get last errors to return false#70
Conversation
- Change the type on static property - empty check on filtered array - actually return false if empty
|
Now, we have an incompatibility with PHP 8.1 (because PHP actually returned this array before 8.2), but I would be fine to just add |
|
Does this mean that the version of Carbon this would be tagged in would require PHP ^8.2 also? |
No, this just means that the behavior of returning I don't expect it to be an issue anyway because PHP 8.1 no longer receives any update, so it shouldn't change and the behavior will be unchanged compared to current version of Carbon for people using PHP 8.1, so actually the small breaking change that can create a bit of friction for people relying on the array result is for the users on PHP >= 8.2 when they'll upgrade to the next version of Carbon or later for people upgrading from PHP 8.1 to higher (which is not great to happen on a minor version but would probably still fit as small-enough for our breaking-change policy) |
Closes briannesbitt/Carbon#3224
As described in the above issue (on the parent repo of this one), the non-expected behaviour of
Carbon::getLastErrors()returning an array, albeit full of empty arrays and zero counts, is not equivalent toDateTime::getLastErrors(). This makes it a little less than ideal to work with when using this method in conjunction withCarbon::canBeCreatedFromFormat()to do edge case date validation.I imagine that people using this library may have their own work-around in place for this, so I feel like this would be considered a breaking change and I'm unsure what the best approach would be to get this behaviour aligned with the
DateTimenamesake.I'd still like to make these changes visible and hope to open a discussion, be it worthy of one, about how it can be done.
TIA