Skip to content

Instantly share code, notes, and snippets.

@deshack
Created May 27, 2016 14:30
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 deshack/0a53d8048d4f26ea9ca3e9304df529df to your computer and use it in GitHub Desktop.
Save deshack/0a53d8048d4f26ea9ca3e9304df529df to your computer and use it in GitHub Desktop.
PHP7 Strict Type Hinting - see https://gist.github.com/deshack/e63358a8726b7c3e0ba13563e4f9864c for a full collection of examples about PHP5/PHP7 type hinting
<?php
// Force Type Hinting to do a strict type check (the same as ===).
declare(strict_types=1);
function setBool(bool $bool) {
var_dump($bool);
}
setBool('foo');
// PHP Fatal error: Uncaught TypeError: Argument 1 passed to setBool() must be of the type boolean, string given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment