From 24424d07a80829fc33d830aaa8316b463b830a30 Mon Sep 17 00:00:00 2001 From: GregW Date: Wed, 8 Mar 2023 17:31:28 +0100 Subject: [PATCH 1/4] [wpmldev-1615] PHP 8.1 PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string fix --- composer.json | 2 +- src/Components/Condition.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index be4612f0d..5a313900c 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "phpmyadmin/sql-parser", + "name": "wpml/sql-parser", "description": "A validating SQL lexer and parser with a focus on MySQL dialect.", "license": "GPL-2.0-or-later", "keywords": ["sql", "lexer", "parser", "analysis"], diff --git a/src/Components/Condition.php b/src/Components/Condition.php index 700b071ef..ace8da553 100644 --- a/src/Components/Condition.php +++ b/src/Components/Condition.php @@ -87,7 +87,7 @@ class Condition extends Component */ public function __construct($expr = null) { - $this->expr = trim($expr); + $this->expr = trim((string) $expr); } /** From 1a4daf55f3cfd96fbb0b3c4b67ecc55e010dff13 Mon Sep 17 00:00:00 2001 From: Eduard Pleh Date: Tue, 18 Jul 2023 11:21:55 +0300 Subject: [PATCH 2/4] [wpmldev-2010] Deprecation fixes for PHP 8.1. --- src/TokensList.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TokensList.php b/src/TokensList.php index 4a3eec6a1..7517d1cab 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -153,6 +153,7 @@ public function getNextOfTypeAndValue($type, $value) * @param int $offset the offset to be set * @param Token $value the token to be saved */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if ($offset === null) { @@ -169,6 +170,7 @@ public function offsetSet($offset, $value) * * @return Token */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $offset < $this->count ? $this->tokens[$offset] : null; @@ -181,6 +183,7 @@ public function offsetGet($offset) * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $offset < $this->count; @@ -191,6 +194,7 @@ public function offsetExists($offset) * * @param int $offset the offset to be unset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->tokens[$offset]); From fda5caaa1ebdbb7472a16b9b9e383abb55b40e19 Mon Sep 17 00:00:00 2001 From: Diego Garcia Date: Fri, 27 Feb 2026 10:16:51 +0100 Subject: [PATCH 3/4] wpmldev-4407: PHP 8.4 compatibility --- src/Parser.php | 4 ++-- src/Statement.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index f09a210d6..09842f4b8 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -595,12 +595,12 @@ public function parse() * Creates a new error log. * * @param string $msg the error message - * @param Token $token the token that produced the error + * @param Token|null $token the token that produced the error * @param int $code the code of the error * * @throws ParserException throws the exception, if strict mode is enabled */ - public function error($msg, Token $token = null, $code = 0) + public function error($msg, $token = null, $code = 0) { $error = new ParserException( Translator::gettext($msg), diff --git a/src/Statement.php b/src/Statement.php index 4b47ea5f8..1c2ad510e 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -84,10 +84,10 @@ abstract class Statement /** * Constructor. * - * @param Parser $parser the instance that requests parsing - * @param TokensList $list the list of tokens to be parsed + * @param Parser|null $parser the instance that requests parsing + * @param TokensList|null $list the list of tokens to be parsed */ - public function __construct(Parser $parser = null, TokensList $list = null) + public function __construct($parser = null, $list = null) { if (($parser !== null) && ($list !== null)) { $this->parse($parser, $list); From 7ce9beb004f118f301b875abc576b3b4bcb4ac41 Mon Sep 17 00:00:00 2001 From: Diego Garcia Date: Wed, 4 Mar 2026 09:57:41 +0100 Subject: [PATCH 4/4] wpmldev-4407: PHP 8.4 compatibility --- src/Parser.php | 2 +- src/Statement.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index 09842f4b8..5028fbf6a 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -600,7 +600,7 @@ public function parse() * * @throws ParserException throws the exception, if strict mode is enabled */ - public function error($msg, $token = null, $code = 0) + public function error($msg, ?Token $token = null, $code = 0) { $error = new ParserException( Translator::gettext($msg), diff --git a/src/Statement.php b/src/Statement.php index 1c2ad510e..b8a014f88 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -87,7 +87,7 @@ abstract class Statement * @param Parser|null $parser the instance that requests parsing * @param TokensList|null $list the list of tokens to be parsed */ - public function __construct($parser = null, $list = null) + public function __construct(?Parser $parser = null, ?TokensList $list = null) { if (($parser !== null) && ($list !== null)) { $this->parse($parser, $list);