I’m just playing around here, my code:
<?php
function test(string $str, array $arr = array()) {
echo $str;
}
test('something');
Which results in:
Catchable fatal error: Argument 1 passed to test() must be an instance of string, string given
I’m curious why I can precede $arr with array without any problems, but I cannot precede $str with string?
String isn’t a supported type hint as of yet
Edit: see http://php.net/manual/en/language.types.type-juggling.php
and
http://php.net/manual/en/language.oop5.typehinting.php