()
| 464 | public function getPens(): \ArrayIterator { return new \ArrayIterator([new Pen()]); } |
| 465 | |
| 466 | public function demo(): void |
| 467 | { |
| 468 | $pen = $this->getPens()->current(); |
| 469 | $pen->write(); // ArrayIterator<int, Pen> → current() returns Pen |
| 470 | |
| 471 | // Direct chain also works: |
| 472 | $this->getPens()->current()->write(); // same resolution through the chain |
| 473 | } |
| 474 | } |
| 475 | |
| 476 |