From 1844b19a3e11e1f0bc58231db8c081ba14bd3dbd Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 11:23:38 +0200 Subject: [PATCH 01/30] Adding BinaryOp and contains multiple arguments support Adding multiple argument support for rAnd, rOr, and contains --- rdb/Queries/Aggregations/Contains.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rdb/Queries/Aggregations/Contains.php b/rdb/Queries/Aggregations/Contains.php index 673d399..754d717 100644 --- a/rdb/Queries/Aggregations/Contains.php +++ b/rdb/Queries/Aggregations/Contains.php @@ -7,12 +7,13 @@ class Contains extends ValuedQuery { - public function __construct(ValuedQuery $sequence, $value) + public function __construct(ValuedQuery $sequence, array $values) { - $value = $this->nativeToDatumOrFunction($value); - $this->setPositionalArg(0, $sequence); - $this->setPositionalArg(1, $value); + + foreach($values as $k => $value) { + $this->setPositionalArg($k+1, $this->nativeToDatumOrFunction($value)); + } } protected function getTermType() From 109e34bdd9b9ab780f553ff4afdd0922fb08e6a5 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 11:27:05 +0200 Subject: [PATCH 02/30] Add files via upload --- rdb/Queries/Math/Add.php | 2 +- rdb/Queries/Math/BinaryOp.php | 7 ++++--- rdb/Queries/Math/Div.php | 2 +- rdb/Queries/Math/Eq.php | 2 +- rdb/Queries/Math/Ge.php | 2 +- rdb/Queries/Math/Gt.php | 2 +- rdb/Queries/Math/Le.php | 2 +- rdb/Queries/Math/Lt.php | 2 +- rdb/Queries/Math/Mod.php | 2 +- rdb/Queries/Math/Mul.php | 2 +- rdb/Queries/Math/Ne.php | 2 +- rdb/Queries/Math/RAnd.php | 4 ++-- rdb/Queries/Math/ROr.php | 4 ++-- rdb/Queries/Math/Sub.php | 2 +- 14 files changed, 19 insertions(+), 18 deletions(-) diff --git a/rdb/Queries/Math/Add.php b/rdb/Queries/Math/Add.php index 3c8a3e0..511f459 100644 --- a/rdb/Queries/Math/Add.php +++ b/rdb/Queries/Math/Add.php @@ -9,6 +9,6 @@ class Add extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_ADD, $value, $other); + parent::__construct(TermTermType::PB_ADD, [$value, $other]); } } diff --git a/rdb/Queries/Math/BinaryOp.php b/rdb/Queries/Math/BinaryOp.php index d91786d..ee1373f 100644 --- a/rdb/Queries/Math/BinaryOp.php +++ b/rdb/Queries/Math/BinaryOp.php @@ -6,12 +6,13 @@ class BinaryOp extends ValuedQuery { - public function __construct($termType, $value, $other) + public function __construct($termType, array $exprs) { $this->termType = $termType; - $this->setPositionalArg(0, $this->nativeToDatum($value)); - $this->setPositionalArg(1, $this->nativeToDatum($other)); + foreach ($exprs as $k => $expr) { + $this->setPositionalArg($k, $this->nativeToDatum($expr)); + } } protected function getTermType() diff --git a/rdb/Queries/Math/Div.php b/rdb/Queries/Math/Div.php index 3174b22..eec6b0d 100644 --- a/rdb/Queries/Math/Div.php +++ b/rdb/Queries/Math/Div.php @@ -9,6 +9,6 @@ class Div extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_DIV, $value, $other); + parent::__construct(TermTermType::PB_DIV, [$value, $other]); } } diff --git a/rdb/Queries/Math/Eq.php b/rdb/Queries/Math/Eq.php index 47e084b..6ce2a41 100644 --- a/rdb/Queries/Math/Eq.php +++ b/rdb/Queries/Math/Eq.php @@ -9,6 +9,6 @@ class Eq extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_EQ, $value, $other); + parent::__construct(TermTermType::PB_EQ, [$value, $other]); } } diff --git a/rdb/Queries/Math/Ge.php b/rdb/Queries/Math/Ge.php index a6f2ded..b4b8ca4 100644 --- a/rdb/Queries/Math/Ge.php +++ b/rdb/Queries/Math/Ge.php @@ -8,6 +8,6 @@ class Ge extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_GE, $value, $other); + parent::__construct(TermTermType::PB_GE, [$value, $other]); } } diff --git a/rdb/Queries/Math/Gt.php b/rdb/Queries/Math/Gt.php index 1f78875..d1985b6 100644 --- a/rdb/Queries/Math/Gt.php +++ b/rdb/Queries/Math/Gt.php @@ -9,6 +9,6 @@ class Gt extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_GT, $value, $other); + parent::__construct(TermTermType::PB_GT, [$value, $other]); } } diff --git a/rdb/Queries/Math/Le.php b/rdb/Queries/Math/Le.php index d296528..98c5da0 100644 --- a/rdb/Queries/Math/Le.php +++ b/rdb/Queries/Math/Le.php @@ -8,6 +8,6 @@ class Le extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_LE, $value, $other); + parent::__construct(TermTermType::PB_LE, [$value, $other]); } } diff --git a/rdb/Queries/Math/Lt.php b/rdb/Queries/Math/Lt.php index fed06b9..9ed3d63 100644 --- a/rdb/Queries/Math/Lt.php +++ b/rdb/Queries/Math/Lt.php @@ -8,6 +8,6 @@ class Lt extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_LT, $value, $other); + parent::__construct(TermTermType::PB_LT, [$value, $other]); } } diff --git a/rdb/Queries/Math/Mod.php b/rdb/Queries/Math/Mod.php index eda29bf..fc8145a 100644 --- a/rdb/Queries/Math/Mod.php +++ b/rdb/Queries/Math/Mod.php @@ -8,6 +8,6 @@ class Mod extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_MOD, $value, $other); + parent::__construct(TermTermType::PB_MOD, [$value, $other]); } } diff --git a/rdb/Queries/Math/Mul.php b/rdb/Queries/Math/Mul.php index 615c5a6..d1f8f43 100644 --- a/rdb/Queries/Math/Mul.php +++ b/rdb/Queries/Math/Mul.php @@ -8,6 +8,6 @@ class Mul extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_MUL, $value, $other); + parent::__construct(TermTermType::PB_MUL, [$value, $other]); } } diff --git a/rdb/Queries/Math/Ne.php b/rdb/Queries/Math/Ne.php index 3d95e9c..577ad23 100644 --- a/rdb/Queries/Math/Ne.php +++ b/rdb/Queries/Math/Ne.php @@ -9,6 +9,6 @@ class Ne extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_NE, $value, $other); + parent::__construct(TermTermType::PB_NE, [$value, $other]); } } diff --git a/rdb/Queries/Math/RAnd.php b/rdb/Queries/Math/RAnd.php index 3186fed..5abec05 100644 --- a/rdb/Queries/Math/RAnd.php +++ b/rdb/Queries/Math/RAnd.php @@ -6,8 +6,8 @@ class RAnd extends BinaryOp { - public function __construct($value, $other) + public function __construct(array $exprs) { - parent::__construct(TermTermType::PB_AND, $value, $other); + parent::__construct(TermTermType::PB_AND, $exprs); } } diff --git a/rdb/Queries/Math/ROr.php b/rdb/Queries/Math/ROr.php index 449604e..cd6b2bc 100644 --- a/rdb/Queries/Math/ROr.php +++ b/rdb/Queries/Math/ROr.php @@ -6,8 +6,8 @@ class ROr extends BinaryOp { - public function __construct($value, $other) + public function __construct(array $exprs) { - parent::__construct(TermTermType::PB_OR, $value, $other); + parent::__construct(TermTermType::PB_OR, $exprs); } } diff --git a/rdb/Queries/Math/Sub.php b/rdb/Queries/Math/Sub.php index a82174e..7ddac69 100644 --- a/rdb/Queries/Math/Sub.php +++ b/rdb/Queries/Math/Sub.php @@ -8,6 +8,6 @@ class Sub extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_SUB, $value, $other); + parent::__construct(TermTermType::PB_SUB, [$value, $other]); } } From 8811a6f125b5534b2def557571bd1da5ecb08c46 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:43:51 +0200 Subject: [PATCH 03/30] PSR-2 compliing --- rdb/Queries/Aggregations/Contains.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rdb/Queries/Aggregations/Contains.php b/rdb/Queries/Aggregations/Contains.php index 754d717..983eda4 100644 --- a/rdb/Queries/Aggregations/Contains.php +++ b/rdb/Queries/Aggregations/Contains.php @@ -11,7 +11,8 @@ public function __construct(ValuedQuery $sequence, array $values) { $this->setPositionalArg(0, $sequence); - foreach($values as $k => $value) { + foreach ($values as $k => $value) + { $this->setPositionalArg($k+1, $this->nativeToDatumOrFunction($value)); } } From 65cf886baab2b71aff3bbb9309fa4eb00080fe3e Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:45:52 +0200 Subject: [PATCH 04/30] PSR-2 compliing --- rdb/DatumConverter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rdb/DatumConverter.php b/rdb/DatumConverter.php index 055e3a9..eb67ada 100644 --- a/rdb/DatumConverter.php +++ b/rdb/DatumConverter.php @@ -158,7 +158,6 @@ public function canEncodeAsJson($v) } return false; - } public function wrapImplicitVar(Query $q) From fc04dd76fe8d03b8a31ad6e7e021edbedb567b11 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:47:39 +0200 Subject: [PATCH 05/30] PSR-2 compliing --- rdb/Queries/Aggregations/Contains.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rdb/Queries/Aggregations/Contains.php b/rdb/Queries/Aggregations/Contains.php index 983eda4..e3353e4 100644 --- a/rdb/Queries/Aggregations/Contains.php +++ b/rdb/Queries/Aggregations/Contains.php @@ -11,8 +11,7 @@ public function __construct(ValuedQuery $sequence, array $values) { $this->setPositionalArg(0, $sequence); - foreach ($values as $k => $value) - { + foreach ($values as $k => $value) { $this->setPositionalArg($k+1, $this->nativeToDatumOrFunction($value)); } } From 81808d393ed798125ef9171fa9dde63d3e5c5f18 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:48:40 +0200 Subject: [PATCH 06/30] PHP<7 compatibility --- rdb/Queries/Math/Add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Add.php b/rdb/Queries/Math/Add.php index 511f459..5eddf6c 100644 --- a/rdb/Queries/Math/Add.php +++ b/rdb/Queries/Math/Add.php @@ -9,6 +9,6 @@ class Add extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_ADD, [$value, $other]); + parent::__construct(TermTermType::PB_ADD, array($value, $other)); } } From 8392b8798312e18fd7697f0cbca04141f9dcee96 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:49:30 +0200 Subject: [PATCH 07/30] PHP<7 compatibility --- rdb/Queries/Math/Eq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Eq.php b/rdb/Queries/Math/Eq.php index 6ce2a41..00ed410 100644 --- a/rdb/Queries/Math/Eq.php +++ b/rdb/Queries/Math/Eq.php @@ -9,6 +9,6 @@ class Eq extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_EQ, [$value, $other]); + parent::__construct(TermTermType::PB_EQ, array($value, $other)); } } From 937e336d9539ad842e02c1afaeeaa319aa933778 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:49:54 +0200 Subject: [PATCH 08/30] PHP<7 compatibility --- rdb/Queries/Math/Le.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Le.php b/rdb/Queries/Math/Le.php index 98c5da0..a436026 100644 --- a/rdb/Queries/Math/Le.php +++ b/rdb/Queries/Math/Le.php @@ -8,6 +8,6 @@ class Le extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_LE, [$value, $other]); + parent::__construct(TermTermType::PB_LE, array($value, $other)); } } From 171810885410ccb947acf5f7fff893d532f52727 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:50:22 +0200 Subject: [PATCH 09/30] PHP<7 compatibility --- rdb/Queries/Math/Mul.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Mul.php b/rdb/Queries/Math/Mul.php index d1f8f43..3292960 100644 --- a/rdb/Queries/Math/Mul.php +++ b/rdb/Queries/Math/Mul.php @@ -8,6 +8,6 @@ class Mul extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_MUL, [$value, $other]); + parent::__construct(TermTermType::PB_MUL, array($value, $other)); } } From b5eb1b308b709fb71dd3d222bd3a6294abadc08c Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:50:47 +0200 Subject: [PATCH 10/30] PHP<7 compatibility --- rdb/Queries/Math/Div.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Div.php b/rdb/Queries/Math/Div.php index eec6b0d..d63da90 100644 --- a/rdb/Queries/Math/Div.php +++ b/rdb/Queries/Math/Div.php @@ -9,6 +9,6 @@ class Div extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_DIV, [$value, $other]); + parent::__construct(TermTermType::PB_DIV, array($value, $other)); } } From 608f4724dbace942be0ef6a29fd7858d50dbebe7 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:51:13 +0200 Subject: [PATCH 11/30] PHP<7 compatibility --- rdb/Queries/Math/Ne.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Ne.php b/rdb/Queries/Math/Ne.php index 577ad23..8202da1 100644 --- a/rdb/Queries/Math/Ne.php +++ b/rdb/Queries/Math/Ne.php @@ -9,6 +9,6 @@ class Ne extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_NE, [$value, $other]); + parent::__construct(TermTermType::PB_NE, array($value, $other)); } } From cdbbcfc89a118dba9be47bcf05653da9df465aa4 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:51:57 +0200 Subject: [PATCH 12/30] PHP<7 compatibility --- rdb/Queries/Math/Lt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Lt.php b/rdb/Queries/Math/Lt.php index 9ed3d63..7aaa7b0 100644 --- a/rdb/Queries/Math/Lt.php +++ b/rdb/Queries/Math/Lt.php @@ -8,6 +8,6 @@ class Lt extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_LT, [$value, $other]); + parent::__construct(TermTermType::PB_LT, array($value, $other)); } } From 4c02fc3aab631a387254de1f46d5c0f77d54ef27 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:52:18 +0200 Subject: [PATCH 13/30] PHP<7 compatibility --- rdb/Queries/Math/Ge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Ge.php b/rdb/Queries/Math/Ge.php index b4b8ca4..cd9f00a 100644 --- a/rdb/Queries/Math/Ge.php +++ b/rdb/Queries/Math/Ge.php @@ -8,6 +8,6 @@ class Ge extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_GE, [$value, $other]); + parent::__construct(TermTermType::PB_GE, array($value, $other)); } } From 1e2f03ed73a41c57f3027f16f616a9a7bc2e68a6 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:52:54 +0200 Subject: [PATCH 14/30] PHP<7 compatibility --- rdb/Queries/Math/Gt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Gt.php b/rdb/Queries/Math/Gt.php index d1985b6..d10c853 100644 --- a/rdb/Queries/Math/Gt.php +++ b/rdb/Queries/Math/Gt.php @@ -9,6 +9,6 @@ class Gt extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_GT, [$value, $other]); + parent::__construct(TermTermType::PB_GT, array($value, $other)); } } From 6be583de6c9dd2d741adf57599752a8ec3d00ffd Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:53:35 +0200 Subject: [PATCH 15/30] PHP<7 compatibility --- rdb/Queries/Math/Sub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Sub.php b/rdb/Queries/Math/Sub.php index 7ddac69..3f5a34e 100644 --- a/rdb/Queries/Math/Sub.php +++ b/rdb/Queries/Math/Sub.php @@ -8,6 +8,6 @@ class Sub extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_SUB, [$value, $other]); + parent::__construct(TermTermType::PB_SUB, array($value, $other)); } } From 16d1bb8a7a635c34c616539843164dccc2948e5e Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:54:20 +0200 Subject: [PATCH 16/30] PHP<7 compatibility --- rdb/Queries/Math/Mod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Mod.php b/rdb/Queries/Math/Mod.php index fc8145a..f7270fa 100644 --- a/rdb/Queries/Math/Mod.php +++ b/rdb/Queries/Math/Mod.php @@ -8,6 +8,6 @@ class Mod extends BinaryOp { public function __construct($value, $other) { - parent::__construct(TermTermType::PB_MOD, [$value, $other]); + parent::__construct(TermTermType::PB_MOD, array($value, $other)); } } From f4df82ae4c87c7aefbe2aa73b143c590a386b282 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 13:55:13 +0200 Subject: [PATCH 17/30] PSR-2 compliing --- rdb/Connection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rdb/Connection.php b/rdb/Connection.php index dcfdf63..5d7519c 100644 --- a/rdb/Connection.php +++ b/rdb/Connection.php @@ -271,7 +271,6 @@ public function run(Query $query, $options = array(), &$profile = '') } else { return $this->createCursorFromResponse($response, $token, $response['n'], $toNativeOptions); } - } public function continueQuery($token) From 056be9a9ea73e698091459c2c95151484d7101b4 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:01:12 +0200 Subject: [PATCH 18/30] Multiple arguments support --- rdb/global.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rdb/global.php b/rdb/global.php index 6a81fe2..ef79399 100644 --- a/rdb/global.php +++ b/rdb/global.php @@ -238,13 +238,13 @@ function mod($expr1, $expr2) return new Mod($expr1, $expr2); } -function rAnd($expr1, $expr2) +function rAnd(...$exprs) { - return new RAnd($expr1, $expr2); + return new RAnd($exprs); } -function rOr($expr1, $expr2) +function rOr(...$exprs) { - return new ROr($expr1, $expr2); + return new ROr($exprs); } function eq($expr1, $expr2) From d1f67d87f10e5243d17aa65d6e0487102a89783f Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:01:41 +0200 Subject: [PATCH 19/30] Multiple arguments support From b268c03784e3ebffe79a1f564239df82fe564051 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:03:46 +0200 Subject: [PATCH 20/30] Multiple arguments support --- rdb/ValuedQuery/ValuedQuery.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index fd983a6..5fd7013 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -240,9 +240,9 @@ public function max($attributeOrOpts = null) } // Note: The API docs suggest that as of 1.6, contains can accept multiple values. // We do not support that for the time being. - public function contains($value) + public function contains(...$values) { - return new Contains($this, $value); + return new Contains($this, $values); } public function pluck($attributes) { @@ -337,13 +337,17 @@ public function mod($other) { return new Mod($this, $other); } - public function rAnd($other) + public function rAnd(...$exprs) { - return new RAnd($this, $other); + array_unshift($exprs, $this); + + return new RAnd($exprs); } - public function rOr($other) + public function rOr(...$exprs) { - return new ROr($this, $other); + array_unshift($exprs, $this); + + return new ROr($exprs); } public function eq($other) { From 6117f7d731a42b350aa2cf38cdddc785ff6f91e6 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:05:20 +0200 Subject: [PATCH 21/30] Multiple arguments support --- rdb/ValuedQuery/ValuedQuery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index 5fd7013..ba44417 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -240,9 +240,9 @@ public function max($attributeOrOpts = null) } // Note: The API docs suggest that as of 1.6, contains can accept multiple values. // We do not support that for the time being. - public function contains(...$values) + public function contains() { - return new Contains($this, $values); + return new Contains($this, func_get_args()); } public function pluck($attributes) { From 93f79b73cc383bb37a6ed9cce6f039bf5f567df8 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:06:51 +0200 Subject: [PATCH 22/30] Multiple arguments support --- rdb/global.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rdb/global.php b/rdb/global.php index ef79399..9767519 100644 --- a/rdb/global.php +++ b/rdb/global.php @@ -238,13 +238,13 @@ function mod($expr1, $expr2) return new Mod($expr1, $expr2); } -function rAnd(...$exprs) +function rAnd() { - return new RAnd($exprs); + return new RAnd(func_get_args()); } -function rOr(...$exprs) +function rOr() { - return new ROr($exprs); + return new ROr(func_get_args()); } function eq($expr1, $expr2) From 2937c7ec3b7cbef048a41a5be6d19dc78364230b Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 14:57:52 +0200 Subject: [PATCH 23/30] Multiple arguments support --- rdb/ValuedQuery/ValuedQuery.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index ba44417..76e8a75 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -337,14 +337,18 @@ public function mod($other) { return new Mod($this, $other); } - public function rAnd(...$exprs) + public function rAnd() { + $exprs = funct_get_args(); + array_unshift($exprs, $this); return new RAnd($exprs); } - public function rOr(...$exprs) + public function rOr() { + $exprs = funct_get_args(); + array_unshift($exprs, $this); return new ROr($exprs); From 99405044b69b28e6e7174233f204938b2ce69780 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Sun, 28 Aug 2016 15:12:08 +0200 Subject: [PATCH 24/30] Multiple arguments support --- rdb/ValuedQuery/ValuedQuery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index 76e8a75..94e70de 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -339,7 +339,7 @@ public function mod($other) } public function rAnd() { - $exprs = funct_get_args(); + $exprs = func_get_args(); array_unshift($exprs, $this); @@ -347,7 +347,7 @@ public function rAnd() } public function rOr() { - $exprs = funct_get_args(); + $exprs = func_get_args(); array_unshift($exprs, $this); From 0b7086561a8d5827f938889317c634bbc5b5cee4 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 17:37:46 +0100 Subject: [PATCH 25/30] Update composer.json --- composer.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 671c07b..3170feb 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "danielmewes/php-rql", + "name": "geekimo/php-rql", "type": "library", "description": "A PHP client driver for the RethinkDB query language (ReQL)", "keywords": ["rethinkdb","driver","database","reql"], - "homepage": "http://danielmewes.github.io/php-rql/", + "homepage": "https://github.com/Geekimo/php-rql/", "license": "Apache-2.0", "authors": [ { @@ -11,6 +11,11 @@ "email": "danielmewes@onlinehome.de", "homepage": "http://dmewes.com", "role": "Developer" + }, + { + "name": "Morgan Abraham", + "email": "morgan@tramicms.net", + "role": "Developer" } ], "require": { From 047838117b2e3657cd0a595886b8b202d1f015f9 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 18:11:19 +0100 Subject: [PATCH 26/30] Multiple args enhancement --- rdb/Queries/Control/Branch.php | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/rdb/Queries/Control/Branch.php b/rdb/Queries/Control/Branch.php index 8772bd3..e314bda 100644 --- a/rdb/Queries/Control/Branch.php +++ b/rdb/Queries/Control/Branch.php @@ -2,20 +2,41 @@ namespace r\Queries\Control; +use r\Exceptions\RqlException; use r\Query; use r\ValuedQuery\ValuedQuery; use r\ProtocolBuffer\TermTermType; class Branch extends ValuedQuery { - public function __construct(Query $test, $trueBranch, $falseBranch) + public function __construct() { - $trueBranch = $this->nativeToDatumOrFunction($trueBranch, false); - $falseBranch = $this->nativeToDatumOrFunction($falseBranch, false); + $branches = func_get_args(); - $this->setPositionalArg(0, $test); - $this->setPositionalArg(1, $trueBranch); - $this->setPositionalArg(2, $falseBranch); + if(count($branches) % 2 == 1) + { + // poping 'false' branch from other branches + $falseBranch = $this->nativeToDatumOrFunction(array_pop($branches), false); + + // for each remaning branch, if the index is odd, this is a branch, so we convert, otherwise, we directly position the argument + foreach ($branches as $i => $branch) + { + if($i % 2 == 1) + { + // branch, so we convert + $branch = $this->nativeToDatumOrFunction($branch, false); + } + + $this->setPositionalArg($i, $branch); + } + + // pushing the 'false' branch at the end of positional args + $this->setPositionalArg(count($branches), $falseBranch); + } + else + { + throw new RqlException(__METHOD__ . ' must have at least 3 parameters, or an odd parameter count.'); + } } protected function getTermType() From 17a3ab38d2cc3ca21c39699aa139758c47d3f443 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 18:21:27 +0100 Subject: [PATCH 27/30] Multiple args corrections --- rdb/global.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdb/global.php b/rdb/global.php index 9767519..fdb056f 100644 --- a/rdb/global.php +++ b/rdb/global.php @@ -135,9 +135,9 @@ function args($args) return new Args($args); } -function branch(Query $test, $trueBranch, $falseBranch) +function branch() { - return new Branch($test, $trueBranch, $falseBranch); + return new Branch(func_get_args()); } function row($attribute = null) From 703b87298bdb79dd37af2bbb73c90e9d4a69f354 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 18:23:16 +0100 Subject: [PATCH 28/30] Multiple args correction --- rdb/Queries/Control/Branch.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rdb/Queries/Control/Branch.php b/rdb/Queries/Control/Branch.php index e314bda..e45a53e 100644 --- a/rdb/Queries/Control/Branch.php +++ b/rdb/Queries/Control/Branch.php @@ -9,10 +9,8 @@ class Branch extends ValuedQuery { - public function __construct() + public function __construct($branches) { - $branches = func_get_args(); - if(count($branches) % 2 == 1) { // poping 'false' branch from other branches From 81377fbc6116dec782ed90908e5447295cd5e24d Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 18:24:07 +0100 Subject: [PATCH 29/30] Multiple args correction --- rdb/Queries/Control/Branch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Control/Branch.php b/rdb/Queries/Control/Branch.php index e45a53e..5341389 100644 --- a/rdb/Queries/Control/Branch.php +++ b/rdb/Queries/Control/Branch.php @@ -9,7 +9,7 @@ class Branch extends ValuedQuery { - public function __construct($branches) + public function __construct(array $branches) { if(count($branches) % 2 == 1) { From 892bdc6c2d7d2c7f89ab5240205f85d7d0aa8578 Mon Sep 17 00:00:00 2001 From: ABRAHAM Morgan Date: Mon, 25 Dec 2017 19:30:34 +0100 Subject: [PATCH 30/30] PSR-2 compliing --- rdb/Queries/Control/Branch.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rdb/Queries/Control/Branch.php b/rdb/Queries/Control/Branch.php index 5341389..d9df5d0 100644 --- a/rdb/Queries/Control/Branch.php +++ b/rdb/Queries/Control/Branch.php @@ -11,16 +11,13 @@ class Branch extends ValuedQuery { public function __construct(array $branches) { - if(count($branches) % 2 == 1) - { + if (count($branches) % 2 == 1) { // poping 'false' branch from other branches $falseBranch = $this->nativeToDatumOrFunction(array_pop($branches), false); // for each remaning branch, if the index is odd, this is a branch, so we convert, otherwise, we directly position the argument - foreach ($branches as $i => $branch) - { - if($i % 2 == 1) - { + foreach ($branches as $i => $branch) { + if($i % 2 == 1) { // branch, so we convert $branch = $this->nativeToDatumOrFunction($branch, false); } @@ -30,9 +27,7 @@ public function __construct(array $branches) // pushing the 'false' branch at the end of positional args $this->setPositionalArg(count($branches), $falseBranch); - } - else - { + } else { throw new RqlException(__METHOD__ . ' must have at least 3 parameters, or an odd parameter count.'); } }