1--TEST-- 2numfmt creation failures 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5--FILE-- 6<?php 7 8function err($fmt) { 9 if(!$fmt) { 10 echo var_export(intl_get_error_message(), true)."\n"; 11 } 12} 13 14function print_exception($e) { 15 echo "\n" . get_class($e) . ": " . $e->getMessage() 16 . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; 17} 18 19function crt($t, $l, $s) { 20 switch(true) { 21 case $t == "O": 22 try { 23 return new NumberFormatter($l, $s); 24 } catch (Throwable $e) { 25 print_exception($e); 26 return null; 27 } 28 break; 29 case $t == "C": 30 return NumberFormatter::create($l, $s); 31 break; 32 case $t == "P": 33 return numfmt_create($l, $s); 34 break; 35 } 36} 37 38$args = array( 39 array(null, null), 40 array("whatever", 1234567), 41 array(array(), array()), 42 array("en", -1), 43 array("en_US", NumberFormatter::PATTERN_RULEBASED), 44); 45 46try { 47 $fmt = new NumberFormatter(); 48} catch (TypeError $e) { 49 print_exception($e); 50 $fmt = null; 51} 52err($fmt); 53$fmt = numfmt_create(); 54err($fmt); 55$fmt = NumberFormatter::create(); 56err($fmt); 57 58foreach($args as $arg) { 59 $fmt = crt("O", $arg[0], $arg[1]); 60 err($fmt); 61 $fmt = crt("C", $arg[0], $arg[1]); 62 err($fmt); 63 $fmt = crt("P", $arg[0], $arg[1]); 64 err($fmt); 65} 66 67?> 68--EXPECTF-- 69TypeError: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d 70'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 71 72Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d 73'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 74 75Warning: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d 76'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 77 78IntlException: Constructor failed in %sformatter_fail.php on line %d 79'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 80'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 81'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 82 83TypeError: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d 84'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 85 86Warning: NumberFormatter::create() expects parameter 1 to be string, array given in %s on line %d 87'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 88 89Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d 90'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 91 92IntlException: Constructor failed in %sformatter_fail.php on line %d 93'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 94'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 95'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 96 97IntlException: Constructor failed in %sformatter_fail.php on line %d 98'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' 99'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' 100'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' 101