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

Method demo

examples/demo.php:273–291  ·  view source on GitHub ↗
(ScaffoldingMotor $m)

Source from the content-addressed store, hash-verified

271 public function sport(): void {}
272
273 public function demo(ScaffoldingMotor $m): void
274 {
275 // instanceof self — narrows to InstanceofSelfDemo
276 assert($m instanceof self);
277 $m->cruise(); // inherited from ScaffoldingSedan
278 $m->sport(); // own method via self narrowing
279
280 // instanceof static — narrows to InstanceofSelfDemo
281 $x = getUnknownValue();
282 if ($x instanceof static) {
283 $x->sport(); // narrowed to static (this class)
284 }
285
286 // instanceof parent — narrows to ScaffoldingSedan
287 $y = getUnknownValue();
288 if ($y instanceof parent) {
289 $y->cruise(); // narrowed to parent (ScaffoldingSedan)
290 }
291 }
292}
293
294

Callers

nothing calls this directly

Calls 3

getUnknownValueFunction · 0.85
cruiseMethod · 0.80
sportMethod · 0.80

Tested by

no test coverage detected