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 60Fatal error: Uncaught TypeError: Test::f1(): Argument #1 ($ar) must be of type array, int given, called in %s on line %d and defined in %s:%d 61Stack trace: 62#0 %s(%d): Test::f1(1) 63#1 {main} 64 thrown in %s on line %d 65