1
1
<?php
2
2
/**
3
- * This file is a port of the Lexer & Tokens_List classes from the PHPMyAdmin/sql-parser library.
3
+ * This file is a port of the Lexer & TokensList classes from the PHPMyAdmin/sql-parser library.
4
4
*
5
5
* @package wp-sqlite-integration
6
6
* @see https://github.com/phpmyadmin/sql-parser
@@ -33,7 +33,7 @@ class WP_SQLite_Lexer {
33
33
*
34
34
* @var string[]
35
35
*/
36
- public static $ parser_methods = array (
36
+ protected const PARSER_METHODS = array (
37
37
// It is best to put the parsers in order of their complexity
38
38
// (ascending) and their occurrence rate (descending).
39
39
//
@@ -77,7 +77,7 @@ class WP_SQLite_Lexer {
77
77
*
78
78
* @var string[]
79
79
*/
80
- public $ keyword_name_indicators = array (
80
+ protected const KEYWORD_NAME_INDICATORS = array (
81
81
'FROM ' ,
82
82
'SET ' ,
83
83
'WHERE ' ,
@@ -89,7 +89,7 @@ class WP_SQLite_Lexer {
89
89
*
90
90
* @var string[]
91
91
*/
92
- public $ operator_name_indicators = array (
92
+ protected const OPERATOR_NAME_INDICATORS = array (
93
93
', ' ,
94
94
'. ' ,
95
95
);
@@ -1486,7 +1486,7 @@ public function lex() {
1486
1486
*/
1487
1487
$ token = null ;
1488
1488
1489
- foreach ( static :: $ parser_methods as $ method ) {
1489
+ foreach ( self :: PARSER_METHODS as $ method ) {
1490
1490
$ token = $ this ->$ method ();
1491
1491
1492
1492
if ( $ token ) {
@@ -1668,10 +1668,10 @@ private function solve_ambiguity_on_function_keywords() {
1668
1668
$ next = $ this ->tokens_get_next ();
1669
1669
if (
1670
1670
( WP_SQLite_Token::TYPE_KEYWORD !== $ next ->type
1671
- || ! in_array ( $ next ->value , $ this -> keyword_name_indicators , true )
1671
+ || ! in_array ( $ next ->value , self :: KEYWORD_NAME_INDICATORS , true )
1672
1672
)
1673
1673
&& ( WP_SQLite_Token::TYPE_OPERATOR !== $ next ->type
1674
- || ! in_array ( $ next ->value , $ this -> operator_name_indicators , true )
1674
+ || ! in_array ( $ next ->value , self :: OPERATOR_NAME_INDICATORS , true )
1675
1675
)
1676
1676
&& ( null !== $ next ->value )
1677
1677
) {
@@ -2068,7 +2068,7 @@ public function parse_number() {
2068
2068
} elseif (
2069
2069
$ this ->last + 1 < $ this ->string_length
2070
2070
&& '0 ' === $ this ->str [ $ this ->last ]
2071
- && ( 'x ' === $ this ->str [ $ this ->last + 1 ] || ' X ' === $ this -> str [ $ this -> last + 1 ] )
2071
+ && 'x ' === $ this ->str [ $ this ->last + 1 ]
2072
2072
) {
2073
2073
$ token .= $ this ->str [ $ this ->last ++ ];
2074
2074
$ state = 2 ;
@@ -2514,15 +2514,10 @@ public static function is_separator( $str ) {
2514
2514
* Constructor.
2515
2515
*
2516
2516
* @param stdClass[] $tokens The initial array of tokens.
2517
- * @param int $count The count of tokens in the initial array.
2518
2517
*/
2519
- public function tokens ( array $ tokens = array (), $ count = -1 ) {
2520
- if ( empty ( $ tokens ) ) {
2521
- return ;
2522
- }
2523
-
2518
+ public function tokens ( array $ tokens = array () ) {
2524
2519
$ this ->tokens = $ tokens ;
2525
- $ this ->tokens_count = - 1 === $ count ? count ( $ tokens ) : $ count ;
2520
+ $ this ->tokens_count = count ( $ tokens );
2526
2521
}
2527
2522
2528
2523
/**
0 commit comments