simplify
[m6w6/pq-gateway] / lib / pq / Query / Expr.php
index 0f3d86e52ba1db3ae3cfb99ca9391e7f3e2396e1..31e8c969b290f21a3653a6a20e3faae7fa465846 100644 (file)
@@ -18,7 +18,7 @@ class Expr
         * @param string $e the expression or a format string followed by arguments
         * @param string ...
         */
-       function __construct($e, $arg = null) {
+       function __construct($e) {
                if (func_num_args() > 1) {
                        $e = call_user_func_array("sprintf", func_get_args());
                }
@@ -52,11 +52,14 @@ class Expr
         * @throws \UnexpectedValueException if any expr is NULL
         */
        function add(Expr $next) {
-               if ($this->isNull() || $next->isNull()) {
+               if ($this->isNull()) {
                        throw new \UnexpectedValueException("Cannot add anything to NULL");
                }
-               for ($that = $this; $that->next; $that = $that->next);
-               $that->next = $next;
+               if ($this->next) {
+                       $this->next->add($next);
+               } else {
+                       $this->next = $next;
+               }
                return $this;
        }
 }