1--TEST-- 2Test array_column(): Index argument with various types in weak type mode 3--FILE-- 4<?php 5echo "\n-- Testing array_column() column key parameter should be a string or an integer (testing bool) --\n"; 6try { 7 var_dump(array_column([['php7', 'foo'], ['php8', 'bar']], false)); 8} catch (\TypeError $e) { 9 echo $e->getMessage() . "\n"; 10} 11try { 12 var_dump(array_column([['php7', 'foo'], ['php8', 'bar']], true)); 13} catch (\TypeError $e) { 14 echo $e->getMessage() . "\n"; 15} 16 17echo "\n-- Testing array_column() column key parameter should be a string or integer (testing array) --\n"; 18try { 19 var_dump(array_column([['php7', 'foo'], ['php8', 'bar']], array())); 20} catch (\TypeError $e) { 21 echo $e->getMessage() . "\n"; 22} 23 24echo "\n-- Testing array_column() index key parameter should be a string or an integer (testing bool) --\n"; 25try { 26 var_dump(array_column([['php' => 7, 'foo'], ['php' => 8, 'bar']], 'php', false)); 27} catch (\TypeError $e) { 28 echo $e->getMessage() . "\n"; 29} 30try { 31 var_dump(array_column([['php' => 7, 'foo'], ['php' => 8, 'bar']], 'php', true)); 32} catch (\TypeError $e) { 33 echo $e->getMessage() . "\n"; 34} 35 36echo "\n-- Testing array_column() index key parameter should be a string or integer (testing array) --\n"; 37try { 38 var_dump(array_column([['php' => 7, 'foo'], ['php' => 8, 'bar']], 'php', array())); 39} catch (\TypeError $e) { 40 echo $e->getMessage() . "\n"; 41} 42 43?> 44 45DONE 46--EXPECT-- 47-- Testing array_column() column key parameter should be a string or an integer (testing bool) -- 48array(2) { 49 [0]=> 50 string(4) "php7" 51 [1]=> 52 string(4) "php8" 53} 54array(2) { 55 [0]=> 56 string(3) "foo" 57 [1]=> 58 string(3) "bar" 59} 60 61-- Testing array_column() column key parameter should be a string or integer (testing array) -- 62array_column(): Argument #2 ($column_key) must be of type string|int|null, array given 63 64-- Testing array_column() index key parameter should be a string or an integer (testing bool) -- 65array(2) { 66 ["foo"]=> 67 int(7) 68 ["bar"]=> 69 int(8) 70} 71array(2) { 72 [0]=> 73 int(7) 74 [1]=> 75 int(8) 76} 77 78-- Testing array_column() index key parameter should be a string or integer (testing array) -- 79array_column(): Argument #3 ($index_key) must be of type string|int|null, array given 80 81DONE 82