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

Method demo

examples/demo.php:2837–2855  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2835class PassByReferenceDemo
2836{
2837 public function demo(): void
2838 {
2839 // When a function takes a typed &$var parameter, the variable
2840 // acquires that type after the call.
2841 initPen($pen);
2842 $pen->write(); // $pen is now Pen
2843
2844 // Static method calls with by-ref parameters:
2845 PenFactory::create($staticPen);
2846 $staticPen->write(); // $staticPen is now Pen
2847
2848 // Constructor calls with by-ref parameters:
2849 new PenBuilder($ctorPen);
2850 $ctorPen->write(); // $ctorPen is now Pen
2851
2852 // Instance method calls ($this->method) with by-ref parameters:
2853 $this->init($thisPen);
2854 $thisPen->write(); // $thisPen is now Pen
2855 }
2856
2857 private function init(?Pen &$pen): void
2858 {

Callers

nothing calls this directly

Calls 4

initMethod · 0.95
initPenFunction · 0.85
writeMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected