It seems like you're encountering an issue where the typed property $form is being accessed before it has been initialized. In PHP, typed properties must be initialized before you can access them, otherwise, you'll get the error you're seeing.
To solve this issue, you need to ensure that the $form property is initialized before you try to use it. You can do this by either providing a default value when you declare the property or by initializing it in the mount method before you access it.
Here's how you can modify your mount method to ensure $form is initialized:
public ?SipTrunksForm $form = null;
public function mount(?SipTrunk $sipTrunk): void
{
$this->form = new SipTrunksForm(); // Initialize the form property
if ($sipTrunk && $sipTrunk->exists) {
$this->form->setSipTrunk($sipTrunk);
}
}
In the above code, I've added a default value of null to the $form property declaration. Then, in the mount method, I've initialized $form with a new instance of SipTrunksForm before checking if $sipTrunk exists and setting it.
This should resolve the error you're encountering. If SipTrunksForm requires any parameters for its constructor, make sure to pass them when creating the new instance.