Open jangaraev opened 1 month ago
there is also an option to call parent's constructor in Butschster\Head\Packages\Package
:
public function __construct(
protected string $name,
) {
parent::__construct(app(ManagerInterface::class));
$this->placements = new PlacementsBag();
}
something like that
does anyone faced this issue? do I use a wrong approach, probably?
Describe the bug I have this error in my script.
Typed property Butschster\Head\MetaTags\Meta::$config must not be accessed before initialization
this is how the code is organized in my project:
the controller (actually the trait, but it doesn't make sense here):
it's clearly seen that I instantiate an instance of
\Butschster\Head\Packages\Package
, which is okay, and it extends the\Butschster\Head\MetaTags\Meta
which has a different declaration of constructor where the$config
variable is expected.apparently the thing is Package doesn't call the parent's constructor and that's why the private promoted property
$config
in Meta lefts undefined.Environment:
Possible solution The easiest fix is to declare the
$config
variable in a regular way (not promoted), so the code looks like thisthanks for your open-source development