Last active
May 27, 2016 14:19
-
-
Save deshack/17e81148b28fba26f3301b2bb519e08e to your computer and use it in GitHub Desktop.
PHP5 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 | |
function setOptions(array $options) { | |
var_dump($options); | |
} | |
setOptions(array()); | |
// array(0) { | |
// } | |
setOptions('foo'); | |
// PHP Warning: Uncaught TypeError: Argument 1 passed to setOptions() must be of the type array, string given | |
function setValue(string $value) { | |
var_dump($value); | |
} | |
setValue('foo'); | |
// PHP Catchable fatal error: Argument 1 passed to setValue() must be an instance of string, string given |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment