Created
May 27, 2016 14:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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