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

Don't pass null as parameter #8896

Merged
merged 1 commit into from
Aug 9, 2021

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Aug 7, 2021

Passing null to various core functions triggers a deprecation warning in PHP 8.1. This PR attempts to fix this kind of error.

Verified

This commit was signed with the committer’s verified signature.
greg0ire Grégoire Paris
Signed-off-by: Alexander M. Turek <me@derrabus.de>
@@ -511,7 +511,7 @@ public function syntaxError($expected = '', $token = null)
$message .= $expected !== '' ? sprintf('Expected %s, got ', $expected) : 'Unexpected ';
$message .= $this->lexer->lookahead === null ? 'end of string.' : sprintf("'%s'", $token['value']);

throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL()));
throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL() ?? ''));
Copy link
Member Author

Choose a reason for hiding this comment

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

💡 $message of Exception::__construct() must not be null.

@@ -528,7 +528,7 @@ public function syntaxError($expected = '', $token = null)
public function semanticalError($message = '', $token = null)
{
if ($token === null) {
$token = $this->lexer->lookahead ?? ['position' => null];
$token = $this->lexer->lookahead ?? ['position' => 0];
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['position'] is later used as $offset for substr().

@greg0ire greg0ire merged commit 4fa2f6b into doctrine:2.9.x Aug 9, 2021
@greg0ire
Copy link
Member

greg0ire commented Aug 9, 2021

Thanks @derrabus !

@derrabus derrabus deleted the bugfix/dont-pass-null branch August 9, 2021 07:31
@greg0ire greg0ire added this to the 2.9.4 milestone Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants