1--TEST-- 2msgfmt creation failures icu <= 4.2 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?> 6--FILE-- 7<?php 8 9function err($fmt) { 10 if(!$fmt) { 11 echo var_export(intl_get_error_message(), true)."\n"; 12 } 13} 14 15function print_exception($e) { 16 echo "\n" . get_class($e) . ": " . $e->getMessage() 17 . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; 18} 19 20function crt($t, $l, $s) { 21 switch(true) { 22 case $t == "O": 23 try { 24 return new MessageFormatter($l, $s); 25 } catch (Throwable $e) { 26 print_exception($e); 27 return null; 28 } 29 break; 30 case $t == "C": 31 return MessageFormatter::create($l, $s); 32 break; 33 case $t == "P": 34 return msgfmt_create($l, $s); 35 break; 36 } 37} 38 39$args = array( 40 array(null, null), 41 array("whatever", "{0,whatever}"), 42 array(array(), array()), 43 array("en", "{0,choice}"), 44 array("fr", "{0,"), 45 array("en_US", "\xD0"), 46); 47 48try { 49 $fmt = new MessageFormatter(); 50} catch (TypeError $e) { 51 print_exception($e); 52 $fmt = null; 53} 54err($fmt); 55$fmt = msgfmt_create(); 56err($fmt); 57$fmt = MessageFormatter::create(); 58err($fmt); 59try { 60 $fmt = new MessageFormatter('en'); 61} catch (TypeError $e) { 62 print_exception($e); 63 $fmt = null; 64} 65err($fmt); 66$fmt = msgfmt_create('en'); 67err($fmt); 68$fmt = MessageFormatter::create('en'); 69err($fmt); 70 71foreach($args as $arg) { 72 $fmt = crt("O", $arg[0], $arg[1]); 73 err($fmt); 74 $fmt = crt("C", $arg[0], $arg[1]); 75 err($fmt); 76 $fmt = crt("P", $arg[0], $arg[1]); 77 err($fmt); 78} 79 80?> 81--EXPECTF-- 82TypeError: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d 83'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 84 85Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d 86'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 87 88Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d 89'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 90 91TypeError: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d 92'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 93 94Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d 95'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 96 97Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d 98'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 99 100IntlException: Constructor failed in %smsgfmt_fail2.php on line %d 101'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 102'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 103'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 104 105IntlException: Constructor failed in %smsgfmt_fail2.php on line %d 106'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 107'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 108'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 109 110TypeError: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d 111'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 112 113Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d 114'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 115 116Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d 117'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' 118 119IntlException: Constructor failed in %smsgfmt_fail2.php on line %d 120'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 121'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 122'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 123 124IntlException: Constructor failed in %smsgfmt_fail2.php on line %d 125'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' 126'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' 127'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' 128 129IntlException: Constructor failed in %smsgfmt_fail2.php on line %d 130'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' 131'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' 132'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' 133