5use InvalidArgumentException;
31 $this->children[] = $expression;
34 abstract protected function getType(): string;
44 throw new InvalidArgumentException(
"The array of conditions can't be empty." );
47 foreach ( $conds as $field => $cond ) {
48 if ( is_numeric( $field ) ) {
50 throw new InvalidArgumentException( __METHOD__ .
": Only IExpression are allowed with numeric key." );
55 throw new InvalidArgumentException( __METHOD__ .
": unexpected key $field for IExpression value" );
57 $exprs[] =
new Expression( $field,
'=', $cond );
61 return new static( ...$exprs );
70 if ( !$this->children ) {
71 throw new InvalidArgumentException(
"The array of values can't be empty." );
73 $sqls = array_map(
static fn ( $value ) => $value->toSql( $dbQuoter ), $this->children );
74 return '(' . implode(
' ' . $this->
getType() .
' ', $sqls ) .
')';
78 if ( !$this->children ) {
79 throw new InvalidArgumentException(
"The array of values can't be empty." );
81 $sqls = array_map(
static fn ( $value ) => $value->toGeneralizedSql(), $this->children );
82 return '(' . implode(
' ' . $this->getType() .
' ', $sqls ) .
')';
if(!defined('MW_SETUP_CALLBACK'))