Skip to content

Self and Parent Types

PHP allows using self and parent as return types.

class Base {
public function create(): self {
return new self();
}
}
class Child extends Base {
public function create(): parent {
return parent::create();
}
}