Positive instanceof + early return on a mixed parameter. */
(mixed $value)
| 372 | |
| 373 | /** Positive instanceof + early return on a mixed parameter. */ |
| 374 | public function mixedGuard(mixed $value): void |
| 375 | { |
| 376 | if ($value instanceof Banana) { |
| 377 | return; // $value is Banana → exit |
| 378 | } |
| 379 | // After the guard, $value is NOT Banana. |
| 380 | if ($value instanceof Rock) { |
| 381 | $value->crush(); // narrowed to Rock (not Banana) |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
| 386 |