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

Method demo

examples/demo.php:1285–1308  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1283class ShapeMethodDemo
1284{
1285 public function demo(): void
1286 {
1287 $data = $this->getToolKit();
1288 $data['pen']->write(); // Pen
1289 $data['pencil']->sketch(); // Pencil
1290
1291 // Nested annotated shape
1292 /** @var array{meta: array{page: int, total: int}, items: list<Pen>} $response */
1293 $response = getUnknownValue();
1294 $response['meta']['page']; // nested shape key
1295 $response['items'][0]->write(); // list element type
1296
1297 // Nested keys inferred from literal — no annotation needed
1298 $config = ['db' => ['host' => 'localhost', 'port' => 3306], 'debug' => true];
1299 $config['db']['host']; // Try: delete 'host' and trigger completion
1300
1301 // Object shapes
1302 $profile = $this->getProfile();
1303 $profile->name; // Ctrl+Click → jumps to `name:` in @return docblock
1304
1305 $result = $this->getResult();
1306 $result->tool->write(); // Ctrl+Click `tool` → jumps to `tool:` in @return docblock
1307 $result->meta->page; // Ctrl+Click `meta` → jumps to `meta:` in @return docblock
1308 }
1309
1310 /** @return array{pen: Pen, pencil: Pencil, active: bool} */
1311 public function getToolKit(): array { return []; }

Callers

nothing calls this directly

Calls 6

getToolKitMethod · 0.95
getProfileMethod · 0.95
getResultMethod · 0.95
getUnknownValueFunction · 0.85
writeMethod · 0.80
sketchMethod · 0.80

Tested by

no test coverage detected