我正在尝试在 Laravel 5.5 中渲染一封电子邮件,但无论我做什么,我都会在渲染时收到以下错误:
ErrorException (E_NOTICE) Trying to access array offset on value of type null
发生在 \vendor\egulias\email-validator\EmailValidator\Parser\Parser.php
我正在运行 php 7.4,我相信该错误不会发生在 php 7.3 上。
网页.php:
Route::get('scratch', function(){
$mail = new Test();
return $mail->render();
});
Run Code Online (Sandbox Code Playgroud)
测试.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Test extends Mailable
{
use Queueable, SerializesModels;
public $subscription;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.test');
}
}
Run Code Online (Sandbox Code Playgroud)
测试.blade.php
Hello from world
Run Code Online (Sandbox Code Playgroud)
我认为这一定是 Laravel 5.5 和 PHP 7.4 的问题。我可以更改我的版本,但如果可能的话我想避免这种情况。升级 Laravel 不适用于此应用程序。
编辑
这条线失败了vendor\egulias\email-validator\EmailValidator\Parser\Parser.php
protected function escaped()
{
$previous = $this->lexer->getPrevious();
if ($previous['type'] === EmailLexer::S_BACKSLASH // here
&&
$this->lexer->token['type'] !== EmailLexer::GENERIC
) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3200 次 |
| 最近记录: |