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

Method demo

examples/demo.php:93–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91class ChainingDemo
92{
93 public function demo(): void
94 {
95 $studio = new ScaffoldingChainingDemo();
96
97 // Fluent method chains — MUST NOT appear: calibrate() (protected)
98 $studio->brush->setSize('large')->setStyle('pointed')->stroke();
99
100 // Return type chains
101 $studio->brush->getCanvas()->title();
102
103 // Variable → method chain
104 $canvas = $studio->brush->getCanvas();
105 $canvas->getBrush()->stroke();
106
107 // Deep property chain
108 $studio->canvas->easel->material;
109 $studio->canvas->easel->height();
110
111 // Null-safe chaining
112 $maybe = Brush::find(1);
113 $maybe?->getCanvas()?->title();
114
115 // Multi-line method chains
116 $studio->brush->setSize('large')
117 ->setStyle('pointed')
118 ->stroke();
119
120 // Variable assigned from chain
121 $directBrush = $studio->brush->getCanvas()->getBrush();
122 $directBrush->stroke();
123
124 // (new Class())->method()
125 $fromNew = (new Canvas())->getBrush();
126 $fromNew->stroke();
127
128 // Intermediate variable from property access
129 $easel = (new Canvas())->easel;
130 $easel->material;
131 }
132}
133
134

Callers

nothing calls this directly

Calls 8

strokeMethod · 0.80
setStyleMethod · 0.80
setSizeMethod · 0.80
titleMethod · 0.80
getCanvasMethod · 0.80
getBrushMethod · 0.80
heightMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected