You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Compare new value of the field with existing one without retrieving.
315
334
* In the trivial case it's same as ($value == $model->get($name)) but this method can be used for:
@@ -326,32 +345,17 @@ public function compare($value, $value2 = null): bool
326
345
$value2 = $this->get();
327
346
}
328
347
329
-
// TODO code below is not nice, we want to replace it, the purpose of the code is simply to
330
-
// compare if typecasted values are the same using strict comparison (===) or nor
331
-
$typecastFunc = function ($v) {
332
-
// do not typecast null values, because that implies calling normalize() which tries to validate that value can't be null in case field value is required
333
-
if ($v === null) {
334
-
return$v;
335
-
}
336
-
337
-
if ($this->getOwner()->persistence === null) {
338
-
$v = $this->normalize($v);
339
-
340
-
// without persistence, we can not do a lot with non-scalar types, but as DateTime
341
-
// is used often, fix the compare for them
342
-
// TODO probably create and use a default persistence
343
-
if (is_scalar($v)) {
344
-
return (string) $v;
345
-
} elseif ($vinstanceof \DateTimeInterface) {
346
-
return$v->getTimestamp() . '.' . $v->format('u');
347
-
}
348
-
349
-
returnserialize($v);
348
+
$typecastFunc = function ($value): ?string {
349
+
// do not typecast null values, because that implies calling normalize()
350
+
// which tries to validate if value is not null in case field value is required
0 commit comments