Fixes `strpos` in `ComparisonOperation` for PHP 8 (#44007)
* Fixes * Changelog * Add breaks
This commit is contained in:
parent
9b98a85380
commit
f85d275c3a
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix strpos php8 compliant and payment gateway recommendation rule default value
|
|
@ -968,7 +968,7 @@ class DefaultPaymentGateways {
|
|||
'option_name' => 'woocommerce_onboarding_profile',
|
||||
'operation' => 'in',
|
||||
'value' => array( 'no_im_selling_offline', 'im_selling_both_online_and_offline' ),
|
||||
'default' => array(),
|
||||
'default' => '',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,22 +36,34 @@ class ComparisonOperation {
|
|||
if ( is_array( $left_operand ) && is_string( $right_operand ) ) {
|
||||
return in_array( $right_operand, $left_operand, true );
|
||||
}
|
||||
return strpos( $right_operand, $left_operand ) !== false;
|
||||
if ( is_string( $right_operand ) && is_string( $left_operand ) ) {
|
||||
return strpos( $right_operand, $left_operand ) !== false;
|
||||
}
|
||||
break;
|
||||
case '!contains':
|
||||
if ( is_array( $left_operand ) && is_string( $right_operand ) ) {
|
||||
return ! in_array( $right_operand, $left_operand, true );
|
||||
}
|
||||
return strpos( $right_operand, $left_operand ) === false;
|
||||
if ( is_string( $right_operand ) && is_string( $left_operand ) ) {
|
||||
return strpos( $right_operand, $left_operand ) === false;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
if ( is_array( $right_operand ) && is_string( $left_operand ) ) {
|
||||
return in_array( $left_operand, $right_operand, true );
|
||||
}
|
||||
return strpos( $left_operand, $right_operand ) !== false;
|
||||
if ( is_string( $left_operand ) && is_string( $right_operand ) ) {
|
||||
return strpos( $left_operand, $right_operand ) !== false;
|
||||
}
|
||||
break;
|
||||
case '!in':
|
||||
if ( is_array( $right_operand ) && is_string( $left_operand ) ) {
|
||||
return ! in_array( $left_operand, $right_operand, true );
|
||||
}
|
||||
return strpos( $left_operand, $right_operand ) === false;
|
||||
if ( is_string( $left_operand ) && is_string( $right_operand ) ) {
|
||||
return strpos( $left_operand, $right_operand ) === false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue