1--TEST-- 2Test nullsafe property in special functions 3--FILE-- 4<?php 5 6function dump_error(callable $callable) { 7 try { 8 var_dump($callable()); 9 } catch (Throwable $e) { 10 var_dump($e->getMessage()); 11 } 12} 13 14function foo() {} 15 16$foo = null; 17dump_error(fn() => strlen($foo?->foo())); 18dump_error(fn() => is_null($foo?->foo())); 19dump_error(fn() => is_bool($foo?->foo())); 20dump_error(fn() => is_int($foo?->foo())); 21dump_error(fn() => is_scalar($foo?->foo())); 22dump_error(fn() => boolval($foo?->foo())); 23dump_error(fn() => defined($foo?->foo())); 24dump_error(fn() => chr($foo?->foo())); 25dump_error(fn() => ord($foo?->foo())); 26dump_error(fn() => call_user_func_array($foo?->foo(), [])); 27dump_error(fn() => call_user_func_array('foo', $foo?->foo())); 28dump_error(fn() => get_class($foo?->foo())); 29dump_error(fn() => get_called_class($foo?->foo())); 30dump_error(fn() => gettype($foo?->foo())); 31dump_error(fn() => func_num_args($foo?->foo())); 32dump_error(fn() => func_get_args($foo?->foo())); 33dump_error(fn() => array_slice($foo?->foo(), 0)); 34dump_error(fn() => array_slice(['foo'], $foo?->foo())); 35dump_error(fn() => array_slice(['foo'], 0, $foo?->foo())); 36dump_error(fn() => array_key_exists($foo?->foo(), [])); 37dump_error(fn() => array_key_exists('foo', $foo?->foo())); 38 39?> 40--EXPECTF-- 41Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d 42int(0) 43bool(true) 44bool(false) 45bool(false) 46bool(false) 47bool(false) 48 49Deprecated: defined(): Passing null to parameter #1 ($constant_name) of type string is deprecated in %s on line %d 50bool(false) 51 52Deprecated: chr(): Passing null to parameter #1 ($codepoint) of type int is deprecated in %s on line %d 53string(1) "%s" 54 55Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in %s on line %d 56int(0) 57string(98) "call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given" 58string(77) "call_user_func_array(): Argument #2 ($args) must be of type array, null given" 59string(69) "get_class(): Argument #1 ($object) must be of type object, null given" 60string(55) "get_called_class() expects exactly 0 arguments, 1 given" 61string(4) "NULL" 62string(52) "func_num_args() expects exactly 0 arguments, 1 given" 63string(52) "func_get_args() expects exactly 0 arguments, 1 given" 64string(69) "array_slice(): Argument #1 ($array) must be of type array, null given" 65 66Deprecated: array_slice(): Passing null to parameter #2 ($offset) of type int is deprecated in %s on line %d 67array(1) { 68 [0]=> 69 string(3) "foo" 70} 71array(1) { 72 [0]=> 73 string(3) "foo" 74} 75bool(false) 76string(74) "array_key_exists(): Argument #2 ($array) must be of type array, null given" 77