Skip to content

Commit a4b9f67

Browse files
committed
Add stubs for NumberFormatter
1 parent 3796597 commit a4b9f67

File tree

4 files changed

+262
-144
lines changed

4 files changed

+262
-144
lines changed

ext/intl/formatter/formatter.stub.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
class NumberFormatter
4+
{
5+
public function __construct(string $locale, int $style, string $pattern = "") {}
6+
7+
/** @return NumberFormatter|null */
8+
public static function create(string $locale, int $style, string $pattern = "") {}
9+
10+
/** @return string|false */
11+
public function format($value, int $type = NumberFormatter::TYPE_DEFAULT) {}
12+
13+
/** @return int|float|false */
14+
public function parse(string $value, int $type = NumberFormatter::TYPE_DOUBLE, &$position = null) {}
15+
16+
/** @return string|false */
17+
public function formatCurrency(float $value, string $currency) {}
18+
19+
/** @return float|false */
20+
public function parseCurrency(string $value, &$currency, &$position = null) {}
21+
22+
/**
23+
* @param int|float $value
24+
* @return bool
25+
*/
26+
public function setAttribute(int $attr, $value) {}
27+
28+
/** @return int|float|false */
29+
public function getAttribute(int $attr) {}
30+
31+
/** @return bool */
32+
public function setTextAttribute(int $attr, string $value) {}
33+
34+
/** @return string|false */
35+
public function getTextAttribute(int $attr) {}
36+
37+
/** @return bool */
38+
public function setSymbol(int $attr, string $value) {}
39+
40+
/** @return string|false */
41+
public function getSymbol(int $attr) {}
42+
43+
/** @return bool */
44+
public function setPattern(string $pattern) {}
45+
46+
/** @return string|false */
47+
public function getPattern() {}
48+
49+
/** @return string|false */
50+
public function getLocale(int $type = ULOC_ACTUAL_LOCALE) {}
51+
52+
/** @return int */
53+
public function getErrorCode() {}
54+
55+
/** @return string */
56+
public function getErrorMessage() {}
57+
}
58+
59+
function numfmt_create(string $locale, int $style, string $pattern = ""): NumberFormatter|false {}
60+
61+
function numfmt_format(NumberFormatter $fmt, $value, int $type = NumberFormatter::TYPE_DEFAULT): string|false {}
62+
63+
function numfmt_parse(NumberFormatter $fmt, string $value, int $type = NumberFormatter::TYPE_DOUBLE, &$position = null): int|float|false {}
64+
65+
function numfmt_format_currency(NumberFormatter $fmt, float $value, string $currency): string|false {}
66+
67+
function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency, &$position = null): float|false {}
68+
69+
/** @param int|float $value */
70+
function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {}
71+
72+
function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|double|false {}
73+
74+
function numfmt_set_text_attribute(NumberFormatter $fmt, int $attr, string $value): bool {}
75+
76+
function numfmt_get_text_attribute(NumberFormatter $fmt, int $attr): string|false {}
77+
78+
function numfmt_set_symbol(NumberFormatter $fmt, int $attr, string $value): bool {}
79+
80+
function numfmt_get_symbol(NumberFormatter $fmt, int $attr): string|false {}
81+
82+
function numfmt_set_pattern(NumberFormatter $fmt, string $pattern): bool {}
83+
84+
function numfmt_get_pattern(NumberFormatter $fmt): string|false {}
85+
86+
function numfmt_get_locale(NumberFormatter $fmt, int $type = ULOC_ACTUAL_LOCALE): string|false {}
87+
88+
function numfmt_get_error_code(NumberFormatter $fmt): int {}
89+
90+
function numfmt_get_error_message(NumberFormatter $fmt): string {}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2)
4+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
5+
ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
6+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
7+
ZEND_END_ARG_INFO()
8+
9+
#define arginfo_class_NumberFormatter_create arginfo_class_NumberFormatter___construct
10+
11+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_format, 0, 0, 1)
12+
ZEND_ARG_INFO(0, value)
13+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
14+
ZEND_END_ARG_INFO()
15+
16+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_parse, 0, 0, 1)
17+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
18+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
19+
ZEND_ARG_INFO(1, position)
20+
ZEND_END_ARG_INFO()
21+
22+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_formatCurrency, 0, 0, 2)
23+
ZEND_ARG_TYPE_INFO(0, value, IS_DOUBLE, 0)
24+
ZEND_ARG_TYPE_INFO(0, currency, IS_STRING, 0)
25+
ZEND_END_ARG_INFO()
26+
27+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_parseCurrency, 0, 0, 2)
28+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
29+
ZEND_ARG_INFO(1, currency)
30+
ZEND_ARG_INFO(1, position)
31+
ZEND_END_ARG_INFO()
32+
33+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_setAttribute, 0, 0, 2)
34+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
35+
ZEND_ARG_INFO(0, value)
36+
ZEND_END_ARG_INFO()
37+
38+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_getAttribute, 0, 0, 1)
39+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
40+
ZEND_END_ARG_INFO()
41+
42+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_setTextAttribute, 0, 0, 2)
43+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
44+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
45+
ZEND_END_ARG_INFO()
46+
47+
#define arginfo_class_NumberFormatter_getTextAttribute arginfo_class_NumberFormatter_getAttribute
48+
49+
#define arginfo_class_NumberFormatter_setSymbol arginfo_class_NumberFormatter_setTextAttribute
50+
51+
#define arginfo_class_NumberFormatter_getSymbol arginfo_class_NumberFormatter_getAttribute
52+
53+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_setPattern, 0, 0, 1)
54+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
55+
ZEND_END_ARG_INFO()
56+
57+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_getPattern, 0, 0, 0)
58+
ZEND_END_ARG_INFO()
59+
60+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_getLocale, 0, 0, 0)
61+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
62+
ZEND_END_ARG_INFO()
63+
64+
#define arginfo_class_NumberFormatter_getErrorCode arginfo_class_NumberFormatter_getPattern
65+
66+
#define arginfo_class_NumberFormatter_getErrorMessage arginfo_class_NumberFormatter_getPattern
67+
68+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_numfmt_create, 0, 2, NumberFormatter, MAY_BE_FALSE)
69+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
70+
ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
71+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
72+
ZEND_END_ARG_INFO()
73+
74+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
75+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
76+
ZEND_ARG_INFO(0, value)
77+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
78+
ZEND_END_ARG_INFO()
79+
80+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_parse, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE)
81+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
82+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
83+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
84+
ZEND_ARG_INFO(1, position)
85+
ZEND_END_ARG_INFO()
86+
87+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_format_currency, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
88+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
89+
ZEND_ARG_TYPE_INFO(0, value, IS_DOUBLE, 0)
90+
ZEND_ARG_TYPE_INFO(0, currency, IS_STRING, 0)
91+
ZEND_END_ARG_INFO()
92+
93+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_parse_currency, 0, 3, MAY_BE_DOUBLE|MAY_BE_FALSE)
94+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
95+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
96+
ZEND_ARG_INFO(1, currency)
97+
ZEND_ARG_INFO(1, position)
98+
ZEND_END_ARG_INFO()
99+
100+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_attribute, 0, 3, _IS_BOOL, 0)
101+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
102+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
103+
ZEND_ARG_INFO(0, value)
104+
ZEND_END_ARG_INFO()
105+
106+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_numfmt_get_attribute, 0, 2, double, MAY_BE_LONG|MAY_BE_FALSE)
107+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
108+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
109+
ZEND_END_ARG_INFO()
110+
111+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_text_attribute, 0, 3, _IS_BOOL, 0)
112+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
113+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
114+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
115+
ZEND_END_ARG_INFO()
116+
117+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_get_text_attribute, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
118+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
119+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
120+
ZEND_END_ARG_INFO()
121+
122+
#define arginfo_numfmt_set_symbol arginfo_numfmt_set_text_attribute
123+
124+
#define arginfo_numfmt_get_symbol arginfo_numfmt_get_text_attribute
125+
126+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_pattern, 0, 2, _IS_BOOL, 0)
127+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
128+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
129+
ZEND_END_ARG_INFO()
130+
131+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_get_pattern, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
132+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
133+
ZEND_END_ARG_INFO()
134+
135+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
136+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
137+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
138+
ZEND_END_ARG_INFO()
139+
140+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_get_error_code, 0, 1, IS_LONG, 0)
141+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
142+
ZEND_END_ARG_INFO()
143+
144+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_get_error_message, 0, 1, IS_STRING, 0)
145+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
146+
ZEND_END_ARG_INFO()

