1--TEST-- 2ZE2 class type hinting with arrays 3--FILE-- 4<?php 5 6class Test 7{ 8 static function f1(array $ar) 9 { 10 echo __METHOD__ . "()\n"; 11 var_dump($ar); 12 } 13 14 static function f2(array $ar = NULL) 15 { 16 echo __METHOD__ . "()\n"; 17 var_dump($ar); 18 } 19 20 static function f3(array $ar = array()) 21 { 22 echo __METHOD__ . "()\n"; 23 var_dump($ar); 24 } 25 26 static function f4(array $ar = array(25)) 27 { 28 echo __METHOD__ . "()\n"; 29 var_dump($ar); 30 } 31} 32 33Test::f1(array(42)); 34Test::f2(NULL); 35Test::f2(); 36Test::f3(); 37Test::f4(); 38Test::f1(1); 39 40?> 41--EXPECTF-- 42Test::f1() 43array(1) { 44 [0]=> 45 int(42) 46} 47Test::f2() 48NULL 49Test::f2() 50NULL 51Test::f3() 52array(0) { 53} 54Test::f4() 55array(1) { 56 [0]=> 57 int(25) 58} 59 60Catchable fatal error: Argument 1 passed to Test::f1() must be an array, integer given, called in %stype_hinting_003.php on line %d and defined in %stype_hinting_003.php on line %d 61