Skip to content

Commit 6678856

Browse files
committed
Improve property and method naming and documentation
1 parent e0dfccd commit 6678856

File tree

7 files changed

+349
-217
lines changed

7 files changed

+349
-217
lines changed

tests/mysql/WP_MySQL_Lexer_Tests.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ class WP_MySQL_Lexer_Tests extends TestCase {
1313
* @dataProvider data_identifier_or_number
1414
*/
1515
public function test_identifier_or_number( $input, $expected ): void {
16+
$lexer = new WP_MySQL_Lexer( $input );
1617
$actual = array_map(
1718
function ( $token ) {
1819
return $token->get_type();
1920
},
20-
WP_MySQL_Lexer::tokenize( $input )
21+
$lexer->remaining_tokens()
2122
);
2223

2324
// Compare token names to get more readable error messages.

tests/mysql/WP_MySQL_Server_Suite_Lexer_Tests.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public function test_tokenize_mysql_test_suite(): void {
2323
try {
2424
while ( ( $record = fgetcsv( $handle ) ) !== false ) {
2525
$query = $record[0];
26-
$tokens = WP_MySQL_Lexer::tokenize( $query );
26+
$lexer = new WP_MySQL_Lexer( $query );
27+
$tokens = $lexer->remaining_tokens();
2728
$this->assertNotEmpty( $tokens, "Failed to tokenize query: $query" );
2829
}
2930
} finally {

tests/mysql/WP_MySQL_Server_Suite_Parser_Tests.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public function test_parse_mysql_test_suite( array $batch ): void {
4848
foreach ( $batch as $record ) {
4949
$query = $record[0];
5050

51-
$tokens = WP_MySQL_Lexer::tokenize( $query );
51+
$lexer = new WP_MySQL_Lexer( $query );
52+
$tokens = $lexer->remaining_tokens();
5253
$this->assertNotEmpty( $tokens, "Failed to tokenize query: $query" );
5354

5455
$parser = new WP_MySQL_Parser( self::$grammar, $tokens );

tests/tools/run-lexer-benchmark.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function ( $severity, $message, $file, $line ) {
2727
$start = microtime( true );
2828
for ( $i = 0; $i < count( $records ); $i += 1 ) {
2929
$query = $records[ $i ][0];
30-
$tokens = WP_MySQL_Lexer::tokenize( $query );
30+
$lexer = new WP_MySQL_Lexer( $query );
31+
$tokens = $lexer->remaining_tokens();
3132
if ( count( $tokens ) === 0 ) {
3233
throw new Exception( 'Failed to tokenize query: ' . $query );
3334
}

tests/tools/run-parser-benchmark.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ function getStats( $total, $failures, $exceptions ) {
5555
}
5656

5757
try {
58-
$tokens = WP_MySQL_Lexer::tokenize( $query );
58+
$lexer = new WP_MySQL_Lexer( $query );
59+
$tokens = $lexer->remaining_tokens();
5960
if ( count( $tokens ) === 0 ) {
6061
throw new Exception( 'Failed to tokenize query: ' . $query );
6162
}

tests/tools/run-parser-test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function ( $severity, $message, $file, $line ) {
2424
$grammar = new WP_Parser_Grammar( $grammar_data );
2525

2626
// Edit the query below to test different inputs:
27-
$tokens = WP_MySQL_Lexer::tokenize( 'SELECT 1' );
27+
$lexer = new WP_MySQL_Lexer( 'SELECT 1' );
28+
$tokens = $lexer->remaining_tokens();
2829

2930
echo "Tokens:\n";
3031
foreach ( $tokens as $token ) {

0 commit comments

Comments
 (0)