website/errors/return.noParent.md
<?php declare(strict_types = 1);
class Foo
{
public function create(): parent
{
}
}
The parent keyword in PHP refers to the parent class of the current class. It can only be used inside a class that extends another class. When parent is used as a return type in a class that does not extend any other class, it has no meaning because there is no parent class to refer to.
Replace parent with the actual class name that was intended:
class Foo
{
- public function create(): parent
+ public function create(): self
{
}
}
If the class should have a parent, add the extends clause:
-class Foo
+class Foo extends BaseClass
{
public function create(): parent
{
+ return new BaseClass();
}
}