MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / demo

Method demo

examples/demo.php:481–503  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

479class InheritedDocblockDemo
480{
481 public function demo(): void
482 {
483 // Interface declares @return list<Pen>, implementor has only `: array`.
484 // The richer type propagates automatically.
485 $holder = new ScaffoldingConcreteHolder();
486 $holder->getPens()[0]->write(); // list<Pen> inherited from interface
487
488 // Parent class declares @return list<Pen>, child overrides with `: array`.
489 $child = new ScaffoldingChildHolder();
490 $child->getPens()[0]->write(); // list<Pen> inherited from parent
491
492 // When the child writes its own @return, it wins over the parent.
493 $cat = new ScaffoldingCatStore();
494 $cat->getAnimals()[0]->label(); // list<Pencil> from child's own docblock
495
496 // Parameter types propagate by position (child may rename params).
497 $box = new ScaffoldingPenBox();
498 $box->accept([new Pen()]); // @param list<Pen> inherited from interface
499
500 // Grandparent @return flows through the entire chain.
501 $deep = new ScaffoldingDeepChild();
502 $deep->getPens()[0]->write(); // list<Pen> from grandparent
503 }
504}
505
506

Callers

nothing calls this directly

Calls 5

writeMethod · 0.80
getPensMethod · 0.45
labelMethod · 0.45
getAnimalsMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected