Skip to content

Instantly share code, notes, and snippets.

@deshack
Last active May 27, 2016 14: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 deshack/17e81148b28fba26f3301b2bb519e08e to your computer and use it in GitHub Desktop.
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
<?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