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

Method demo

examples/demo.php:973–998  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

971class CollectionForeachDemo
972{
973 public function demo(): void
974 {
975 $src = new ScaffoldingCollectionForeach();
976
977 // From method return type
978 foreach ($src->allPens() as $pen) {
979 $pen->write(); // via method return type → collection generics
980 }
981
982 // From new instance
983 $items = new PenCollection();
984 foreach ($items as $item) {
985 $item->color(); // resolves to Pen via @extends generics
986 }
987
988 // From property type
989 foreach ($src->pens as $pen) {
990 $pen->color(); // via property type → collection generics
991 }
992
993 // From variable
994 $collection = $src->allPens();
995 foreach ($collection as $pen) {
996 $pen->write(); // via variable assignment scanning
997 }
998 }
999}
1000
1001

Callers

nothing calls this directly

Calls 3

writeMethod · 0.80
colorMethod · 0.80
allPensMethod · 0.45

Tested by

no test coverage detected