1515
1616/**
1717 * @author Nicolas Grekas <[email protected] > 18+ * @author Jan Schädlich <[email protected] > 1819 */
1920class IntlCaster
2021{
@@ -25,14 +26,7 @@ public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub
2526 Caster::PREFIX_VIRTUAL .'pattern ' => $ c ->getPattern (),
2627 );
2728
28- if ($ errorCode = $ c ->getErrorCode ()) {
29- $ a += array (
30- Caster::PREFIX_VIRTUAL .'error_code ' => $ errorCode ,
31- Caster::PREFIX_VIRTUAL .'error_message ' => $ c ->getErrorMessage (),
32- );
33- }
34-
35- return $ a ;
29+ return self ::dumpError ($ c , $ a );
3630 }
3731
3832 public static function castNumberFormatter (\NumberFormatter $ c , array $ a , Stub $ stub , $ isNested , $ filter = 0 )
@@ -45,7 +39,7 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
4539 if ($ filter & Caster::EXCLUDE_VERBOSE ) {
4640 $ stub ->cut += 3 ;
4741
48- return $ a ;
42+ return self :: dumpError ( $ c , $ a ) ;
4943 }
5044
5145 $ a += array (
@@ -109,6 +103,11 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
109103 ),
110104 );
111105
106+ return self ::dumpError ($ c , $ a );
107+ }
108+
109+ private static function dumpError ($ c , array $ a ): array
110+ {
112111 if ($ errorCode = $ c ->getErrorCode ()) {
113112 $ a += array (
114113 Caster::PREFIX_VIRTUAL .'error_code ' => $ errorCode ,
0 commit comments