ext/intl/formatter/formatter_class.c

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "formatter_parse.h"
2222
#include "formatter_main.h"
2323
#include "formatter_attr.h"
24+
#include "formatter_arginfo.h"
2425

2526
#include <zend_exceptions.h>
2627
#include "Zend/zend_interfaces.h"
@@ -91,82 +92,27 @@ zend_object *NumberFormatter_object_clone(zend_object *object)
9192
* 'NumberFormatter' class registration structures & functions
9293
*/
9394

94-
/* {{{ arginfo */
95-
ZEND_BEGIN_ARG_INFO_EX(number_parse_arginfo, 0, 0, 1)
96-
ZEND_ARG_INFO(0, string)
97-
ZEND_ARG_INFO(0, type)
98-
ZEND_ARG_INFO(1, position)
99-
ZEND_END_ARG_INFO()
100-
101-
ZEND_BEGIN_ARG_INFO_EX(number_parse_currency_arginfo, 0, 0, 2)
102-
ZEND_ARG_INFO(0, string)
103-
ZEND_ARG_INFO(1, currency)
104-
ZEND_ARG_INFO(1, position)
105-
ZEND_END_ARG_INFO()
106-
107-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_getattribute, 0, 0, 1)
108-
ZEND_ARG_INFO(0, attr)
109-
ZEND_END_ARG_INFO()
110-
111-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setattribute, 0, 0, 2)
112-
ZEND_ARG_INFO(0, attr)
113-
ZEND_ARG_INFO(0, value)
114-
ZEND_END_ARG_INFO()
115-
116-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setsymbol, 0, 0, 2)
117-
ZEND_ARG_INFO(0, attr)
118-
ZEND_ARG_INFO(0, symbol)
119-
ZEND_END_ARG_INFO()
120-
121-
ZEND_BEGIN_ARG_INFO(arginfo_numberformatter_getpattern, 0)
122-
ZEND_END_ARG_INFO()
123-
124-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setpattern, 0, 0, 1)
125-
ZEND_ARG_INFO(0, pattern)
126-
ZEND_END_ARG_INFO()
127-
128-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_getlocale, 0, 0, 0)
129-
ZEND_ARG_INFO(0, type)
130-
ZEND_END_ARG_INFO()
131-
132-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter___construct, 0, 0, 2)
133-
ZEND_ARG_INFO(0, locale)
134-
ZEND_ARG_INFO(0, style)
135-
ZEND_ARG_INFO(0, pattern)
136-
ZEND_END_ARG_INFO()
137-
138-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_formatcurrency, 0, 0, 2)
139-
ZEND_ARG_INFO(0, num)
140-
ZEND_ARG_INFO(0, currency)
141-
ZEND_END_ARG_INFO()
142-
143-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_format, 0, 0, 1)
144-
ZEND_ARG_INFO(0, num)
145-
ZEND_ARG_INFO(0, type)
146-
ZEND_END_ARG_INFO()
147-
/* }}} */
148-
14995
/* {{{ NumberFormatter_class_functions
15096
* Every 'NumberFormatter' class method has an entry in this table
15197
*/
15298
static const zend_function_entry NumberFormatter_class_functions[] = {
153-
PHP_ME( NumberFormatter, __construct, arginfo_numberformatter___construct, ZEND_ACC_PUBLIC )
154-
ZEND_FENTRY( create, ZEND_FN( numfmt_create ), arginfo_numberformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
155-
PHP_NAMED_FE( format, ZEND_FN( numfmt_format ), arginfo_numberformatter_format )
156-
PHP_NAMED_FE( parse, ZEND_FN( numfmt_parse ), number_parse_arginfo )
157-
PHP_NAMED_FE( formatCurrency, ZEND_FN( numfmt_format_currency ), arginfo_numberformatter_formatcurrency )
158-
PHP_NAMED_FE( parseCurrency, ZEND_FN( numfmt_parse_currency ), number_parse_currency_arginfo )
159-
PHP_NAMED_FE( setAttribute, ZEND_FN( numfmt_set_attribute ), arginfo_numberformatter_setattribute )
160-
PHP_NAMED_FE( getAttribute, ZEND_FN( numfmt_get_attribute ), arginfo_numberformatter_getattribute )
161-
PHP_NAMED_FE( setTextAttribute, ZEND_FN( numfmt_set_text_attribute ), arginfo_numberformatter_setattribute )
162-
PHP_NAMED_FE( getTextAttribute, ZEND_FN( numfmt_get_text_attribute ), arginfo_numberformatter_getattribute )
163-
PHP_NAMED_FE( setSymbol, ZEND_FN( numfmt_set_symbol ), arginfo_numberformatter_setsymbol )
164-
PHP_NAMED_FE( getSymbol, ZEND_FN( numfmt_get_symbol ), arginfo_numberformatter_getattribute )
165-
PHP_NAMED_FE( setPattern, ZEND_FN( numfmt_set_pattern ), arginfo_numberformatter_setpattern )
166-
PHP_NAMED_FE( getPattern, ZEND_FN( numfmt_get_pattern ), arginfo_numberformatter_getpattern )
167-
PHP_NAMED_FE( getLocale, ZEND_FN( numfmt_get_locale ), arginfo_numberformatter_getlocale )
168-
PHP_NAMED_FE( getErrorCode, ZEND_FN( numfmt_get_error_code ), arginfo_numberformatter_getpattern )
169-
PHP_NAMED_FE( getErrorMessage, ZEND_FN( numfmt_get_error_message ), arginfo_numberformatter_getpattern )
99+
PHP_ME( NumberFormatter, __construct, arginfo_class_NumberFormatter___construct, ZEND_ACC_PUBLIC )
100+
ZEND_FENTRY( create, ZEND_FN( numfmt_create ), arginfo_class_NumberFormatter_create, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
101+
PHP_NAMED_FE( format, ZEND_FN( numfmt_format ), arginfo_class_NumberFormatter_format )
102+
PHP_NAMED_FE( parse, ZEND_FN( numfmt_parse ), arginfo_class_NumberFormatter_parse )
103+
PHP_NAMED_FE( formatCurrency, ZEND_FN( numfmt_format_currency ), arginfo_class_NumberFormatter_formatCurrency )
104+
PHP_NAMED_FE( parseCurrency, ZEND_FN( numfmt_parse_currency ), arginfo_class_NumberFormatter_parseCurrency )
105+
PHP_NAMED_FE( setAttribute, ZEND_FN( numfmt_set_attribute ), arginfo_class_NumberFormatter_setAttribute )
106+
PHP_NAMED_FE( getAttribute, ZEND_FN( numfmt_get_attribute ), arginfo_class_NumberFormatter_getAttribute )
107+
PHP_NAMED_FE( setTextAttribute, ZEND_FN( numfmt_set_text_attribute ), arginfo_class_NumberFormatter_setTextAttribute )
108+
PHP_NAMED_FE( getTextAttribute, ZEND_FN( numfmt_get_text_attribute ), arginfo_class_NumberFormatter_getTextAttribute )
109+
PHP_NAMED_FE( setSymbol, ZEND_FN( numfmt_set_symbol ), arginfo_class_NumberFormatter_setSymbol )
110+
PHP_NAMED_FE( getSymbol, ZEND_FN( numfmt_get_symbol ), arginfo_class_NumberFormatter_getSymbol )
111+
PHP_NAMED_FE( setPattern, ZEND_FN( numfmt_set_pattern ), arginfo_class_NumberFormatter_setPattern )
112+
PHP_NAMED_FE( getPattern, ZEND_FN( numfmt_get_pattern ), arginfo_class_NumberFormatter_getPattern )
113+
PHP_NAMED_FE( getLocale, ZEND_FN( numfmt_get_locale ), arginfo_class_NumberFormatter_getLocale )
114+
PHP_NAMED_FE( getErrorCode, ZEND_FN( numfmt_get_error_code ), arginfo_class_NumberFormatter_getErrorCode )
115+
PHP_NAMED_FE( getErrorMessage, ZEND_FN( numfmt_get_error_message ), arginfo_class_NumberFormatter_getErrorMessage )
170116
PHP_FE_END
171117
};
172118
/* }}} */

0 commit comments

Comments
 (0)