Skip to content

Commit 3872442

Browse files
committed
Add union return types
1 parent 6e7fb78 commit 3872442

File tree

5 files changed

+35
-42
lines changed

5 files changed

+35
-42
lines changed

ext/intl/dateformat/dateformat.stub.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,11 @@ public function getErrorMessage() {}
9292
*/
9393
function datefmt_create(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = ""): ?IntlDateFormatter {}
9494

95-
/** @return int|false */
96-
function datefmt_get_datetype(IntlDateFormatter $df) {}
95+
function datefmt_get_datetype(IntlDateFormatter $df): int|false {}
9796

98-
/** @return int|false */
99-
function datefmt_get_timetype(IntlDateFormatter $df) {}
97+
function datefmt_get_timetype(IntlDateFormatter $df): int|false {}
10098

101-
/** @return int|false */
102-
function datefmt_get_calendar(IntlDateFormatter $df) {}
99+
function datefmt_get_calendar(IntlDateFormatter $df): int|false {}
103100

104101
/** @param IntlCalendar|int|null $which */
105102
function datefmt_set_calendar(IntlDateFormatter $df, $which): bool {}
@@ -117,35 +114,26 @@ function datefmt_set_timezone(IntlDateFormatter $df, $zone): ?bool {}
117114

118115
function datefmt_set_pattern(IntlDateFormatter $df, string $pattern): bool {}
119116

120-
/** @return string|false */
121-
function datefmt_get_pattern(IntlDateFormatter $df) {}
117+
function datefmt_get_pattern(IntlDateFormatter $df): string|false {}
122118

123-
/** @return string|false */
124-
function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN) {}
119+
function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN): string|false {}
125120

126-
/** @return null|bool */
127-
function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient) {}
121+
function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): null|bool {}
128122

129123
function datefmt_is_lenient(IntlDateFormatter $df): bool {}
130124

131-
/**
132-
* @param mixed $value
133-
* @return string|false
134-
*/
135-
function datefmt_format(IntlDateFormatter $df, $value) {}
125+
/** @param mixed $value */
126+
function datefmt_format(IntlDateFormatter $df, $value): string|false {}
136127

137128
/**
138129
* @param IntlCalendar|DateTimeInterface $object
139130
* @param array|int|string|null $format
140-
* @return string|false
141131
*/
142-
function datefmt_format_object($object, $format = null, ?string $locale = null) {}
132+
function datefmt_format_object($object, $format = null, ?string $locale = null): string|false {}
143133

144-
/** @return int|false */
145-
function datefmt_parse(IntlDateFormatter $df, string $value, ?int &$position = null) {}
134+
function datefmt_parse(IntlDateFormatter $df, string $value, ?int &$position = null): int|false {}
146135

147-
/** @return array|false */
148-
function datefmt_localtime(IntlDateFormatter $df, string $value, ?int &$position = null) {}
136+
function datefmt_localtime(IntlDateFormatter $df, string $value, ?int &$position = null): array|false {}
149137

150138
function datefmt_get_error_code(IntlDateFormatter $df): int {}
151139

ext/intl/dateformat/dateformat_arginfo.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_datefmt_create, 0, 3, IntlDateFor
7878
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
7979
ZEND_END_ARG_INFO()
8080

81-
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_get_datetype, 0, 0, 1)
81+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_datetype, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
8282
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
8383
ZEND_END_ARG_INFO()
8484

@@ -95,9 +95,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_timezone_id, 0, 1, I
9595
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
9696
ZEND_END_ARG_INFO()
9797

98-
#define arginfo_datefmt_get_calendar_object arginfo_datefmt_get_datetype
98+
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_get_calendar_object, 0, 0, 1)
99+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
100+
ZEND_END_ARG_INFO()
99101

100-
#define arginfo_datefmt_get_timezone arginfo_datefmt_get_datetype
102+
#define arginfo_datefmt_get_timezone arginfo_datefmt_get_calendar_object
101103

102104
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_timezone, 0, 2, _IS_BOOL, 1)
103105
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
@@ -109,14 +111,16 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_pattern, 0, 2, _IS_B
109111
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
110112
ZEND_END_ARG_INFO()
111113

112-
#define arginfo_datefmt_get_pattern arginfo_datefmt_get_datetype
114+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_pattern, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
115+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
116+
ZEND_END_ARG_INFO()
113117

114-
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_get_locale, 0, 0, 1)
118+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
115119
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
116120
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
117121
ZEND_END_ARG_INFO()
118122

119-
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_lenient, 0, 0, 2)
123+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_set_lenient, 0, 2, MAY_BE_NULL|MAY_BE_BOOL)
120124
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
121125
ZEND_ARG_TYPE_INFO(0, lenient, _IS_BOOL, 0)
122126
ZEND_END_ARG_INFO()
@@ -125,20 +129,28 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_is_lenient, 0, 1, _IS_BO
125129
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
126130
ZEND_END_ARG_INFO()
127131

128-
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_format, 0, 0, 2)
132+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
129133
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
130134
ZEND_ARG_INFO(0, value)
131135
ZEND_END_ARG_INFO()
132136

133-
#define arginfo_datefmt_format_object arginfo_class_IntlDateFormatter_formatObject
137+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_format_object, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
138+
ZEND_ARG_INFO(0, object)
139+
ZEND_ARG_INFO(0, format)
140+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
141+
ZEND_END_ARG_INFO()
134142

135-
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_parse, 0, 0, 2)
143+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_parse, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
136144
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
137145
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
138146
ZEND_ARG_TYPE_INFO(1, position, IS_LONG, 1)
139147
ZEND_END_ARG_INFO()
140148

141-
#define arginfo_datefmt_localtime arginfo_datefmt_parse
149+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_localtime, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
150+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
151+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
152+
ZEND_ARG_TYPE_INFO(1, position, IS_LONG, 1)
153+
ZEND_END_ARG_INFO()
142154

143155
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_error_code, 0, 1, IS_LONG, 0)
144156
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)

ext/intl/msgformat/msgformat.stub.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function getErrorMessage() {}
3737

3838
function msgfmt_create(string $locale, string $pattern): ?MessageFormatter {}
3939

40-
/** @return string|false */
41-
function msgfmt_format(MessageFormatter $fmt, array $args): string {}
40+
function msgfmt_format(MessageFormatter $fmt, array $args): string|false {}
4241

4342
/** @return string|false */
4443
function msgfmt_format_message(string $locale, string $pattern, array $args) {}

ext/intl/msgformat/msgformat_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_msgfmt_create, 0, 2, MessageForma
4545
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
4646
ZEND_END_ARG_INFO()
4747

48-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_msgfmt_format, 0, 2, IS_STRING, 0)
48+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_msgfmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
4949
ZEND_ARG_OBJ_INFO(0, fmt, MessageFormatter, 0)
5050
ZEND_ARG_TYPE_INFO(0, args, IS_ARRAY, 0)
5151
ZEND_END_ARG_INFO()

ext/intl/php_intl.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_locale, 0, 0, 1)
289289
ZEND_ARG_INFO(0, type)
290290
ZEND_END_ARG_INFO()
291291

292-
ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse_message, 0, 0, 3)
293-
ZEND_ARG_INFO(0, locale)
294-
ZEND_ARG_INFO(0, pattern)
295-
ZEND_ARG_INFO(0, source)
296-
ZEND_END_ARG_INFO()
297-
298292
ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_ascii, 0, 0, 1)
299293
ZEND_ARG_INFO(0, domain)
300294
ZEND_ARG_INFO(0, option)

0 commit comments

Comments
 (0)