1--TEST-- 2ReflectionFunction constructor errors 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8 9try { 10 $a = new ReflectionFunction(array(1, 2, 3)); 11 echo "exception not thrown.".PHP_EOL; 12} catch (TypeError $re) { 13 echo "Ok - ".$re->getMessage().PHP_EOL; 14} 15try { 16 $a = new ReflectionFunction('nonExistentFunction'); 17} catch (ReflectionException $e) { 18 echo $e->getMessage().PHP_EOL; 19} 20try { 21 $a = new ReflectionFunction(); 22} catch (TypeError $re) { 23 echo "Ok - ".$re->getMessage().PHP_EOL; 24} 25try { 26 $a = new ReflectionFunction(1, 2); 27} catch (TypeError $re) { 28 echo "Ok - ".$re->getMessage().PHP_EOL; 29} 30try { 31 $a = new ReflectionFunction([]); 32} catch (TypeError $re) { 33 echo "Ok - ".$re->getMessage().PHP_EOL; 34} 35 36?> 37--EXPECT-- 38Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given 39Function nonExistentFunction() does not exist 40Ok - ReflectionFunction::__construct() expects exactly 1 argument, 0 given 41Ok - ReflectionFunction::__construct() expects exactly 1 argument, 2 given 42Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given 43