Skip to content

Commit 1103b8d

Browse files
committed
amend value types
1 parent a3a970b commit 1103b8d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Schema/Traits/Custom_Table_Query_Methods.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,13 +945,15 @@ public static function cast_value_based_on_type( string $type, $value ) {
945945
* @return array<null|string|int|float|bool|DateTimeInterface> The value as an array.
946946
*/
947947
private static function ensure_array( $value ): array {
948-
if ( is_object( $value ) && ! $value instanceof DateTimeInterface ) {
949-
throw new InvalidArgumentException( 'Value should not be an object.' );
948+
if ( ! is_int( $value ) && ! is_string( $value ) && ! is_float( $value ) && ! is_bool( $value ) && ! $value instanceof DateTimeInterface && ! is_array( $value ) ) {
949+
throw new InvalidArgumentException( 'Value should be an integer, string, float, boolean, DateTimeInterface, or array.' );
950950
}
951951

952952
if ( is_array( $value ) && $value ) {
953953
foreach ( $value as $v ) {
954-
self::ensure_array( $v );
954+
if ( ! is_int( $v ) && ! is_string( $v ) && ! is_float( $v ) && ! is_bool( $v ) && ! $v instanceof DateTimeInterface ) {
955+
throw new InvalidArgumentException( 'Offset of value should be an integer, string, float, boolean or DateTimeInterface.' );
956+
}
955957
}
956958
}
957959

0 commit comments

Comments
 (0)