Esempio n. 1
0
 /**
  * Enter description here...
  *
  * @param OpExpr $left
  * @param ExprOp $op
  * @param OpExpr $right
  * @param boolean $not
  */
 public function transform(&$left, &$op, &$right, &$not)
 {
     if (!$left->isOpExpr() || !$right->isOpExpr() || !DefaultOpCollection::isBoolean($op)) {
         return;
     }
     if ($left->isTextOnly() && $right->isDBonly()) {
         // we just swap the items around, to ease other transformations
         $tmp = $left;
         $left = $right;
         $right = $tmp;
         return;
     }
     if ($op != $right->op() || !DefaultOpCollection::isBoolean($right)) {
         return;
     }
     if ($op == ExprOp::OP_OR && ($not || $right->not())) {
         // NOTE: we can't transform. e.g.
         // db or !(db or txt) => db or !db and !txt
         // so nothing to do
         // BUT: db and !(db and txt) => db and !db and !txt
         return;
     }
     $rightLeft = $right->left();
     $rightRight = $right->right();
     if ($left->isDBonly() && $rightLeft->isDBonly()) {
         $newLeft = new OpExpr($left, $op, $rightLeft);
         $right = $rightRight;
         $left = $newLeft;
         return;
     }
     if ($left->isTextOnly() && $rightRight->isTextOnly()) {
         $newRight = new OpExpr($left, $op, $rightRight);
         $left = $rightLeft;
         $right = $newRight;
         return;
     }
 }