I encoutered this bug when creating a new TemplatedMailMessage and using the 'alias' directive instead of using an identifier. My code looks like this:
$message = (new TemplatedMailMessage())
->from(
config('mail.from.address'),
config('mail.from.name'))
->alias($this->templateId)
->include($this->templateModel($notifiable));
In the 2.x versions of your package this worked. But in the 3.x version it throws this error:
Error: Typed property CraigPaul\Mail\TemplatedMailMessage::$id must not be accessed before initialization in /.../vendor/coconutcraig/laravel-postmark/src/TemplatedMailMessage.php:27
However, when adding the "identifier" with value '0' it does work:
$message = (new TemplatedMailMessage())
->from(
config('mail.from.address'),
config('mail.from.name'))
->identifier(0)
->alias($this->templateId)
->include($this->templateModel($notifiable));
Possible implementation
Change the id property on the TemplatedMailMessage class to this:
Detailed description
I encoutered this bug when creating a new TemplatedMailMessage and using the 'alias' directive instead of using an identifier. My code looks like this:
In the 2.x versions of your package this worked. But in the 3.x version it throws this error:
Error: Typed property CraigPaul\Mail\TemplatedMailMessage::$id must not be accessed before initialization in /.../vendor/coconutcraig/laravel-postmark/src/TemplatedMailMessage.php:27
However, when adding the "identifier" with value '0' it does work:
Possible implementation
Change the id property on the TemplatedMailMessage class to this:
protected ?int $id = null;
Your environment