From 4fb210d8aa25811b6bba6a4ec3128e2340ba1e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Fri, 11 Aug 2023 21:56:02 +0200 Subject: [PATCH 01/15] Add BOOL as data type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Krög --- src/Contexts/ContextMariaDb100000.php | 14 +++++++------- src/Contexts/ContextMariaDb100100.php | 14 +++++++------- src/Contexts/ContextMariaDb100200.php | 14 +++++++------- src/Contexts/ContextMariaDb100300.php | 14 +++++++------- src/Contexts/ContextMariaDb100400.php | 14 +++++++------- src/Contexts/ContextMariaDb100500.php | 14 +++++++------- src/Contexts/ContextMariaDb100600.php | 14 +++++++------- src/Contexts/ContextMySql50000.php | 12 ++++++------ src/Contexts/ContextMySql50100.php | 14 +++++++------- src/Contexts/ContextMySql50500.php | 14 +++++++------- src/Contexts/ContextMySql50600.php | 14 +++++++------- src/Contexts/ContextMySql50700.php | 14 +++++++------- src/Contexts/ContextMySql80000.php | 14 +++++++------- tools/contexts/_common.txt | 1 + 14 files changed, 91 insertions(+), 90 deletions(-) diff --git a/src/Contexts/ContextMariaDb100000.php b/src/Contexts/ContextMariaDb100000.php index 03a0312b2..23b1f6638 100644 --- a/src/Contexts/ContextMariaDb100000.php +++ b/src/Contexts/ContextMariaDb100000.php @@ -33,12 +33,12 @@ class ContextMariaDb100000 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, - 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, 'PREV' => 1, + 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -175,7 +175,7 @@ class ContextMariaDb100000 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100100.php b/src/Contexts/ContextMariaDb100100.php index 529229191..7ca0d5c0c 100644 --- a/src/Contexts/ContextMariaDb100100.php +++ b/src/Contexts/ContextMariaDb100100.php @@ -33,12 +33,12 @@ class ContextMariaDb100100 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, - 'THAN' => 1, 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, + 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100100 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100200.php b/src/Contexts/ContextMariaDb100200.php index b652ecb6b..22aaf552c 100644 --- a/src/Contexts/ContextMariaDb100200.php +++ b/src/Contexts/ContextMariaDb100200.php @@ -33,12 +33,12 @@ class ContextMariaDb100200 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100200 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100300.php b/src/Contexts/ContextMariaDb100300.php index 85fe6c4e4..f5c0a1d0f 100644 --- a/src/Contexts/ContextMariaDb100300.php +++ b/src/Contexts/ContextMariaDb100300.php @@ -33,12 +33,12 @@ class ContextMariaDb100300 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100300 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100400.php b/src/Contexts/ContextMariaDb100400.php index 3d009c31d..487015928 100644 --- a/src/Contexts/ContextMariaDb100400.php +++ b/src/Contexts/ContextMariaDb100400.php @@ -33,12 +33,12 @@ class ContextMariaDb100400 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100400 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100500.php b/src/Contexts/ContextMariaDb100500.php index d45e51033..ec4ba8583 100644 --- a/src/Contexts/ContextMariaDb100500.php +++ b/src/Contexts/ContextMariaDb100500.php @@ -33,12 +33,12 @@ class ContextMariaDb100500 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100500 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMariaDb100600.php b/src/Contexts/ContextMariaDb100600.php index e10943bae..f07151a8f 100644 --- a/src/Contexts/ContextMariaDb100600.php +++ b/src/Contexts/ContextMariaDb100600.php @@ -33,12 +33,12 @@ class ContextMariaDb100600 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMariaDb100600 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql50000.php b/src/Contexts/ContextMySql50000.php index a85270326..7eaad49c8 100644 --- a/src/Contexts/ContextMySql50000.php +++ b/src/Contexts/ContextMySql50000.php @@ -33,11 +33,11 @@ class ContextMySql50000 extends Context 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'BDB' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'FAST' => 1, - 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'LAST' => 1, 'LOGS' => 1, - 'MODE' => 1, 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PREV' => 1, 'ROWS' => 1, 'SOME' => 1, 'STOP' => 1, 'TYPE' => 1, 'VIEW' => 1, - 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'FAST' => 1, 'FILE' => 1, + 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'LAST' => 1, 'LOGS' => 1, 'MODE' => 1, + 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PREV' => 1, + 'ROWS' => 1, 'SOME' => 1, 'STOP' => 1, 'TYPE' => 1, 'VIEW' => 1, 'WORK' => 1, + 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, 'LEVEL' => 1, 'LOCAL' => 1, 'LOCKS' => 1, @@ -155,7 +155,7 @@ class ContextMySql50000 extends Context 'NATURAL RIGHT OUTER JOIN' => 7, 'WITH CONSISTENT SNAPSHOT' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql50100.php b/src/Contexts/ContextMySql50100.php index c0112c0fc..c30254be8 100644 --- a/src/Contexts/ContextMySql50100.php +++ b/src/Contexts/ContextMySql50100.php @@ -33,12 +33,12 @@ class ContextMySql50100 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'BDB' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'GOTO' => 1, 'HASH' => 1, - 'HELP' => 1, 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, - 'MODE' => 1, 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'ROWS' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'GOTO' => 1, 'HASH' => 1, 'HELP' => 1, + 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, + 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'ROWS' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, 'LABEL' => 1, @@ -170,7 +170,7 @@ class ContextMySql50100 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql50500.php b/src/Contexts/ContextMySql50500.php index f451af72b..a05b89f1f 100644 --- a/src/Contexts/ContextMySql50500.php +++ b/src/Contexts/ContextMySql50500.php @@ -33,12 +33,12 @@ class ContextMySql50500 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, - 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, - 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, 'PREV' => 1, + 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, 'TYPE' => 1, + 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -175,7 +175,7 @@ class ContextMySql50500 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql50600.php b/src/Contexts/ContextMySql50600.php index ef080f810..43919114d 100644 --- a/src/Contexts/ContextMySql50600.php +++ b/src/Contexts/ContextMySql50600.php @@ -33,12 +33,12 @@ class ContextMySql50600 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, - 'THAN' => 1, 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, + 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -180,7 +180,7 @@ class ContextMySql50600 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql50700.php b/src/Contexts/ContextMySql50700.php index 60294c74b..3e5893cb5 100644 --- a/src/Contexts/ContextMySql50700.php +++ b/src/Contexts/ContextMySql50700.php @@ -33,12 +33,12 @@ class ContextMySql50700 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, - 'THAN' => 1, 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, + 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -186,7 +186,7 @@ class ContextMySql50700 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/src/Contexts/ContextMySql80000.php b/src/Contexts/ContextMySql80000.php index b6d05d84c..b86b4212b 100644 --- a/src/Contexts/ContextMySql80000.php +++ b/src/Contexts/ContextMySql80000.php @@ -33,12 +33,12 @@ class ContextMySql80000 extends Context 'AT' => 1, 'DO' => 1, 'IO' => 1, 'NO' => 1, 'XA' => 1, 'ANY' => 1, 'CPU' => 1, 'END' => 1, 'IPC' => 1, 'NDB' => 1, 'NEW' => 1, 'ONE' => 1, 'ROW' => 1, 'XID' => 1, - 'BOOL' => 1, 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, - 'ENDS' => 1, 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, - 'HOST' => 1, 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, - 'NAME' => 1, 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, - 'PORT' => 1, 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, - 'THAN' => 1, 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, + 'BYTE' => 1, 'CODE' => 1, 'CUBE' => 1, 'DATA' => 1, 'DISK' => 1, 'ENDS' => 1, + 'FAST' => 1, 'FILE' => 1, 'FULL' => 1, 'HASH' => 1, 'HELP' => 1, 'HOST' => 1, + 'LAST' => 1, 'LESS' => 1, 'LIST' => 1, 'LOGS' => 1, 'MODE' => 1, 'NAME' => 1, + 'NEXT' => 1, 'NONE' => 1, 'ONLY' => 1, 'OPEN' => 1, 'PAGE' => 1, 'PORT' => 1, + 'PREV' => 1, 'ROWS' => 1, 'SLOW' => 1, 'SOME' => 1, 'STOP' => 1, 'THAN' => 1, + 'TYPE' => 1, 'VIEW' => 1, 'WAIT' => 1, 'WORK' => 1, 'X509' => 1, 'AFTER' => 1, 'BEGIN' => 1, 'BLOCK' => 1, 'BTREE' => 1, 'CACHE' => 1, 'CHAIN' => 1, 'CLOSE' => 1, 'ERROR' => 1, 'EVENT' => 1, 'EVERY' => 1, 'FIRST' => 1, 'FIXED' => 1, 'FLUSH' => 1, 'FOUND' => 1, 'HOSTS' => 1, @@ -187,7 +187,7 @@ class ContextMySql80000 extends Context 'ON COMPLETION NOT PRESERVE' => 7, 'BIT' => 9, 'XML' => 9, - 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, + 'BOOL' => 9, 'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9, 'ARRAY' => 9, 'SERIAL' => 9, 'BOOLEAN' => 9, diff --git a/tools/contexts/_common.txt b/tools/contexts/_common.txt index 5be2a01e6..5d48e8f7d 100644 --- a/tools/contexts/_common.txt +++ b/tools/contexts/_common.txt @@ -7,6 +7,7 @@ BIGINT (D) BINARY (D) BINARY VARYING (D) BLOB (D) +BOOL (D) BOOLEAN (D) CHAR (D) CHARACTER (D) From b299035f9f12f865ce9400350c8b07e7a902a6c4 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 29 Aug 2023 23:18:27 +0100 Subject: [PATCH 02/15] Escape identifiers that need it Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 10 ---------- psalm-baseline.xml | 2 +- src/Context.php | 12 +++++++++++- tests/Lexer/ContextTest.php | 4 ++++ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a5f50405d..fcc9a6308 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -925,16 +925,6 @@ parameters: count: 2 path: tests/Components/PartitionDefinitionTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 2 and PhpMyAdmin\\\\SqlParser\\\\TokensList will always evaluate to false\\.$#" - count: 1 - path: tests/Lexer/TokensListTest.php - - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 112 and PhpMyAdmin\\\\SqlParser\\\\UtfString will always evaluate to false\\.$#" - count: 1 - path: tests/Misc/UtfStringTest.php - - message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cf3c3d26f..e442ecfe0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + assertEquals('test', Context::escape('test')); + $this->assertEquals('`123`', Context::escape('123')); + $this->assertEquals('`$test`', Context::escape('$test')); + $this->assertEquals('`te st`', Context::escape('te st')); + $this->assertEquals('`te.st`', Context::escape('te.st')); Context::setMode(Context::SQL_MODE_ANSI_QUOTES); $this->assertEquals('"test"', Context::escape('test')); From 2b3cf84b666a6394111dc38b0735a48c57d33087 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 30 Aug 2023 14:36:43 +0100 Subject: [PATCH 03/15] Add remaining native return types Signed-off-by: Kamil Tekiela --- phpcs.xml.dist | 3 -- psalm-baseline.xml | 6 ---- src/Component.php | 4 +-- src/Components/AlterOperation.php | 4 +-- src/Components/ArrayObj.php | 2 +- src/Components/CaseExpression.php | 4 +-- src/Components/CreateDefinition.php | 2 +- src/Components/DataType.php | 4 +-- src/Components/FunctionCall.php | 4 +-- src/Components/IntoKeyword.php | 4 +-- src/Components/Key.php | 4 +-- src/Components/Limit.php | 4 +-- src/Components/LockExpression.php | 9 ++--- src/Components/OptionsArray.php | 8 ++--- src/Components/PartitionDefinition.php | 4 +-- src/Components/Reference.php | 4 +-- src/Components/UnionKeyword.php | 4 +-- src/Components/WithKeyword.php | 4 +-- src/Context.php | 4 +-- src/Core.php | 4 +-- src/Lexer.php | 48 +++++++------------------- src/Statement.php | 4 +-- src/Statements/LoadStatement.php | 4 +-- src/Statements/PurgeStatement.php | 4 +-- src/Token.php | 4 +-- src/TokensList.php | 16 +++------ src/Tools/ContextGenerator.php | 6 ++-- src/Tools/TestGenerator.php | 4 +-- src/Translator.php | 2 +- src/UtfString.php | 8 ++--- src/Utils/BufferedQuery.php | 4 +-- src/Utils/Formatter.php | 16 +++------ src/Utils/Query.php | 12 +++---- src/Utils/Table.php | 4 +-- 34 files changed, 59 insertions(+), 163 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e19cce16d..07e829c2d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -66,9 +66,6 @@ 4 - - 4 - 4 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e442ecfe0..b2755a74b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -857,9 +857,6 @@ $built[$field] value]]]> - - __toString - value]]]> value]]]> @@ -1206,9 +1203,6 @@ - - __toString - $byteLen diff --git a/src/Component.php b/src/Component.php index 9ee99a884..d3df767a5 100644 --- a/src/Component.php +++ b/src/Component.php @@ -22,10 +22,8 @@ interface Component extends Stringable * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return mixed */ - public static function parse(Parser $parser, TokensList $list, array $options = []); + public static function parse(Parser $parser, TokensList $list, array $options = []): mixed; /** * Builds the string representation of a component of this type. diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index 569704960..d688e05da 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -300,10 +300,8 @@ public function __construct( * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return AlterOperation */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): AlterOperation { $ret = new static(); diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index 679a60055..75a5ee8a2 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -49,7 +49,7 @@ public function __construct(array $raw = [], array $values = []) * * @return ArrayObj|Component[] */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): ArrayObj|array { $ret = empty($options['type']) ? new static() : []; diff --git a/src/Components/CaseExpression.php b/src/Components/CaseExpression.php index 0ff0ab0a4..406f9cdee 100644 --- a/src/Components/CaseExpression.php +++ b/src/Components/CaseExpression.php @@ -70,10 +70,8 @@ final class CaseExpression implements Component * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return CaseExpression */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): CaseExpression { $ret = new static(); diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php index a263abb6c..a5e62793f 100644 --- a/src/Components/CreateDefinition.php +++ b/src/Components/CreateDefinition.php @@ -180,7 +180,7 @@ public function __construct( * * @return CreateDefinition[] */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): array { $ret = []; diff --git a/src/Components/DataType.php b/src/Components/DataType.php index 53cfd6550..226213c6b 100644 --- a/src/Components/DataType.php +++ b/src/Components/DataType.php @@ -93,10 +93,8 @@ public function __construct( * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return DataType|null */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): DataType|null { $ret = new static(); diff --git a/src/Components/FunctionCall.php b/src/Components/FunctionCall.php index b3b7590c7..88b269995 100644 --- a/src/Components/FunctionCall.php +++ b/src/Components/FunctionCall.php @@ -48,10 +48,8 @@ public function __construct($name = null, $parameters = null) * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return FunctionCall */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): FunctionCall { $ret = new static(); diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index 493a53e75..00c7ac89a 100644 --- a/src/Components/IntoKeyword.php +++ b/src/Components/IntoKeyword.php @@ -137,10 +137,8 @@ public function __construct( * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return IntoKeyword */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): IntoKeyword { $ret = new static(); diff --git a/src/Components/Key.php b/src/Components/Key.php index a1c64a25f..daa6469f5 100644 --- a/src/Components/Key.php +++ b/src/Components/Key.php @@ -123,10 +123,8 @@ public function __construct( * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return Key */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): Key { $ret = new static(); diff --git a/src/Components/Limit.php b/src/Components/Limit.php index b51679d5a..9f46c537a 100644 --- a/src/Components/Limit.php +++ b/src/Components/Limit.php @@ -42,10 +42,8 @@ public function __construct($rowCount = 0, $offset = 0) * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return Limit */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): Limit { $ret = new static(); diff --git a/src/Components/LockExpression.php b/src/Components/LockExpression.php index af54d4b17..1c9c1beb5 100644 --- a/src/Components/LockExpression.php +++ b/src/Components/LockExpression.php @@ -34,10 +34,8 @@ final class LockExpression implements Component * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return LockExpression */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): LockExpression { $ret = new static(); @@ -109,10 +107,7 @@ public static function buildAll(array $component): string return implode(', ', $component); } - /** - * @return string - */ - private static function parseLockType(Parser $parser, TokensList $list) + private static function parseLockType(Parser $parser, TokensList $list): string { $lockType = ''; diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php index 17c067437..17188cfc7 100644 --- a/src/Components/OptionsArray.php +++ b/src/Components/OptionsArray.php @@ -37,10 +37,8 @@ public function __construct(public array $options = []) * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return OptionsArray */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): OptionsArray { $ret = new static(); @@ -295,10 +293,8 @@ public static function build($component): string * @param string $key the key to be checked * @param bool $getExpr Gets the expression instead of the value. * The value is the processed form of the expression. - * - * @return mixed */ - public function has($key, $getExpr = false) + public function has($key, $getExpr = false): mixed { foreach ($this->options as $option) { if (is_array($option)) { diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php index 8f312765c..f7ca0cfaf 100644 --- a/src/Components/PartitionDefinition.php +++ b/src/Components/PartitionDefinition.php @@ -110,10 +110,8 @@ final class PartitionDefinition implements Component * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return PartitionDefinition */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): PartitionDefinition { $ret = new static(); diff --git a/src/Components/Reference.php b/src/Components/Reference.php index 1b1ca128d..659f5941f 100644 --- a/src/Components/Reference.php +++ b/src/Components/Reference.php @@ -76,10 +76,8 @@ public function __construct($table = null, array $columns = [], $options = null) * @param Parser $parser the parser that serves as context * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing - * - * @return Reference */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): Reference { $ret = new static(); diff --git a/src/Components/UnionKeyword.php b/src/Components/UnionKeyword.php index c13f7852e..427929827 100644 --- a/src/Components/UnionKeyword.php +++ b/src/Components/UnionKeyword.php @@ -24,11 +24,9 @@ final class UnionKeyword implements Component * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing * - * @return mixed - * * @throws RuntimeException not implemented yet. */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): mixed { throw new RuntimeException(Translator::gettext('Not implemented yet.')); } diff --git a/src/Components/WithKeyword.php b/src/Components/WithKeyword.php index ca644a122..cc204b3f8 100644 --- a/src/Components/WithKeyword.php +++ b/src/Components/WithKeyword.php @@ -36,11 +36,9 @@ public function __construct(string $name) * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing * - * @return mixed - * * @throws RuntimeException not implemented yet. */ - public static function parse(Parser $parser, TokensList $list, array $options = []) + public static function parse(Parser $parser, TokensList $list, array $options = []): mixed { throw new RuntimeException(Translator::gettext('Not implemented yet.')); } diff --git a/src/Context.php b/src/Context.php index 42c393244..725e915e2 100644 --- a/src/Context.php +++ b/src/Context.php @@ -670,10 +670,8 @@ private static function getModeFromString(string $mode): int * * @param string $str the string to be escaped * @param string $quote quote to be used when escaping - * - * @return string */ - public static function escape(string $str, string $quote = '`') + public static function escape(string $str, string $quote = '`'): string { if ((static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && (! static::isKeyword($str, true))) { return $str; diff --git a/src/Core.php b/src/Core.php index ffa8bc429..775b686ac 100644 --- a/src/Core.php +++ b/src/Core.php @@ -47,11 +47,9 @@ public function __construct() * * @param Exception $error the error exception * - * @return void - * * @throws Exception throws the exception, if strict mode is enabled. */ - public function error($error) + public function error($error): void { if ($this->strict) { throw $error; diff --git a/src/Lexer.php b/src/Lexer.php index 98a24231a..b8ced2c0f 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -158,10 +158,8 @@ class Lexer extends Core * @param bool $strict whether strict mode should be * enabled or not * @param string $delimiter the delimiter to be used - * - * @return TokensList */ - public static function getTokens($str, $strict = false, $delimiter = null) + public static function getTokens($str, $strict = false, $delimiter = null): TokensList { $lexer = new self($str, $strict, $delimiter); @@ -456,10 +454,8 @@ public function error($msg, $str = '', $pos = 0, $code = 0): void /** * Parses a keyword. - * - * @return Token|null */ - public function parseKeyword() + public function parseKeyword(): Token|null { $token = ''; @@ -518,10 +514,8 @@ public function parseKeyword() /** * Parses a label. - * - * @return Token|null */ - public function parseLabel() + public function parseLabel(): Token|null { $token = ''; @@ -564,10 +558,8 @@ public function parseLabel() /** * Parses an operator. - * - * @return Token|null */ - public function parseOperator() + public function parseOperator(): Token|null { $token = ''; @@ -602,10 +594,8 @@ public function parseOperator() /** * Parses a whitespace. - * - * @return Token|null */ - public function parseWhitespace() + public function parseWhitespace(): Token|null { $token = $this->str[$this->last]; @@ -624,10 +614,8 @@ public function parseWhitespace() /** * Parses a comment. - * - * @return Token|null */ - public function parseComment() + public function parseComment(): Token|null { $iBak = $this->last; $token = $this->str[$this->last]; @@ -743,10 +731,8 @@ public function parseComment() /** * Parses a boolean. - * - * @return Token|null */ - public function parseBool() + public function parseBool(): Token|null { if ($this->last + 3 >= $this->len) { // At least `min(strlen('TRUE'), strlen('FALSE'))` characters are @@ -776,10 +762,8 @@ public function parseBool() /** * Parses a number. - * - * @return Token|null */ - public function parseNumber() + public function parseNumber(): Token|null { // A rudimentary state machine is being used to parse numbers due to // the various forms of their notation. @@ -943,11 +927,9 @@ public function parseNumber() * * @param string $quote additional starting symbol * - * @return Token|null - * * @throws LexerException */ - public function parseString($quote = '') + public function parseString($quote = ''): Token|null { $token = $this->str[$this->last]; $flags = Context::isString($token); @@ -995,11 +977,9 @@ public function parseString($quote = '') /** * Parses a symbol. * - * @return Token|null - * * @throws LexerException */ - public function parseSymbol() + public function parseSymbol(): Token|null { $token = $this->str[$this->last]; $flags = Context::isSymbol($token); @@ -1045,10 +1025,8 @@ public function parseSymbol() /** * Parses unknown parts of the query. - * - * @return Token|null */ - public function parseUnknown() + public function parseUnknown(): Token|null { $token = $this->str[$this->last]; if (Context::isSeparator($token)) { @@ -1073,10 +1051,8 @@ public function parseUnknown() /** * Parses the delimiter of the query. - * - * @return Token|null */ - public function parseDelimiter() + public function parseDelimiter(): Token|null { $idx = 0; diff --git a/src/Statement.php b/src/Statement.php index d0e679d7f..cfad96ff6 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -454,10 +454,8 @@ public function getClauses(): array * Builds the string representation of this statement. * * @see static::build - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->build(); } diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php index f3d07c39a..202654ab8 100644 --- a/src/Statements/LoadStatement.php +++ b/src/Statements/LoadStatement.php @@ -336,10 +336,8 @@ public function parseFileOptions(Parser $parser, TokensList $list, $keyword = 'F * @param Parser $parser * @param TokensList $list * @param int $state - * - * @return int */ - public function parseKeywordsAccordingToState($parser, $list, $state) + public function parseKeywordsAccordingToState($parser, $list, $state): int { $token = $list->tokens[$list->idx]; diff --git a/src/Statements/PurgeStatement.php b/src/Statements/PurgeStatement.php index b8302cdbe..10cf6b31b 100644 --- a/src/Statements/PurgeStatement.php +++ b/src/Statements/PurgeStatement.php @@ -122,10 +122,8 @@ public function parse(Parser $parser, TokensList $list): void * @param Parser $parser the instance that requests parsing * @param Token $token token to be parsed * @param string[] $expectedKeywords array of possibly expected keywords at this point - * - * @return mixed|null */ - private static function parseExpectedKeyword($parser, $token, $expectedKeywords) + private static function parseExpectedKeyword($parser, $token, $expectedKeywords): mixed { if ($token->type === Token::TYPE_KEYWORD) { if (in_array($token->keyword, $expectedKeywords)) { diff --git a/src/Token.php b/src/Token.php index 27b0f6371..bdd2fbb06 100644 --- a/src/Token.php +++ b/src/Token.php @@ -228,10 +228,8 @@ public function __construct($token, $type = 0, $flags = 0) * Does little processing to the token to extract a value. * * If no processing can be done it will return the initial string. - * - * @return mixed */ - public function extract() + public function extract(): mixed { switch ($this->type) { case self::TYPE_KEYWORD: diff --git a/src/TokensList.php b/src/TokensList.php index 39af9204b..d669bda4c 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -93,10 +93,8 @@ public function add(Token $token): void /** * Gets the next token. Skips any irrelevant token (whitespaces and * comments). - * - * @return Token|null */ - public function getNext() + public function getNext(): Token|null { for (; $this->idx < $this->count; ++$this->idx) { if ( @@ -132,10 +130,8 @@ public function getPrevious(): Token|null * Gets the previous token. * * @param int|int[] $type the type - * - * @return Token|null */ - public function getPreviousOfType($type) + public function getPreviousOfType($type): Token|null { if (! is_array($type)) { $type = [$type]; @@ -154,10 +150,8 @@ public function getPreviousOfType($type) * Gets the next token. * * @param int|int[] $type the type - * - * @return Token|null */ - public function getNextOfType($type) + public function getNextOfType($type): Token|null { if (! is_array($type)) { $type = [$type]; @@ -177,10 +171,8 @@ public function getNextOfType($type) * * @param int $type the type of the token * @param string $value the value of the token - * - * @return Token|null */ - public function getNextOfTypeAndValue($type, $value) + public function getNextOfTypeAndValue($type, $value): Token|null { for (; $this->idx < $this->count; ++$this->idx) { if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->value === $value)) { diff --git a/src/Tools/ContextGenerator.php b/src/Tools/ContextGenerator.php index db385cad9..3fbe7c9f5 100644 --- a/src/Tools/ContextGenerator.php +++ b/src/Tools/ContextGenerator.php @@ -145,7 +145,7 @@ public static function sortWords(array &$arr): array * * @return array>> */ - public static function readWords(array $files) + public static function readWords(array $files): array { $words = []; foreach ($files as $file) { @@ -279,10 +279,8 @@ public static function generate($options): string * Formats context name. * * @param string $name name to format - * - * @return string */ - public static function formatName($name) + public static function formatName($name): string { /* Split name and version */ $parts = []; diff --git a/src/Tools/TestGenerator.php b/src/Tools/TestGenerator.php index d64da4423..2056deb00 100644 --- a/src/Tools/TestGenerator.php +++ b/src/Tools/TestGenerator.php @@ -132,10 +132,8 @@ public static function generate($query, $type = 'parser'): array * @param string $output the output file * @param string $debug the debug file * @param bool $ansi activate quotes ANSI mode - * - * @return void */ - public static function build($type, $input, $output, $debug = null, $ansi = false) + public static function build($type, $input, $output, $debug = null, $ansi = false): void { // Support query types: `lexer` / `parser`. if (! in_array($type, ['lexer', 'parser'])) { diff --git a/src/Translator.php b/src/Translator.php index b4876a462..f693bb9a9 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -63,7 +63,7 @@ public static function load(): void * * @return string translated string (or original, if not found) */ - public static function gettext($msgid) + public static function gettext($msgid): string { if (! class_exists(Loader::class, true)) { return $msgid; diff --git a/src/UtfString.php b/src/UtfString.php index 59d2f436f..e2aa00b69 100644 --- a/src/UtfString.php +++ b/src/UtfString.php @@ -318,20 +318,16 @@ public static function getCharLength($byte): int /** * Returns the length in characters of the string. - * - * @return int */ - public function length() + public function length(): int { return $this->charLen; } /** * Returns the contained string. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->str; } diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index c12155b69..5be54ed21 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -120,10 +120,8 @@ public function setDelimiter($delimiter): void * Extracts a statement from the buffer. * * @param bool $end whether the end of the buffer was reached - * - * @return string|false */ - public function extract($end = false) + public function extract($end = false): string|false { /** * The last parsed position. diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index 3f1238383..f5227a808 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -92,7 +92,7 @@ public function __construct(array $options = []) * * @return array>> */ - protected function getMergedOptions(array $options) + protected function getMergedOptions(array $options): array { $options = array_merge( $this->getDefaultOptions(), @@ -324,10 +324,8 @@ private static function mergeFormats(array $formats, array $newFormats): array * Formats the given list of tokens. * * @param TokensList $list the list of tokens - * - * @return string */ - public function formatList($list) + public function formatList($list): string { /** * The query to be returned. @@ -636,10 +634,8 @@ public function escapeConsole(string $string): string * Tries to print the query and returns the result. * * @param Token $token the token to be printed - * - * @return string */ - public function toString($token) + public function toString($token): string { $text = $token->token; static $prev; @@ -698,7 +694,7 @@ public function toString($token) * * @return string the formatted string */ - public static function format($query, array $options = []) + public static function format($query, array $options = []): string { $lexer = new Lexer($query); $formatter = new self($options); @@ -712,10 +708,8 @@ public static function format($query, array $options = []) * A group is delimited by a pair of brackets. * * @param TokensList $list the list of tokens - * - * @return int */ - public static function getGroupLength($list) + public static function getGroupLength($list): int { /** * The number of opening brackets found. diff --git a/src/Utils/Query.php b/src/Utils/Query.php index 81a53d32c..17277bf51 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -287,7 +287,7 @@ class Query * @return array * @psalm-return QueryFlagsType */ - private static function getFlagsSelect(SelectStatement $statement, $flags) + private static function getFlagsSelect(SelectStatement $statement, $flags): array { $flags['querytype'] = 'SELECT'; $flags['is_select'] = true; @@ -363,7 +363,7 @@ private static function getFlagsSelect(SelectStatement $statement, $flags) * @return array * @psalm-return QueryFlagsType */ - public static function getFlags($statement, $all = false) + public static function getFlags($statement, $all = false): array { $flags = ['querytype' => false]; if ($all) { @@ -470,7 +470,7 @@ public static function getFlags($statement, $all = false) * statement?: Statement|null, parser?: Parser * } */ - public static function getAll($query) + public static function getAll($query): array { $parser = new Parser($query); @@ -558,7 +558,7 @@ public static function getAll($query) * * @return array */ - public static function getTables($statement) + public static function getTables($statement): array { $expressions = []; @@ -882,10 +882,8 @@ public static function getFirstStatement($query, $delimiter = null): array * @param Statement $statement the parsed query that has to be modified * @param TokensList $list the list of tokens * @param string $clause the clause to be returned - * - * @return int */ - public static function getClauseStartOffset($statement, $list, $clause) + public static function getClauseStartOffset($statement, $list, $clause): int { /** * The count of brackets. diff --git a/src/Utils/Table.php b/src/Utils/Table.php index 7bca9fd8e..fe4082543 100644 --- a/src/Utils/Table.php +++ b/src/Utils/Table.php @@ -21,7 +21,7 @@ class Table * * @return array> */ - public static function getForeignKeys($statement) + public static function getForeignKeys($statement): array { if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { return []; @@ -79,7 +79,7 @@ public static function getForeignKeys($statement) * * @return array> */ - public static function getFields($statement) + public static function getFields($statement): array { if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { return []; From a353ed354e76fb445de10eb35deb0dcfd82bc2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 02:46:07 -0300 Subject: [PATCH 04/15] Avoid upgrading zumba/json-serializer to 3.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has a bug that causes the tests to fail. Signed-off-by: Maurício Meneghini Fauth --- composer.json | 2 +- phpstan-baseline.neon | 31 ++++++++----------------------- psalm-baseline.xml | 3 --- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 072430d36..15b94e51a 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", "psalm/plugin-phpunit": "^0.16.1", "vimeo/psalm": "^4.11", - "zumba/json-serializer": "^3.0" + "zumba/json-serializer": "~3.0.2" }, "conflict": { "phpmyadmin/motranslator": "<3.0" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c12d84179..7de4c647c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -900,6 +900,11 @@ parameters: count: 1 path: src/Utils/Formatter.php + - + message: "#^Binary operation \"&\" between int and int\\|string results in an error\\.$#" + count: 1 + path: src/Utils/Formatter.php + - message: "#^Binary operation \"&\\=\" between array\\\\>\\|bool\\|string\\|null and array\\\\>\\|bool\\|string\\|null results in an error\\.$#" count: 1 @@ -926,12 +931,12 @@ parameters: path: src/Utils/Formatter.php - - message: "#^Access to an undefined property object\\:\\:\\$alias\\.$#" + message: "#^Trying to invoke int\\\\|int\\<1, max\\>\\|non\\-falsy\\-string but it might not be a callable\\.$#" count: 1 - path: src/Utils/Query.php + path: src/Utils/Formatter.php - - message: "#^Access to an undefined property object\\:\\:\\$expr\\.$#" + message: "#^Argument of an invalid type array\\\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: src/Utils/Query.php @@ -940,11 +945,6 @@ parameters: count: 1 path: src/Utils/Query.php - - - message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: src/Utils/Query.php - - message: "#^Cannot access property \\$dest on PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\|null\\.$#" count: 1 @@ -965,11 +965,6 @@ parameters: count: 1 path: src/Utils/Query.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, object given\\.$#" - count: 1 - path: src/Utils/Query.php - - message: "#^Cannot access offset 'value' on mixed\\.$#" count: 3 @@ -1125,16 +1120,6 @@ parameters: count: 1 path: tests/Components/RenameOperationTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 2 and PhpMyAdmin\\\\SqlParser\\\\TokensList will always evaluate to false\\.$#" - count: 1 - path: tests/Lexer/TokensListTest.php - - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 112 and PhpMyAdmin\\\\SqlParser\\\\UtfString will always evaluate to false\\.$#" - count: 1 - path: tests/Misc/UtfStringTest.php - - message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 597b0a774..699492845 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -12,9 +12,6 @@ $arrayKey - - Parser::$STATEMENT_PARSERS[$token->value] - $component From c5a8c54a02ab932433d2fe3d53d04a6ad0a182fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 14:36:19 -0300 Subject: [PATCH 05/15] Fix undefined property name in AlterOperation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced by 274fc3a6d169e42b4b249dd65f6abb01fd8f7966. Signed-off-by: Maurício Meneghini Fauth --- psalm-baseline.xml | 3 +++ src/Components/AlterOperation.php | 2 +- tests/data/parser/parseAlter3.out | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 699492845..597b0a774 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -12,6 +12,9 @@ $arrayKey + + Parser::$STATEMENT_PARSERS[$token->value] + $component diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index fc358622c..b28e451b4 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -445,7 +445,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = ); break; } - } elseif (! empty(Parser::$statementParsers[$token->value])) { + } elseif (! empty(Parser::$STATEMENT_PARSERS[$token->value])) { // We have reached the end of ALTER operation and suddenly found // a start to new statement, but have not found a delimiter between them $parser->error( diff --git a/tests/data/parser/parseAlter3.out b/tests/data/parser/parseAlter3.out index 69ae9bef1..b11efe29d 100644 --- a/tests/data/parser/parseAlter3.out +++ b/tests/data/parser/parseAlter3.out @@ -554,7 +554,7 @@ "lexer": [], "parser": [ [ - "Missing comma before start of a new alter operation.", + "A new statement was found, but no delimiter between it and the previous one.", { "@type": "@27" }, From 796b135d10ab384e9e2d7e5b276ac08499d9ccec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 15:00:08 -0300 Subject: [PATCH 06/15] Fix invalid hexadecimal prefix 0X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixes #508 Signed-off-by: Maurício Meneghini Fauth --- src/Lexer.php | 5 +- tests/Misc/BugsTest.php | 1 + tests/data/bugs/gh508.in | 1 + tests/data/bugs/gh508.out | 60 +++++++++++ tests/data/lexer/lexNumber.in | 6 +- tests/data/lexer/lexNumber.out | 185 +++++++++++++++++---------------- 6 files changed, 163 insertions(+), 95 deletions(-) create mode 100644 tests/data/bugs/gh508.in create mode 100644 tests/data/bugs/gh508.out diff --git a/src/Lexer.php b/src/Lexer.php index befaf4973..73b5aa060 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -851,10 +851,7 @@ public function parseNumber() } elseif ( $this->last + 1 < $this->len && $this->str[$this->last] === '0' - && ( - $this->str[$this->last + 1] === 'x' - || $this->str[$this->last + 1] === 'X' - ) + && $this->str[$this->last + 1] === 'x' ) { $token .= $this->str[$this->last++]; $state = 2; diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index f457f4cd3..f012caccb 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -26,6 +26,7 @@ public function bugProvider(): array ['bugs/gh14'], ['bugs/gh16'], ['bugs/gh317'], + ['bugs/gh508'], ['bugs/pma11800'], ['bugs/pma11836'], ['bugs/pma11843'], diff --git a/tests/data/bugs/gh508.in b/tests/data/bugs/gh508.in new file mode 100644 index 000000000..bef3a359a --- /dev/null +++ b/tests/data/bugs/gh508.in @@ -0,0 +1 @@ +0X0F \ No newline at end of file diff --git a/tests/data/bugs/gh508.out b/tests/data/bugs/gh508.out new file mode 100644 index 000000000..085f75e6d --- /dev/null +++ b/tests/data/bugs/gh508.out @@ -0,0 +1,60 @@ +{ + "query": "0X0F", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "0X0F", + "len": 4, + "last": 4, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "0X0F", + "value": "0X0F", + "keyword": null, + "type": 0, + "flags": 0, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 2, + "idx": 2 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unexpected beginning of statement.", + { + "@type": "@2" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/lexer/lexNumber.in b/tests/data/lexer/lexNumber.in index 6fe38851d..5751b0987 100644 --- a/tests/data/lexer/lexNumber.in +++ b/tests/data/lexer/lexNumber.in @@ -1,3 +1,3 @@ -SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, 0XFfA, -0xFFa, -0xfFA, -0XFfA, 1e-10, 1e10, .5e10, b'10'; --- invalid number -SELECT 12ex10, b'15'; \ No newline at end of file +SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10'; +-- invalid numbers +SELECT 12ex10, b'15', 0XFfA, -0XFfA; \ No newline at end of file diff --git a/tests/data/lexer/lexNumber.out b/tests/data/lexer/lexNumber.out index f28612d86..2609bb428 100644 --- a/tests/data/lexer/lexNumber.out +++ b/tests/data/lexer/lexNumber.out @@ -1,10 +1,10 @@ { - "query": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, 0XFfA, -0xFFa, -0xfFA, -0XFfA, 1e-10, 1e10, .5e10, b'10';\n-- invalid number\nSELECT 12ex10, b'15';", + "query": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA;", "lexer": { "@type": "PhpMyAdmin\\SqlParser\\Lexer", - "str": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, 0XFfA, -0xFFa, -0xfFA, -0XFfA, 1e-10, 1e10, .5e10, b'10';\n-- invalid number\nSELECT 12ex10, b'15';", - "len": 159, - "last": 159, + "str": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA;", + "len": 160, + "last": 160, "list": { "@type": "PhpMyAdmin\\SqlParser\\TokensList", "tokens": [ @@ -296,33 +296,6 @@ "flags": 0, "position": 61 }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "0XFfA", - "value": 4090, - "keyword": null, - "type": 6, - "flags": 1, - "position": 62 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": ",", - "value": ",", - "keyword": null, - "type": 2, - "flags": 16, - "position": 67 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": " ", - "value": " ", - "keyword": null, - "type": 3, - "flags": 0, - "position": 68 - }, { "@type": "PhpMyAdmin\\SqlParser\\Token", "token": "-0xFFa", @@ -330,7 +303,7 @@ "keyword": null, "type": 6, "flags": 9, - "position": 69 + "position": 62 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -339,7 +312,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 75 + "position": 68 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -348,7 +321,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 76 + "position": 69 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -357,7 +330,7 @@ "keyword": null, "type": 6, "flags": 9, - "position": 77 + "position": 70 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -366,34 +339,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 83 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": " ", - "value": " ", - "keyword": null, - "type": 3, - "flags": 0, - "position": 84 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "-0XFfA", - "value": -4090, - "keyword": null, - "type": 6, - "flags": 9, - "position": 85 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": ",", - "value": ",", - "keyword": null, - "type": 2, - "flags": 16, - "position": 91 + "position": 76 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -402,7 +348,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 92 + "position": 77 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -411,7 +357,7 @@ "keyword": null, "type": 6, "flags": 4, - "position": 93 + "position": 78 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -420,7 +366,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 98 + "position": 83 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -429,7 +375,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 99 + "position": 84 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -438,7 +384,7 @@ "keyword": null, "type": 6, "flags": 4, - "position": 100 + "position": 85 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -447,7 +393,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 104 + "position": 89 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -456,7 +402,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 105 + "position": 90 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -465,7 +411,7 @@ "keyword": null, "type": 6, "flags": 6, - "position": 106 + "position": 91 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -474,7 +420,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 111 + "position": 96 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -483,7 +429,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 112 + "position": 97 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -492,7 +438,7 @@ "keyword": null, "type": 6, "flags": 16, - "position": 113 + "position": 98 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -501,7 +447,7 @@ "keyword": null, "type": 9, "flags": 0, - "position": 118 + "position": 103 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -510,16 +456,16 @@ "keyword": null, "type": 3, "flags": 0, - "position": 119 + "position": 104 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "-- invalid number", - "value": "-- invalid number", + "token": "-- invalid numbers", + "value": "-- invalid numbers", "keyword": null, "type": 4, "flags": 4, - "position": 120 + "position": 105 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -528,7 +474,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 137 + "position": 123 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -537,7 +483,7 @@ "keyword": "SELECT", "type": 1, "flags": 3, - "position": 138 + "position": 124 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -546,7 +492,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 144 + "position": 130 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -555,7 +501,7 @@ "keyword": null, "type": 0, "flags": 0, - "position": 145 + "position": 131 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -564,7 +510,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 151 + "position": 137 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -573,7 +519,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 152 + "position": 138 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -582,7 +528,7 @@ "keyword": null, "type": 0, "flags": 0, - "position": 153 + "position": 139 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -591,6 +537,69 @@ "keyword": null, "type": 7, "flags": 1, + "position": 140 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 144 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 145 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "0XFfA", + "value": "0XFfA", + "keyword": null, + "type": 0, + "flags": 0, + "position": 146 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 151 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 152 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "-", + "value": "-", + "keyword": null, + "type": 2, + "flags": 1, + "position": 153 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "0XFfA", + "value": "0XFfA", + "keyword": null, + "type": 0, + "flags": 0, "position": 154 }, { @@ -600,7 +609,7 @@ "keyword": null, "type": 9, "flags": 0, - "position": 158 + "position": 159 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -612,7 +621,7 @@ "position": null } ], - "count": 67, + "count": 68, "idx": 0 }, "delimiter": ";", From 0eda5b69a69584b9a081ebaf6e0e38a3449c8538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 15:09:42 -0300 Subject: [PATCH 07/15] Add CHANGELOG entry for #508 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ci skip] Signed-off-by: Maurício Meneghini Fauth --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42636d70f..b3861bd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix `ALTER TABLE … MODIFY … ENUM('')` is being wrongly parsed (#478) - Fix MariaDB window function with alias gives bad linting errors (#283) - Fix unrecognized keyword `COLLATE` in `WHERE` clauses (#491) +- Fix invalid hexadecimal prefix 0X (#508) ## [5.8.0] - 2023-06-05 From b877ee6262a00f0f498da5e01335e8a5dc01d203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 15:21:22 -0300 Subject: [PATCH 08/15] Prepare for release 5.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3861bd93..0bc1d2f7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [5.x.x] - YYYY-MM-DD +## [5.8.1] - 2023-09-15 - Fix `:=` was not recognized as an operator just like `=` (#306) - Fix `ALTER TABLE … MODIFY … ENUM('')` is being wrongly parsed (#234) From 07bca9959d74f8dd334ea78b9cfbb92336ed3418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 15:29:02 -0300 Subject: [PATCH 09/15] Prepare for next release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ci skip] Signed-off-by: Maurício Meneghini Fauth --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc1d2f7a..4d5943b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## [5.8.x] - YYYY-MM-DD + ## [5.8.1] - 2023-09-15 - Fix `:=` was not recognized as an operator just like `=` (#306) From 3d0c3a62b8da095f2e761a7de8852a11c6e8fbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 15:30:48 -0300 Subject: [PATCH 10/15] Prepare for next release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ci skip] Signed-off-by: Maurício Meneghini Fauth --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5943b68..8714841f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## [5.9.x] - YYYY-MM-DD + ## [5.8.x] - YYYY-MM-DD ## [5.8.1] - 2023-09-15 From 8b3ab22de35421d52563740513d3cfb38b8244a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 18:34:52 -0300 Subject: [PATCH 11/15] Fix implicit conversion from float to int in AlterOperation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- phpstan-baseline.neon | 5 -- psalm-baseline.xml | 6 +- src/Components/AlterOperation.php | 6 +- tests/Misc/BugsTest.php | 1 + tests/data/bugs/fuzz1.in | 1 + tests/data/bugs/fuzz1.out | 114 ++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 tests/data/bugs/fuzz1.in create mode 100644 tests/data/bugs/fuzz1.out diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7de4c647c..0d1a703fe 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,11 +15,6 @@ parameters: count: 1 path: src/Components/AlterOperation.php - - - message: "#^Parameter \\#1 \\$key of function array_key_exists expects int\\|string, float\\|int\\|string given\\.$#" - count: 2 - path: src/Components/AlterOperation.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 597b0a774..36235b1e2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -12,9 +12,6 @@ $arrayKey - - Parser::$STATEMENT_PARSERS[$token->value] - $component @@ -631,8 +628,7 @@ $this->last $this->last - - $this->str[$this->last + 1] + $this->str[$this->last + 1] $this->str[$this->last++] $this->str[$this->last] diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index b28e451b4..271cdaf70 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -11,7 +11,7 @@ use function array_key_exists; use function in_array; -use function is_numeric; +use function is_int; use function is_string; use function trim; @@ -412,7 +412,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = $state = 2; } elseif ($state === 2) { - if (is_string($token->value) || is_numeric($token->value)) { + if (is_string($token->value) || is_int($token->value)) { $arrayKey = $token->value; } else { $arrayKey = $token->token; @@ -445,7 +445,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = ); break; } - } elseif (! empty(Parser::$STATEMENT_PARSERS[$token->value])) { + } elseif (! empty(Parser::$STATEMENT_PARSERS[$arrayKey])) { // We have reached the end of ALTER operation and suddenly found // a start to new statement, but have not found a delimiter between them $parser->error( diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index f012caccb..3fa44a524 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -22,6 +22,7 @@ public function testBug(string $test): void public function bugProvider(): array { return [ + ['bugs/fuzz1'], ['bugs/gh9'], ['bugs/gh14'], ['bugs/gh16'], diff --git a/tests/data/bugs/fuzz1.in b/tests/data/bugs/fuzz1.in new file mode 100644 index 000000000..406cde8e3 --- /dev/null +++ b/tests/data/bugs/fuzz1.in @@ -0,0 +1 @@ +ALTER..2 \ No newline at end of file diff --git a/tests/data/bugs/fuzz1.out b/tests/data/bugs/fuzz1.out new file mode 100644 index 000000000..4ebecfc0a --- /dev/null +++ b/tests/data/bugs/fuzz1.out @@ -0,0 +1,114 @@ +{ + "query": "ALTER..2", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "ALTER..2", + "len": 8, + "last": 8, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "ALTER", + "value": "ALTER", + "keyword": "ALTER", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ".", + "value": ".", + "keyword": null, + "type": 2, + "flags": 16, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ".2", + "value": 0.2, + "keyword": null, + "type": 6, + "flags": 2, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 4, + "idx": 4 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "table": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": null, + "column": null, + "expr": ".", + "alias": null, + "function": null, + "subquery": null + }, + "altered": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\AlterOperation", + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "field": null, + "partitions": null, + "unknown": [ + { + "@type": "@4" + } + ] + } + ], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 3 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unrecognized alter operation.", + { + "@type": "@5" + }, + 0 + ] + ] + } +} \ No newline at end of file From fb8fe989e578b231c729ab6e3f64de3ab4cf6f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 20:52:34 -0300 Subject: [PATCH 12/15] Fix undefined array key in WithStatement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CTE name must be a valid identifier. Signed-off-by: Maurício Meneghini Fauth --- src/Statements/WithStatement.php | 3 +- tests/Misc/BugsTest.php | 1 + tests/data/bugs/fuzz2.in | 1 + tests/data/bugs/fuzz2.out | 111 +++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 tests/data/bugs/fuzz2.in create mode 100644 tests/data/bugs/fuzz2.out diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index eb207496f..cd22ff55c 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -16,6 +16,7 @@ use function array_slice; use function count; +use function preg_match; /** * `WITH` statement. @@ -114,7 +115,7 @@ public function parse(Parser $parser, TokensList $list) } if ($state === 0) { - if ($token->type !== Token::TYPE_NONE) { + if ($token->type !== Token::TYPE_NONE || ! preg_match('/^[a-zA-Z0-9_$]+$/', $token->token)) { $parser->error('The name of the CTE was expected.', $token); break; } diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index 3fa44a524..cf9571d87 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -23,6 +23,7 @@ public function bugProvider(): array { return [ ['bugs/fuzz1'], + ['bugs/fuzz2'], ['bugs/gh9'], ['bugs/gh14'], ['bugs/gh16'], diff --git a/tests/data/bugs/fuzz2.in b/tests/data/bugs/fuzz2.in new file mode 100644 index 000000000..bda1ec626 --- /dev/null +++ b/tests/data/bugs/fuzz2.in @@ -0,0 +1 @@ +WITH]( \ No newline at end of file diff --git a/tests/data/bugs/fuzz2.out b/tests/data/bugs/fuzz2.out new file mode 100644 index 000000000..335ea320f --- /dev/null +++ b/tests/data/bugs/fuzz2.out @@ -0,0 +1,111 @@ +{ + "query": "WITH](", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "WITH](", + "len": 6, + "last": 6, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "]", + "value": "]", + "keyword": null, + "type": 0, + "flags": 0, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 4, + "idx": 4 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "withers": [], + "cteStatementParser": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 0 + } + ], + "brackets": 1, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [ + [ + "Unexpected character.", + "]", + 4, + 0 + ] + ], + "parser": [ + [ + "The name of the CTE was expected.", + { + "@type": "@3" + }, + 0 + ], + [ + "Unexpected end of the WITH CTE.", + { + "@type": "@3" + }, + 0 + ], + [ + "Unexpected beginning of statement.", + { + "@type": "@3" + }, + 0 + ] + ] + } +} \ No newline at end of file From b91a3a92b5f24f7ca3e0541e7ca3509321804077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 21:31:47 -0300 Subject: [PATCH 13/15] Fix undefined array key in WithStatement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if CTE column brackets was closed. Signed-off-by: Maurício Meneghini Fauth --- src/Components/ArrayObj.php | 4 + src/Statements/WithStatement.php | 7 +- tests/Misc/BugsTest.php | 1 + tests/data/bugs/fuzz3.in | 1 + tests/data/bugs/fuzz3.out | 113 +++++++++++++++++++++++++++ tests/data/parser/parseArrayErr3.out | 10 ++- 6 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 tests/data/bugs/fuzz3.in create mode 100644 tests/data/bugs/fuzz3.out diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index eab1b0659..1397eb243 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -92,6 +92,10 @@ public static function parse(Parser $parser, TokensList $list, array $options = // End of statement. if ($token->type === Token::TYPE_DELIMITER) { + if ($brackets > 0) { + $parser->error('A closing bracket was expected.', $token); + } + break; } diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index cd22ff55c..58c1d1dbc 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -125,7 +125,12 @@ public function parse(Parser $parser, TokensList $list) $state = 1; } elseif ($state === 1) { if ($token->type === Token::TYPE_OPERATOR && $token->value === '(') { - $this->withers[$wither]->columns = Array2d::parse($parser, $list); + $columns = Array2d::parse($parser, $list); + if ($parser->errors !== []) { + break; + } + + $this->withers[$wither]->columns = $columns; $state = 2; } elseif ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS') { $state = 3; diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index cf9571d87..b9ec4282a 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -24,6 +24,7 @@ public function bugProvider(): array return [ ['bugs/fuzz1'], ['bugs/fuzz2'], + ['bugs/fuzz3'], ['bugs/gh9'], ['bugs/gh14'], ['bugs/gh16'], diff --git a/tests/data/bugs/fuzz3.in b/tests/data/bugs/fuzz3.in new file mode 100644 index 000000000..48d31fa9b --- /dev/null +++ b/tests/data/bugs/fuzz3.in @@ -0,0 +1 @@ +WITH*/A( \ No newline at end of file diff --git a/tests/data/bugs/fuzz3.out b/tests/data/bugs/fuzz3.out new file mode 100644 index 000000000..6b9ee9903 --- /dev/null +++ b/tests/data/bugs/fuzz3.out @@ -0,0 +1,113 @@ +{ + "query": "WITH*/A(", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "WITH*/A(", + "len": 8, + "last": 8, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*/", + "value": "*/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "A", + "value": "A", + "keyword": null, + "type": 0, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 5, + "idx": 5 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "withers": { + "A": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "A", + "columns": [], + "statement": null + } + }, + "cteStatementParser": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 3 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "A closing bracket was expected.", + { + "@type": "@6" + }, + 0 + ], + [ + "Unexpected end of the WITH CTE.", + { + "@type": "@6" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseArrayErr3.out b/tests/data/parser/parseArrayErr3.out index 4b86033d0..81a1c2928 100644 --- a/tests/data/parser/parseArrayErr3.out +++ b/tests/data/parser/parseArrayErr3.out @@ -239,6 +239,14 @@ }, "errors": { "lexer": [], - "parser": [] + "parser": [ + [ + "A closing bracket was expected.", + { + "@type": "@17" + }, + 0 + ] + ] } } \ No newline at end of file From 3a02adeb0de60c0e7d60b5605eccb255dcc072dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 15 Sep 2023 22:38:10 -0300 Subject: [PATCH 14/15] Fix undefined array key AlterOperation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- src/Statements/AlterStatement.php | 9 ++- tests/Misc/BugsTest.php | 1 + tests/data/bugs/fuzz1.out | 44 ++++---------- tests/data/bugs/fuzz4.in | 1 + tests/data/bugs/fuzz4.out | 98 +++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 33 deletions(-) create mode 100644 tests/data/bugs/fuzz4.in create mode 100644 tests/data/bugs/fuzz4.out diff --git a/src/Statements/AlterStatement.php b/src/Statements/AlterStatement.php index de3123c43..3cd902d78 100644 --- a/src/Statements/AlterStatement.php +++ b/src/Statements/AlterStatement.php @@ -67,7 +67,14 @@ class AlterStatement extends Statement public function parse(Parser $parser, TokensList $list) { ++$list->idx; // Skipping `ALTER`. - $this->options = OptionsArray::parse($parser, $list, static::$OPTIONS); + $parsedOptions = OptionsArray::parse($parser, $list, static::$OPTIONS); + if ($parsedOptions->isEmpty()) { + $parser->error('Unrecognized alter operation.', $list->tokens[$list->idx]); + + return; + } + + $this->options = $parsedOptions; ++$list->idx; // Parsing affected table. diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index b9ec4282a..2faa7e13d 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -25,6 +25,7 @@ public function bugProvider(): array ['bugs/fuzz1'], ['bugs/fuzz2'], ['bugs/fuzz3'], + ['bugs/fuzz4'], ['bugs/gh9'], ['bugs/gh14'], ['bugs/gh16'], diff --git a/tests/data/bugs/fuzz1.out b/tests/data/bugs/fuzz1.out index 4ebecfc0a..c7a03aba8 100644 --- a/tests/data/bugs/fuzz1.out +++ b/tests/data/bugs/fuzz1.out @@ -61,38 +61,11 @@ "statements": [ { "@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", - "table": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", - "database": null, - "table": null, - "column": null, - "expr": ".", - "alias": null, - "function": null, - "subquery": null - }, - "altered": [ - { - "@type": "PhpMyAdmin\\SqlParser\\Components\\AlterOperation", - "options": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", - "options": [] - }, - "field": null, - "partitions": null, - "unknown": [ - { - "@type": "@4" - } - ] - } - ], - "options": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", - "options": [] - }, + "table": null, + "altered": [], + "options": null, "first": 0, - "last": 3 + "last": 0 } ], "brackets": 0, @@ -105,7 +78,14 @@ [ "Unrecognized alter operation.", { - "@type": "@5" + "@type": "@2" + }, + 0 + ], + [ + "Unexpected beginning of statement.", + { + "@type": "@4" }, 0 ] diff --git a/tests/data/bugs/fuzz4.in b/tests/data/bugs/fuzz4.in new file mode 100644 index 000000000..c688c143f --- /dev/null +++ b/tests/data/bugs/fuzz4.in @@ -0,0 +1 @@ +ALTeR=SET \ No newline at end of file diff --git a/tests/data/bugs/fuzz4.out b/tests/data/bugs/fuzz4.out new file mode 100644 index 000000000..2801189a1 --- /dev/null +++ b/tests/data/bugs/fuzz4.out @@ -0,0 +1,98 @@ +{ + "query": "ALTeR=SET", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "ALTeR=SET", + "len": 9, + "last": 9, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "ALTeR", + "value": "ALTER", + "keyword": "ALTER", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "=", + "value": "=", + "keyword": null, + "type": 2, + "flags": 2, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SET", + "value": "SET", + "keyword": "SET", + "type": 1, + "flags": 11, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 4, + "idx": 4 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "table": null, + "altered": [], + "options": null, + "first": 0, + "last": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "end_options": null, + "set": [], + "first": 1, + "last": 2 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unrecognized alter operation.", + { + "@type": "@2" + }, + 0 + ] + ] + } +} \ No newline at end of file From dd1e7752966bf16a0e31b110ac2643701f54ba4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 16 Sep 2023 00:54:06 -0300 Subject: [PATCH 15/15] Fix invalid characters passed to hexdec function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- src/Token.php | 2 +- tests/data/bugs/fuzz5.in | 1 + tests/data/bugs/fuzz5.out | 76 ++++++++++++++++++ tests/data/bugs/fuzz6.in | 1 + tests/data/bugs/fuzz6.out | 69 ++++++++++++++++ tests/data/lexer/lexNumber.in | 4 +- tests/data/lexer/lexNumber.out | 139 ++++++++++++++++++++++++--------- 7 files changed, 251 insertions(+), 41 deletions(-) create mode 100644 tests/data/bugs/fuzz5.in create mode 100644 tests/data/bugs/fuzz5.out create mode 100644 tests/data/bugs/fuzz6.in create mode 100644 tests/data/bugs/fuzz6.out diff --git a/src/Token.php b/src/Token.php index c7b028b3d..0e2698bb5 100644 --- a/src/Token.php +++ b/src/Token.php @@ -254,8 +254,8 @@ public function extract() case self::TYPE_NUMBER: $ret = str_replace('--', '', $this->token); // e.g. ---42 === -42 if ($this->flags & self::FLAG_NUMBER_HEX) { + $ret = str_replace(['-', '+'], '', $this->token); if ($this->flags & self::FLAG_NUMBER_NEGATIVE) { - $ret = str_replace('-', '', $this->token); $ret = -hexdec($ret); } else { $ret = hexdec($ret); diff --git a/tests/data/bugs/fuzz5.in b/tests/data/bugs/fuzz5.in new file mode 100644 index 000000000..61dd39880 --- /dev/null +++ b/tests/data/bugs/fuzz5.in @@ -0,0 +1 @@ ++0xO \ No newline at end of file diff --git a/tests/data/bugs/fuzz5.out b/tests/data/bugs/fuzz5.out new file mode 100644 index 000000000..ee8ec15e4 --- /dev/null +++ b/tests/data/bugs/fuzz5.out @@ -0,0 +1,76 @@ +{ + "query": "+0xO", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "+0xO", + "len": 4, + "last": 4, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "+0x", + "value": 0, + "keyword": null, + "type": 6, + "flags": 1, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "O", + "value": "O", + "keyword": null, + "type": 0, + "flags": 0, + "position": 3 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 3, + "idx": 3 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unexpected beginning of statement.", + { + "@type": "@2" + }, + 0 + ], + [ + "Unexpected beginning of statement.", + { + "@type": "@3" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/bugs/fuzz6.in b/tests/data/bugs/fuzz6.in new file mode 100644 index 000000000..f3afa7709 --- /dev/null +++ b/tests/data/bugs/fuzz6.in @@ -0,0 +1 @@ +-+0x! \ No newline at end of file diff --git a/tests/data/bugs/fuzz6.out b/tests/data/bugs/fuzz6.out new file mode 100644 index 000000000..fce6bf5b7 --- /dev/null +++ b/tests/data/bugs/fuzz6.out @@ -0,0 +1,69 @@ +{ + "query": "-+0x!", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "-+0x!", + "len": 5, + "last": 5, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "-+0x", + "value": 0, + "keyword": null, + "type": 6, + "flags": 9, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "!", + "value": "!", + "keyword": null, + "type": 2, + "flags": 2, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 3, + "idx": 3 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unexpected beginning of statement.", + { + "@type": "@2" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/lexer/lexNumber.in b/tests/data/lexer/lexNumber.in index 5751b0987..a0fff528e 100644 --- a/tests/data/lexer/lexNumber.in +++ b/tests/data/lexer/lexNumber.in @@ -1,3 +1,3 @@ -SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10'; +SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, +0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10'; -- invalid numbers -SELECT 12ex10, b'15', 0XFfA, -0XFfA; \ No newline at end of file +SELECT 12ex10, b'15', 0XFfA, -0XFfA, +0XFfA; \ No newline at end of file diff --git a/tests/data/lexer/lexNumber.out b/tests/data/lexer/lexNumber.out index 2609bb428..5c6988dd1 100644 --- a/tests/data/lexer/lexNumber.out +++ b/tests/data/lexer/lexNumber.out @@ -1,10 +1,10 @@ { - "query": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA;", + "query": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, +0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA, +0XFfA;", "lexer": { "@type": "PhpMyAdmin\\SqlParser\\Lexer", - "str": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA;", - "len": 160, - "last": 160, + "str": "SELECT 12, 34, 5.67, 0x89, -10, --11, +12, .15, 0xFFa, 0xfFA, +0xfFA, -0xFFa, -0xfFA, 1e-10, 1e10, .5e10, b'10';\n-- invalid numbers\nSELECT 12ex10, b'15', 0XFfA, -0XFfA, +0XFfA;", + "len": 176, + "last": 176, "list": { "@type": "PhpMyAdmin\\SqlParser\\TokensList", "tokens": [ @@ -298,11 +298,11 @@ }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "-0xFFa", - "value": -4090, + "token": "+0xfFA", + "value": 4090, "keyword": null, "type": 6, - "flags": 9, + "flags": 1, "position": 62 }, { @@ -325,7 +325,7 @@ }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "-0xfFA", + "token": "-0xFFa", "value": -4090, "keyword": null, "type": 6, @@ -350,6 +350,33 @@ "flags": 0, "position": 77 }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "-0xfFA", + "value": -4090, + "keyword": null, + "type": 6, + "flags": 9, + "position": 78 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 84 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 85 + }, { "@type": "PhpMyAdmin\\SqlParser\\Token", "token": "1e-10", @@ -357,7 +384,7 @@ "keyword": null, "type": 6, "flags": 4, - "position": 78 + "position": 86 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -366,7 +393,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 83 + "position": 91 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -375,7 +402,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 84 + "position": 92 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -384,7 +411,7 @@ "keyword": null, "type": 6, "flags": 4, - "position": 85 + "position": 93 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -393,7 +420,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 89 + "position": 97 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -402,7 +429,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 90 + "position": 98 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -411,7 +438,7 @@ "keyword": null, "type": 6, "flags": 6, - "position": 91 + "position": 99 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -420,7 +447,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 96 + "position": 104 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -429,7 +456,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 97 + "position": 105 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -438,7 +465,7 @@ "keyword": null, "type": 6, "flags": 16, - "position": 98 + "position": 106 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -447,7 +474,7 @@ "keyword": null, "type": 9, "flags": 0, - "position": 103 + "position": 111 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -456,7 +483,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 104 + "position": 112 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -465,7 +492,7 @@ "keyword": null, "type": 4, "flags": 4, - "position": 105 + "position": 113 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -474,7 +501,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 123 + "position": 131 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -483,7 +510,7 @@ "keyword": "SELECT", "type": 1, "flags": 3, - "position": 124 + "position": 132 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -492,7 +519,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 130 + "position": 138 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -501,7 +528,7 @@ "keyword": null, "type": 0, "flags": 0, - "position": 131 + "position": 139 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -510,7 +537,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 137 + "position": 145 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -519,7 +546,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 138 + "position": 146 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -528,7 +555,7 @@ "keyword": null, "type": 0, "flags": 0, - "position": 139 + "position": 147 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -537,7 +564,7 @@ "keyword": null, "type": 7, "flags": 1, - "position": 140 + "position": 148 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -546,7 +573,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 144 + "position": 152 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -555,7 +582,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 145 + "position": 153 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -564,7 +591,7 @@ "keyword": null, "type": 0, "flags": 0, - "position": 146 + "position": 154 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -573,7 +600,7 @@ "keyword": null, "type": 2, "flags": 16, - "position": 151 + "position": 159 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -582,7 +609,7 @@ "keyword": null, "type": 3, "flags": 0, - "position": 152 + "position": 160 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -591,7 +618,7 @@ "keyword": null, "type": 2, "flags": 1, - "position": 153 + "position": 161 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -600,7 +627,43 @@ "keyword": null, "type": 0, "flags": 0, - "position": 154 + "position": 162 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 167 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 168 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "+", + "value": "+", + "keyword": null, + "type": 2, + "flags": 1, + "position": 169 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "0XFfA", + "value": "0XFfA", + "keyword": null, + "type": 0, + "flags": 0, + "position": 170 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -609,7 +672,7 @@ "keyword": null, "type": 9, "flags": 0, - "position": 159 + "position": 175 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -621,7 +684,7 @@ "position": null } ], - "count": 68, + "count": 75, "idx": 0 }, "delimiter": ";",