Closed patrocle closed 11 months ago
if (
$expected === '*'
|| $value instanceof \UnitEnum && ($value->name === $expected) // <--- if false here
|| $expected === 'true' && $value === true
|| $expected === 'false' && $value === false
|| is_numeric($expected) && Str::contains($expected, '.') && $value === (float) $expected
|| is_numeric($expected) && $value === (int) $expected
|| (string) $value === $expected // <--- then it checks here
) {
$this->fireModelEvent($change, false);
}
if $value is an instance of \UnitEnum but $value->name different from $expected then it will check if (string) $value equals $expected, but we can't cast (string) $value from a Enum
Hi, thanks for your PR! Sorry for my late reply. Could you add a unit test that illustrates the problem, so the unit test shows that your code fixes that problem?
Hi, I update the test it_works_with_enumerated_casts to show that when we update an enum attribute that doesn't have an event match with $value->name === $expected, it try to cast to (string) $value === $expected Thanks
Any chance to get this merged? Solved exception on my side perfectly fine - thanks @patrocle
@jpkleemans ? 🥴🥴
@jpkleemans Hi, can you merge this ? Thanks
@patrocle thanks for adding the test. But it looks like it fails?
Could you have a look at it?
support PHP Enums hasn't been merged