8000 Add doctrine/lexer v3 compatibility by zanardigit · Pull Request #3527 · bolt/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add doctrine/lexer v3 compatibility #3527

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

Closed
wants to merge 1 commit into from

Conversation

zanardigit
Copy link

Using the token as Token object is compatible with both v2 and v3 of doctrine/lexer

Using the token as Token object is compatible with both v2 and v3 of doctrine/lexer
@bobvandevijver
Copy link
Member

@zanardigit Can you rebase this and solve the PHPStan issue?

@@ -52,7 +52,7 @@ public function parse(Parser $parser): void
$this->first = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_AS);
$parser->match(Lexer::T_IDENTIFIER);
$this->second = $parser->getLexer()->token['value'];
$this->second = $parser->getLexer()->token->value;
Copy link
Contributor

Choose a reason for hiding this comment

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

@bobvandevijver I have written this code to fix it because the Lexer can be installed in version 2 or 3!

Suggested change
$this->second = $parser->getLexer()->token->value;
// doctrine/lexer v2
if (is_array($parser->getLexer()->token)) {
$this->second = $parser->getLexer()->token['value'];
/** @phpstan-ignore-next-line */
} elseif (is_object($parser->getLexer()->token)) { // doctrine/lexer v3
$this->second = $parser->getLexer()->token->value;
} else {
throw new \LogicException('Unable to access parser token');
}

Copy link
Author

Choose a reason for hiding this comment

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

@macintoshplus it's been a while since I tested this, but as far as i remember using the token as a Token object should be compatible with both v2 and v3 of doctrine/lexer. So, that is probably not required. Feel free to correct me if you found different results.

Copy link
Contributor

Choose a reason for hiding this comment

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

@zanardigit, I have fixed this error today by requiring doctrine/lexer v2 in my project.
After the library downgrade the Bolt code works fine but, I don't want to keep this requirement in my project.

We don't know the version used in the project. We must assume works with version 2 or 3.

Copy link
Author
@zanardigit zanardigit Mar 7, 2025

Choose a reason for hiding this comment

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

@macintoshplus cannot test right now, I trust you.
In that case, my PR should be rejected; you should issue a new one with the proposed changes, which are safer and will work in any case, so they are definitely better.

@zanardigit zanardigit closed this Mar 7, 2025
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
0