(ScaffoldingMotor $m)
| 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 |
nothing calls this directly
no test coverage detected