Skip to content

Instantly share code, notes, and snippets.

@lechidung
Last active November 29, 2020 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lechidung/c3bdb355b4134d824c100c90fe11a17a to your computer and use it in GitHub Desktop.
Save lechidung/c3bdb355b4134d824c100c90fe11a17a to your computer and use it in GitHub Desktop.
PHP 8
/*** PHP 7 ***/
class Number {
/** @var int|float */
private $number;
/**
* @param float|int $number
*/
public function __construct($number) {
$this->number = $number;
}
}
new Number('NaN'); // Ok
/*** PHP 8 ***/
class Number {
public function __construct(
private int|float $number
) {}
}
new Number('NaN'); // TypeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment