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-- 42Deprecated: Test::f2(): Implicitly marking parameter $ar as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d 43Test::f1() 44array(1) { 45 [0]=> 46 int(42) 47} 48Test::f2() 49NULL 50Test::f2() 51NULL 52Test::f3() 53array(0) { 54} 55Test::f4() 56array(1) { 57 [0]=> 58 int(25) 59} 60 61Fatal 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 62Stack trace: 63#0 %s(%d): Test::f1(1) 64#1 {main} 65 thrown in %s on line %d 66