-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix "Trying to access array offset on value of type null" #228
Conversation
Added a check that `$previous` is not null (i.e. previous token exists)
When could it be null? |
It's hard t say, I've found it in log file of a laravel-based project:
All input emails in |
That's rare, yes. If "previous" is |
It looks like to be environment-dependent. I've added if ($previous === null) {
file_put_contents(__FILE__ . '.log',
var_export($this->lexer, true) . "\n\n\n",
FILE_APPEND);
} inside of
Unfortunately my attempt to reproduce the issue via a simple script has been failed (i.e. no error is triggered):
Not sure what I could check additionally. |
According to composer.lock, the installed version is 2.1.6. Maybe the issue has been fixed in 2.1.10, but unfortunately I'm not directly involved into that project and cannot update it to check. |
@dryabov maybe you can check Swiftmailer's email generator to see which chars they use and then explore with the lexer test (https://github.com/egulias/EmailValidator/blob/master/Tests/EmailValidator/EmailLexerTest.php#L126) to see if you are able to produce a 'null' element. |
Ive also started getting this error recently, it was working fine. Maybe related to updating to php7.4? |
Thanks @ricardo118 . Are you able to reproduce it with a test? |
This is indeed due to upgrading to PHP 7.4. Its first backward incompatible change is:
It seems to work fine after replacing line 147 of Parser.php with: |
Hi @cetetesoft good to hear. However, the mistery is under which circumstances |
@egulias, any email address seems to trigger the error: |
@cetetesoft however, all test pass in PHP 7.4. I'm investigating the issue. |
I'll merge for now and find later how this can happen. |
Added a check that
$previous
is not null (i.e. previous token exists)