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

Method demo

examples/demo.php:2303–2327  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2301class FirstClassCallableDemo
2302{
2303 public function demo(): void
2304 {
2305 $src = new ScaffoldingFirstClassCallable();
2306
2307 $fun = makePen(...);
2308 $fun()->write(); // function reference → Closure returning Pen
2309
2310 $orderFn = $src->dispatch(...);
2311 $orderFn()->write(); // instance method → Closure returning Pen
2312
2313 $finder = Pen::make(...);
2314 $finder()->color(); // static method → Closure returning Pen
2315
2316 $make = makePen(...);
2317 $pen = $make();
2318 $pen->color(); // assigned result from callable invocation
2319
2320 // Immediate invocation: method(...)() returns the method's return type
2321 makePen(...)()->write(); // function first-class callable invoked immediately
2322 Pen::make(...)()->color(); // static method first-class callable invoked immediately
2323 $src->dispatch(...)()->write(); // instance method first-class callable invoked immediately
2324
2325 $immediate = Pen::make(...)();
2326 $immediate->color(); // assigned result from immediate static callable invocation
2327 }
2328}
2329
2330

Callers

nothing calls this directly

Calls 5

makePenFunction · 0.85
writeMethod · 0.80
dispatchMethod · 0.80
colorMethod · 0.80
makeMethod · 0.45

Tested by

no test coverage detected