Problem
In the box_values method, when $box is a string, the current implementation expects $box to always be an array. This creates unnecessary type constraints and can break scenarios where a string is valid input.
Suggested Fix
Update box_values to use the following logic:
if ( ! is_array( $box ) ) {
return $box;
}
This way, when $box is a string, it will simply be returned, making the function more robust.
Code Reference
public static function box_values( $box, $box_default = array() ) {
if ( ! is_array( $box ) ) {
return $box;
}
// existing logic here
}
Expected Behavior
- If
$box is a string, return the string as is.
- If
$box is an array, continue with the current array logic.
Benefit
This change improves compatibility and prevents errors when a string is given as input.
Problem
In the
box_valuesmethod, when$boxis a string, the current implementation expects$boxto always be an array. This creates unnecessary type constraints and can break scenarios where a string is valid input.Suggested Fix
Update
box_valuesto use the following logic:This way, when
$boxis a string, it will simply be returned, making the function more robust.Code Reference
Expected Behavior
$boxis a string, return the string as is.$boxis an array, continue with the current array logic.Benefit
This change improves compatibility and prevents errors when a string is given as input.