PHP8

// php 8 Union type
class Number {
  public function __construct(
    private int|float $number
  ) {}
}

new Number('NaN'); // TypeError

Wandering Whale