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

Method demo

examples/demo.php:395–411  ·  view source on GitHub ↗

* @param Rock|Banana $item * @param list $rocks */

($item, array $rocks)

Source from the content-addressed store, hash-verified

393 * @param list<Rock> $rocks
394 */
395 public function demo($item, array $rocks): void
396 {
397 if (in_array($item, $rocks, true)) {
398 $item->crush(); // narrowed to Rock
399 // MUST NOT appear: peel() (Banana only)
400 } else {
401 $item->peel(); // excluded Rock → Banana
402 // MUST NOT appear: crush() (Rock only)
403 }
404
405 // Guard clause with in_array
406 $specimen = pickRockOrBanana(); // Rock|Banana
407 if (!in_array($specimen, $rocks, true)) {
408 return;
409 }
410 $specimen->crush(); // narrowed to Rock after guard
411 }
412}
413
414

Callers

nothing calls this directly

Calls 3

pickRockOrBananaFunction · 0.85
crushMethod · 0.80
peelMethod · 0.80

Tested by

no test coverage detected