66use Cake \ORM \TableRegistry ;
77use Cake \Routing \Router ;
88use Cake \Validation \Validation ;
9+ use DateTimeInterface ;
910use InvalidArgumentException ;
1011use Shim \Model \Table \Table as ShimTable ;
1112use Tools \I18n \Date ;
@@ -396,7 +397,7 @@ public function validateDateTime($value, array $options = [], array $context = [
396397 if ($ after ) {
397398 if (!is_object ($ after )) {
398399 $ after = new DateTime ($ after );
399- } elseif ($ after instanceof \ DateTimeInterface && !($ after instanceof DateTime)) {
400+ } elseif ($ after instanceof DateTimeInterface && !($ after instanceof DateTime)) {
400401 $ after = new DateTime ($ after );
401402 }
402403 }
@@ -408,7 +409,7 @@ public function validateDateTime($value, array $options = [], array $context = [
408409 if ($ before ) {
409410 if (!is_object ($ before )) {
410411 $ before = new DateTime ($ before );
411- } elseif ($ before instanceof \ DateTimeInterface && !($ before instanceof DateTime)) {
412+ } elseif ($ before instanceof DateTimeInterface && !($ before instanceof DateTime)) {
412413 $ before = new DateTime ($ before );
413414 }
414415 }
@@ -477,7 +478,7 @@ public function validateDate($value, array $options = [], array $context = []) {
477478 $ date = $ value ;
478479 if (!is_object ($ value )) {
479480 $ date = new Date ($ value );
480- } elseif ($ value instanceof \ DateTimeInterface) {
481+ } elseif ($ value instanceof DateTimeInterface) {
481482 $ date = new Date ($ value );
482483 }
483484
@@ -494,7 +495,7 @@ public function validateDate($value, array $options = [], array $context = []) {
494495 /** @var \Cake\I18n\DateTime $after */
495496 if (!is_object ($ after )) {
496497 $ after = new Date ($ after );
497- } elseif ($ after instanceof \ DateTimeInterface) {
498+ } elseif ($ after instanceof DateTimeInterface) {
498499 $ after = new Date ($ after );
499500 }
500501 if ($ after ->greaterThan ($ compare )) {
@@ -511,7 +512,7 @@ public function validateDate($value, array $options = [], array $context = []) {
511512 /** @var \Cake\I18n\DateTime $before */
512513 if (!is_object ($ before )) {
513514 $ before = new Date ($ before );
514- } elseif ($ before instanceof \ DateTimeInterface) {
515+ } elseif ($ before instanceof DateTimeInterface) {
515516 $ before = new Date ($ before );
516517 }
517518 if ($ before ->lessThan ($ compare )) {
@@ -550,7 +551,7 @@ public function validateTime($value, array $options = [], array $context = []) {
550551 // Extract time string for validation
551552 $ timeString = $ value ;
552553 if (is_object ($ value )) {
553- if ($ value instanceof \ DateTimeInterface) {
554+ if ($ value instanceof DateTimeInterface) {
554555 $ timeString = $ value ->format ('H:i:s ' );
555556 }
556557 } else {
@@ -584,7 +585,7 @@ public function validateTime($value, array $options = [], array $context = []) {
584585 $ dateTimeParts = explode (' ' , (string )$ after , 2 );
585586 $ timeString = array_pop ($ dateTimeParts );
586587 $ after = new Time ($ timeString );
587- } elseif ($ after instanceof \ DateTimeInterface && !($ after instanceof Time)) {
588+ } elseif ($ after instanceof DateTimeInterface && !($ after instanceof Time)) {
588589 $ after = new Time ($ after ->format ('H:i:s ' ));
589590 }
590591
@@ -618,7 +619,7 @@ public function validateTime($value, array $options = [], array $context = []) {
618619 $ dateTimeParts = explode (' ' , (string )$ before , 2 );
619620 $ timeString = array_pop ($ dateTimeParts );
620621 $ before = new Time ($ timeString );
621- } elseif ($ before instanceof \ DateTimeInterface && !($ before instanceof Time)) {
622+ } elseif ($ before instanceof DateTimeInterface && !($ before instanceof Time)) {
622623 $ before = new Time ($ before ->format ('H:i:s ' ));
623624 }
624625
0 commit comments