79583039

Date: 2025-04-20 04:49:45
Score: 1
Natty:
Report link

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

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What
  • Low reputation (1):
Posted by: Franyer Sánchez