What about this?
class EntryPoint {
public object $privateCollaborator;
public function __construct() {
$this->privateCollaborator = self::getPrivateCollaborator();
}
private static function getPrivateCollaborator() {
return new class {
};
}
}
$entryPoint = new EntryPoint();
I sometimes use it so as not to dirty the LSP-Intelephense autocomplete in Sublime Text. If I remove the object type to the property at the entrance point, LSP-Intelephense will recognize the reference of the object, being able to self-fulfill the members of that collaborator