Skip to content

Commit 0b9e96a

Browse files
committed
Add stubs for NumberFormatter
1 parent cef1960 commit 0b9e96a

File tree

4 files changed

+268
-149
lines changed

4 files changed

+268
-149
lines changed

ext/intl/formatter/formatter.stub.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
class NumberFormatter
4+
{
5+
public function __construct(string $locale, int $style, ?string $pattern = null) {}
6+
7+
/** @return NumberFormatter|null */
8+
public static function create(string $locale, int $style, ?string $pattern = null) {}
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 = UNKNOWN) {}
51+
52+
/** @return int */
53+
public function getErrorCode() {}
54+
55+
/** @return string */
56+
public function getErrorMessage() {}
57+
}
58+
59+
/** @return NumberFormatter|false */
60+
function numfmt_create(string $locale, int $style, ?string $pattern = null) {}
61+
62+
/** @return string|false */
63+
function numfmt_format(NumberFormatter $fmt, $value, int $type = NumberFormatter::TYPE_DEFAULT) {}
64+
65+
/** @return int|float|false */
66+
function numfmt_parse(NumberFormatter $fmt, $value, int $type = NumberFormatter::TYPE_DOUBLE, &$position = null) {}
67+
68+
/** @return string|false */
69+
function numfmt_format_currency(NumberFormatter $fmt, float $value, string $currency) {}
70+
71+
/** @return float|false */
72+
function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency, &$position = null) {}
73+
74+
/** @param int|float $value */
75+
function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {}
76+
77+
/** @return int|double|false */
78+
function numfmt_get_attribute(NumberFormatter $fmt, int $attr) {}
79+
80+
function numfmt_set_text_attribute(NumberFormatter $fmt, int $attr, string $value): bool {}
81+
82+
/** @return string|false */
83+
function numfmt_get_text_attribute(NumberFormatter $fmt, int $attr) {}
84+
85+
function numfmt_set_symbol(NumberFormatter $fmt, int $attr, string $value): bool {}
86+
87+
/** @return string|false */
88+
function numfmt_get_symbol(NumberFormatter $fmt, int $attr) {}
89+
90+
function numfmt_set_pattern(NumberFormatter $fmt, string $pattern): bool {}
91+
92+
/** @return string|false */
93+
function numfmt_get_pattern(NumberFormatter $fmt) {}
94+
95+
/** @return string|false */
96+
function numfmt_get_locale(NumberFormatter $fmt, int $type = UNKNOWN) {}
97+
98+
function numfmt_get_error_code(NumberFormatter $fmt, int $type = UNKNOWN): int {}
99+
100+
function numfmt_get_error_message(NumberFormatter $fmt, int $type = UNKNOWN): string {}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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, 1)
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+
#define arginfo_numfmt_create arginfo_class_NumberFormatter___construct
69+
70+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format, 0, 0, 2)
71+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
72+
ZEND_ARG_INFO(0, value)
73+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
74+
ZEND_END_ARG_INFO()
75+
76+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse, 0, 0, 2)
77+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
78+
ZEND_ARG_INFO(0, value)
79+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
80+
ZEND_ARG_INFO(1, position)
81+
ZEND_END_ARG_INFO()
82+
83+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format_currency, 0, 0, 3)
84+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
85+
ZEND_ARG_TYPE_INFO(0, value, IS_DOUBLE, 0)
86+
ZEND_ARG_TYPE_INFO(0, currency, IS_STRING, 0)
87+
ZEND_END_ARG_INFO()
88+
89+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse_currency, 0, 0, 3)
90+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
91+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
92+
ZEND_ARG_INFO(1, currency)
93+
ZEND_ARG_INFO(1, position)
94+
ZEND_END_ARG_INFO()
95+
96+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_attribute, 0, 3, _IS_BOOL, 0)
97+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
98+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
99+
ZEND_ARG_INFO(0, value)
100+
ZEND_END_ARG_INFO()
101+
102+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_attribute, 0, 0, 2)
103+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
104+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
105+
ZEND_END_ARG_INFO()
106+
107+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_text_attribute, 0, 3, _IS_BOOL, 0)
108+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
109+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
110+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
111+
ZEND_END_ARG_INFO()
112+
113+
#define arginfo_numfmt_get_text_attribute arginfo_numfmt_get_attribute
114+
115+
#define arginfo_numfmt_set_symbol arginfo_numfmt_set_text_attribute
116+
117+
#define arginfo_numfmt_get_symbol arginfo_numfmt_get_attribute
118+
119+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_pattern, 0, 2, _IS_BOOL, 0)
120+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
121+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
122+
ZEND_END_ARG_INFO()
123+
124+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_pattern, 0, 0, 1)
125+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
126+
ZEND_END_ARG_INFO()
127+
128+
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_locale, 0, 0, 1)
129+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
130+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
131+
ZEND_END_ARG_INFO()
132+
133+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_get_error_code, 0, 1, IS_LONG, 0)
134+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
135+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
136+
ZEND_END_ARG_INFO()
137+
138+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_get_error_message, 0, 1, IS_STRING, 0)
139+
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
140+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
141+
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

@@ -90,82 +91,27 @@ zend_object *NumberFormatter_object_clone(zend_object *object)
9091
* 'NumberFormatter' class registration structures & functions
9192
*/
9293

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

0 commit comments

Comments
 (0)