()
| 479 | class 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 |
nothing calls this directly
no test coverage detected