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

Method demo

examples/demo.php:731–746  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

729class ForeachArrayAccessDemo
730{
731 public function demo(): void
732 {
733 /** @var list<Pen> $members */
734 $members = getUnknownValue();
735 foreach ($members as $member) {
736 $member->write(); // element type from list<Pen>
737 }
738 $members[0]->color(); // array access element type
739
740 /** @var array<int, Pen> */
741 $annotated = []; // @var without variable name
742 $annotated[0]->write(); // type from next-line annotation
743
744 $inferred = [new Pen(), new Marker()];
745 $inferred[0]->write(); // element type inferred from literal
746 }
747}
748
749// ── Foreach By-Reference ────────────────────────────────────────────────────

Callers

nothing calls this directly

Calls 3

getUnknownValueFunction · 0.85
writeMethod · 0.80
colorMethod · 0.80

Tested by

no test coverage detected