Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native parameter types to Token constructor #526

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

MauricioFauth
Copy link
Member

@MauricioFauth MauricioFauth commented Jan 15, 2024

Ensures that token are always a string and that flags are always an integer.

Using an empty string for the last delimiter has the same effect as using null.

Signed-off-by: Maurício Meneghini Fauth <[email protected]>
Ensures that token are always a string and that flags are always an
integer.

Signed-off-by: Maurício Meneghini Fauth <[email protected]>
Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (94f2db2) 96.45% compared to head (16389b2) 96.45%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #526   +/-   ##
=========================================
  Coverage     96.45%   96.45%           
  Complexity     2152     2152           
=========================================
  Files            64       64           
  Lines          5019     5019           
=========================================
  Hits           4841     4841           
  Misses          178      178           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MauricioFauth
Copy link
Member Author

@kamil-tekiela What do you think?

@kamil-tekiela
Copy link
Contributor

On line 256 in Lexer you still assign null to $delimiter property which is then used on line 1013. Isn't this a problem still?

@@ -360,7 +360,7 @@ private function solveAmbiguityOnFunctionKeywords(): void
&& ($next->type !== TokenType::Operator
|| ! in_array($next->value, self::OPERATOR_NAME_INDICATORS, true)
)
&& ($next->value !== null)
&& ($next->value !== '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that this ok, but I feel like the phpdoc should be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Token::$value type should definitely be updated. That value is only created by Lexer line 285.

sql-parser/src/Lexer.php

Lines 284 to 285 in 94f2db2

// Adding a final delimiter to mark the ending.
$list->tokens[$list->count++] = new Token(null, TokenType::Delimiter);

@MauricioFauth
Copy link
Member Author

On line 256 in Lexer you still assign null to $delimiter property which is then used on line 1013. Isn't this a problem still?

Lexer::$delimiter should only be string. But this is not an issue because it gets coerced to string right after.

@MauricioFauth MauricioFauth self-assigned this Jan 16, 2024
@MauricioFauth MauricioFauth merged commit 3b7191a into phpmyadmin:master Jan 16, 2024
11 of 12 checks passed
@MauricioFauth MauricioFauth deleted the Token-construct branch January 16, 2024 17:19
@williamdes williamdes modified the milestones: 5.9.0, 6.0.0 Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants