From 5be7115dda9baf4c64ff9a12ff6a20b4d61f18e8 Mon Sep 17 00:00:00 2001 From: Michael Bagnall Date: Thu, 4 Nov 2021 18:30:42 -0500 Subject: [PATCH 1/5] Remove Match function due to PHP 8 --- .gitignore | 1 + composer.json | 8 +++++++- pb4php/parser/pb_parser.php | 2 +- rdb/Queries/Math/{Match.php => Equal.php} | 4 ++-- rdb/ValuedQuery/ValuedQuery.php | 6 +++--- 5 files changed, 14 insertions(+), 7 deletions(-) rename rdb/Queries/Math/{Match.php => Equal.php} (87%) diff --git a/.gitignore b/.gitignore index b8adef8..0c7ad0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store composer.lock vendor/ _builds/ diff --git a/composer.json b/composer.json index 671c07b..1b5aea7 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "danielmewes/php-rql", + "name": "mbagnall/php-rql", "type": "library", "description": "A PHP client driver for the RethinkDB query language (ReQL)", "keywords": ["rethinkdb","driver","database","reql"], @@ -11,6 +11,12 @@ "email": "danielmewes@onlinehome.de", "homepage": "http://dmewes.com", "role": "Developer" + }, + { + "name": "Michael Bagnall", + "email": "michael@bagnall.io", + "homepage": "http://bagnall.io", + "role": "Maintainer" } ], "require": { diff --git a/pb4php/parser/pb_parser.php b/pb4php/parser/pb_parser.php index 1dd4b93..59ffbfc 100644 --- a/pb4php/parser/pb_parser.php +++ b/pb4php/parser/pb_parser.php @@ -306,7 +306,7 @@ private function _parse_enum($content) $myarray = array(); $match = preg_match_all('/(.*);\s?/', $content, $matches); if (!$match) { - throw new Execption('Semantic error in Enum!'); + throw new Exception('Semantic error in Enum!'); } foreach ($matches[1] as $match) { $split = explode("=", $match); diff --git a/rdb/Queries/Math/Match.php b/rdb/Queries/Math/Equal.php similarity index 87% rename from rdb/Queries/Math/Match.php rename to rdb/Queries/Math/Equal.php index bec830d..e912e11 100644 --- a/rdb/Queries/Math/Match.php +++ b/rdb/Queries/Math/Equal.php @@ -1,11 +1,11 @@ Date: Thu, 4 Nov 2021 18:44:38 -0500 Subject: [PATCH 2/5] Fix namespace --- rdb/Queries/Math/Equal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdb/Queries/Math/Equal.php b/rdb/Queries/Math/Equal.php index e912e11..7a06ba1 100644 --- a/rdb/Queries/Math/Equal.php +++ b/rdb/Queries/Math/Equal.php @@ -1,6 +1,6 @@ Date: Sat, 6 Nov 2021 06:45:21 -0500 Subject: [PATCH 3/5] Put match back in but renamed the class not the function --- rdb/Queries/Math/{Equal.php => Match.php} | 2 +- rdb/ValuedQuery/ValuedQuery.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename rdb/Queries/Math/{Equal.php => Match.php} (92%) diff --git a/rdb/Queries/Math/Equal.php b/rdb/Queries/Math/Match.php similarity index 92% rename from rdb/Queries/Math/Equal.php rename to rdb/Queries/Math/Match.php index 7a06ba1..e9ab13e 100644 --- a/rdb/Queries/Math/Equal.php +++ b/rdb/Queries/Math/Match.php @@ -5,7 +5,7 @@ use r\ValuedQuery\ValuedQuery; use r\ProtocolBuffer\TermTermType; -class Equal extends ValuedQuery +class RqlMatch extends ValuedQuery { public function __construct(ValuedQuery $value, $expression) { diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index e33781b..57e423b 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -74,7 +74,7 @@ use r\Queries\Math\Gt; use r\Queries\Math\Le; use r\Queries\Math\Lt; -use r\Queries\Math\Equal; +use r\Queries\Math\Match; use r\Queries\Math\Mod; use r\Queries\Math\Mul; use r\Queries\Math\Ne; @@ -373,9 +373,9 @@ public function not() { return new Not($this); } - public function equal($expression) + public function match($expression) { - return new Equal($this, $expression); + return new RqlMatch($this, $expression); } public function upcase() { From 242b9361ced63e43b38283ca03dbc87fc324f941 Mon Sep 17 00:00:00 2001 From: Michael Bagnall Date: Sat, 6 Nov 2021 06:50:46 -0500 Subject: [PATCH 4/5] Rename match class to RqlMatch --- rdb/Queries/Math/{Match.php => RqlMatch.php} | 0 rdb/ValuedQuery/ValuedQuery.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename rdb/Queries/Math/{Match.php => RqlMatch.php} (100%) diff --git a/rdb/Queries/Math/Match.php b/rdb/Queries/Math/RqlMatch.php similarity index 100% rename from rdb/Queries/Math/Match.php rename to rdb/Queries/Math/RqlMatch.php diff --git a/rdb/ValuedQuery/ValuedQuery.php b/rdb/ValuedQuery/ValuedQuery.php index 57e423b..1cc43f1 100644 --- a/rdb/ValuedQuery/ValuedQuery.php +++ b/rdb/ValuedQuery/ValuedQuery.php @@ -74,7 +74,7 @@ use r\Queries\Math\Gt; use r\Queries\Math\Le; use r\Queries\Math\Lt; -use r\Queries\Math\Match; +use r\Queries\Math\RqlMatch; use r\Queries\Math\Mod; use r\Queries\Math\Mul; use r\Queries\Math\Ne; From 13b709a7f1cf88ff155ebb5365a5677c14f3c398 Mon Sep 17 00:00:00 2001 From: Michael Bagnall Date: Sun, 17 Sep 2023 16:00:38 -0500 Subject: [PATCH 5/5] Fix some PHP 8.2 deprecations that will error in PHP 9 --- rdb/Cursor.php | 12 +++++------- rdb/ValuedQuery/RVar.php | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/rdb/Cursor.php b/rdb/Cursor.php index 0445f96..a17de0c 100644 --- a/rdb/Cursor.php +++ b/rdb/Cursor.php @@ -37,13 +37,13 @@ public function __construct( } // PHP iterator interface - public function rewind() + public function rewind() : void { if ($this->wasIterated) { throw new RqlDriverError("Rewind() not supported. You can only iterate over a cursor once."); } } - public function next() + public function next() : void { $this->requestMoreIfNecessary(); if (!$this->valid()) { @@ -52,16 +52,16 @@ public function next() $this->wasIterated = true; $this->currentIndex++; } - public function valid() + public function valid() : bool { $this->requestMoreIfNecessary(); return !$this->isComplete || ($this->currentIndex < $this->currentSize); } - public function key() + public function key() : mixed { return null; } - public function current() + public function current() : mixed { $this->requestMoreIfNecessary(); if (!$this->valid()) { @@ -106,8 +106,6 @@ public function __toString() return "Cursor"; } - - public function __destruct() { if ($this->connection->isOpen()) { diff --git a/rdb/ValuedQuery/RVar.php b/rdb/ValuedQuery/RVar.php index 334ba61..65dc988 100644 --- a/rdb/ValuedQuery/RVar.php +++ b/rdb/ValuedQuery/RVar.php @@ -7,20 +7,21 @@ use r\Datum\NumberDatum; use r\ProtocolBuffer\TermTermType; -class RVar extends ValuedQuery -{ +class RVar extends ValuedQuery { + + public string $name; private $id; private static $nextVarId = 1; - public function __construct($name) + public function __construct($variableName) { - if (!is_string($name)) { + if (!is_string($variableName)) { throw new RqlDriverError("Variable name must be a string."); } $this->id = RVar::$nextVarId; - $this->name = $name; + $this->name = $variableName; if (RVar::$nextVarId == (1 << 31) - 1) { RVar::$nextVarId = 0; // TODO: This is not ideal. In very very very rare cases, it could lead to collisions. @@ -31,13 +32,11 @@ public function __construct($name) $this->setPositionalArg(0, new NumberDatum($this->id)); } - protected function getTermType() - { - return TermTermType::PB_VAR; + protected function getTermType() { + return TermTermType::PB_VAR; } - public function getId() - { - return $this->id; + public function getId() { + return $this->id; } }