Skip to content

Commit fe7761b

Browse files
committed
Add stubs for IntlDateFormatter & MessageFormatter
Closes GH-4812
1 parent f6ddcfa commit fe7761b

File tree

9 files changed

+495
-209
lines changed

9 files changed

+495
-209
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
3+
class IntlDateFormatter
4+
{
5+
/**
6+
* @param IntlTimeZone|DateTimeZone|string|null $timezone
7+
* @param IntlCalendar|int|null $calendar
8+
*/
9+
public function __construct(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = "") {}
10+
11+
/**
12+
* @param IntlTimeZone|DateTimeZone|string|null $timezone
13+
* @param IntlCalendar|int|null $calendar
14+
* @return IntlDateFormatter|null
15+
*/
16+
public static function create(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = "") {}
17+
18+
/** @return int|false */
19+
public function getDateType() {}
20+
21+
/** @return int|false */
22+
public function getTimeType() {}
23+
24+
/** @return int|false */
25+
public function getCalendar() {}
26+
27+
/**
28+
* @param IntlCalendar|int|null $which
29+
* @return bool
30+
*/
31+
public function setCalendar($which) {}
32+
33+
/** @return string|false */
34+
public function getTimeZoneId() {}
35+
36+
/** @return IntlCalendar|null|false */
37+
public function getCalendarObject() {}
38+
39+
/** @return IntlTimeZone|false */
40+
public function getTimeZone() {}
41+
42+
/**
43+
* @param IntlTimeZone|DateTimeZone|string|null $zone
44+
* @return ?bool
45+
*/
46+
public function setTimeZone($zone) {}
47+
48+
/** @return bool */
49+
public function setPattern(string $pattern) {}
50+
51+
/** @return string|false */
52+
public function getPattern() {}
53+
54+
/** @return string|false */
55+
public function getLocale(int $which = UNKNOWN) {}
56+
57+
/** @return void */
58+
public function setLenient(bool $lenient) {}
59+
60+
/** @return bool */
61+
public function isLenient() {}
62+
63+
/**
64+
* @param array|int $value
65+
* @return string|false
66+
*/
67+
public function format($value) {}
68+
69+
/**
70+
* @param IntlCalendar|DateTime $object
71+
* @param array|int|string|null $format
72+
* @return string|false
73+
*/
74+
public static function formatObject($object, $format = null, ?string $locale = null) {}
75+
76+
/** @return int|float|false */
77+
public function parse(string $value, &$position = null) {}
78+
79+
/** @return array|false */
80+
public function localtime(string $value, &$position = null) {}
81+
82+
/** @return int */
83+
public function getErrorCode() {}
84+
85+
/** @return string */
86+
public function getErrorMessage() {}
87+
}
88+
89+
/**
90+
* @param IntlTimeZone|DateTimeZone|string|null $timezone
91+
* @param IntlCalendar|int|null $calendar
92+
*/
93+
function datefmt_create(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = ""): ?IntlDateFormatter {}
94+
95+
function datefmt_get_datetype(IntlDateFormatter $df): int|false {}
96+
97+
function datefmt_get_timetype(IntlDateFormatter $df): int|false {}
98+
99+
function datefmt_get_calendar(IntlDateFormatter $df): int|false {}
100+
101+
/** @param IntlCalendar|int|null $which */
102+
function datefmt_set_calendar(IntlDateFormatter $df, $which): bool {}
103+
104+
function datefmt_get_timezone_id(IntlDateFormatter $df): string|false {}
105+
106+
function datefmt_get_calendar_object(IntlDateFormatter $df): IntlCalendar|false|null {}
107+
108+
function datefmt_get_timezone(IntlDateFormatter $df): IntlTimeZone|false {}
109+
110+
/** @param IntlTimeZone|DateTimeZone|string|null $zone */
111+
function datefmt_set_timezone(IntlDateFormatter $df, $zone): ?bool {}
112+
113+
function datefmt_set_pattern(IntlDateFormatter $df, string $pattern): bool {}
114+
115+
function datefmt_get_pattern(IntlDateFormatter $df): string|false {}
116+
117+
function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN): string|false {}
118+
119+
function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): void {}
120+
121+
function datefmt_is_lenient(IntlDateFormatter $df): bool {}
122+
123+
/** @param mixed $value */
124+
function datefmt_format(IntlDateFormatter $df, $value): string|false {}
125+
126+
/**
127+
* @param IntlCalendar|DateTimeInterface $object
128+
* @param array|int|string|null $format
129+
*/
130+
function datefmt_format_object($object, $format = null, ?string $locale = null): string|false {}
131+
132+
function datefmt_parse(IntlDateFormatter $df, string $value, &$position = null): int|float|false {}
133+
134+
function datefmt_localtime(IntlDateFormatter $df, string $value, &$position = null): array|false {}
135+
136+
function datefmt_get_error_code(IntlDateFormatter $df): int {}
137+
138+
function datefmt_get_error_message(IntlDateFormatter $df): string {}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 3)
4+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
5+
ZEND_ARG_TYPE_INFO(0, datetype, IS_LONG, 0)
6+
ZEND_ARG_TYPE_INFO(0, timetype, IS_LONG, 0)
7+
ZEND_ARG_INFO(0, timezone)
8+
ZEND_ARG_INFO(0, calendar)
9+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
10+
ZEND_END_ARG_INFO()
11+
12+
#define arginfo_class_IntlDateFormatter_create arginfo_class_IntlDateFormatter___construct
13+
14+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getDateType, 0, 0, 0)
15+
ZEND_END_ARG_INFO()
16+
17+
#define arginfo_class_IntlDateFormatter_getTimeType arginfo_class_IntlDateFormatter_getDateType
18+
19+
#define arginfo_class_IntlDateFormatter_getCalendar arginfo_class_IntlDateFormatter_getDateType
20+
21+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setCalendar, 0, 0, 1)
22+
ZEND_ARG_INFO(0, which)
23+
ZEND_END_ARG_INFO()
24+
25+
#define arginfo_class_IntlDateFormatter_getTimeZoneId arginfo_class_IntlDateFormatter_getDateType
26+
27+
#define arginfo_class_IntlDateFormatter_getCalendarObject arginfo_class_IntlDateFormatter_getDateType
28+
29+
#define arginfo_class_IntlDateFormatter_getTimeZone arginfo_class_IntlDateFormatter_getDateType
30+
31+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setTimeZone, 0, 0, 1)
32+
ZEND_ARG_INFO(0, zone)
33+
ZEND_END_ARG_INFO()
34+
35+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setPattern, 0, 0, 1)
36+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
37+
ZEND_END_ARG_INFO()
38+
39+
#define arginfo_class_IntlDateFormatter_getPattern arginfo_class_IntlDateFormatter_getDateType
40+
41+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getLocale, 0, 0, 0)
42+
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
43+
ZEND_END_ARG_INFO()
44+
45+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setLenient, 0, 0, 1)
46+
ZEND_ARG_TYPE_INFO(0, lenient, _IS_BOOL, 0)
47+
ZEND_END_ARG_INFO()
48+
49+
#define arginfo_class_IntlDateFormatter_isLenient arginfo_class_IntlDateFormatter_getDateType
50+
51+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_format, 0, 0, 1)
52+
ZEND_ARG_INFO(0, value)
53+
ZEND_END_ARG_INFO()
54+
55+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_formatObject, 0, 0, 1)
56+
ZEND_ARG_INFO(0, object)
57+
ZEND_ARG_INFO(0, format)
58+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
59+
ZEND_END_ARG_INFO()
60+
61+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_parse, 0, 0, 1)
62+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
63+
ZEND_ARG_INFO(1, position)
64+
ZEND_END_ARG_INFO()
65+
66+
#define arginfo_class_IntlDateFormatter_localtime arginfo_class_IntlDateFormatter_parse
67+
68+
#define arginfo_class_IntlDateFormatter_getErrorCode arginfo_class_IntlDateFormatter_getDateType
69+
70+
#define arginfo_class_IntlDateFormatter_getErrorMessage arginfo_class_IntlDateFormatter_getDateType
71+
72+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_datefmt_create, 0, 3, IntlDateFormatter, 1)
73+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
74+
ZEND_ARG_TYPE_INFO(0, datetype, IS_LONG, 0)
75+
ZEND_ARG_TYPE_INFO(0, timetype, IS_LONG, 0)
76+
ZEND_ARG_INFO(0, timezone)
77+
ZEND_ARG_INFO(0, calendar)
78+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
79+
ZEND_END_ARG_INFO()
80+
81+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_datetype, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
82+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
83+
ZEND_END_ARG_INFO()
84+
85+
#define arginfo_datefmt_get_timetype arginfo_datefmt_get_datetype
86+
87+
#define arginfo_datefmt_get_calendar arginfo_datefmt_get_datetype
88+
89+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_calendar, 0, 2, _IS_BOOL, 0)
90+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
91+
ZEND_ARG_INFO(0, which)
92+
ZEND_END_ARG_INFO()
93+
94+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_timezone_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
95+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
96+
ZEND_END_ARG_INFO()
97+
98+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_datefmt_get_calendar_object, 0, 1, IntlCalendar, MAY_BE_FALSE|MAY_BE_NULL)
99+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
100+
ZEND_END_ARG_INFO()
101+
102+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_datefmt_get_timezone, 0, 1, IntlTimeZone, MAY_BE_FALSE)
103+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
104+
ZEND_END_ARG_INFO()
105+
106+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_timezone, 0, 2, _IS_BOOL, 1)
107+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
108+
ZEND_ARG_INFO(0, zone)
109+
ZEND_END_ARG_INFO()
110+
111+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_pattern, 0, 2, _IS_BOOL, 0)
112+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
113+
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
114+
ZEND_END_ARG_INFO()
115+
116+
#define arginfo_datefmt_get_pattern arginfo_datefmt_get_timezone_id
117+
118+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
119+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
120+
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
121+
ZEND_END_ARG_INFO()
122+
123+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_lenient, 0, 2, IS_VOID, 0)
124+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
125+
ZEND_ARG_TYPE_INFO(0, lenient, _IS_BOOL, 0)
126+
ZEND_END_ARG_INFO()
127+
128+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_is_lenient, 0, 1, _IS_BOOL, 0)
129+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
130+
ZEND_END_ARG_INFO()
131+
132+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
133+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
134+
ZEND_ARG_INFO(0, value)
135+
ZEND_END_ARG_INFO()
136+
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()
142+
143+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_parse, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE)
144+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
145+
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
146+
ZEND_ARG_INFO(1, position)
147+
ZEND_END_ARG_INFO()
148+
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_INFO(1, position)
153+
ZEND_END_ARG_INFO()
154+
155+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_error_code, 0, 1, IS_LONG, 0)
156+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
157+
ZEND_END_ARG_INFO()
158+
159+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_error_message, 0, 1, IS_STRING, 0)
160+
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
161+
ZEND_END_ARG_INFO()

ext/intl/dateformat/dateformat_attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ PHP_FUNCTION( datefmt_is_lenient )
206206
}
207207
/* }}} */
208208

209-
/* {{{ proto string IntlDateFormatter::setLenient()
209+
/* {{{ proto void IntlDateFormatter::setLenient()
210210
* Set formatter lenient. }}} */
211-
/* {{{ proto string datefmt_setLenient(IntlDateFormatter $mf)
211+
/* {{{ proto void datefmt_setLenient(IntlDateFormatter $mf)
212212
* Set formatter lenient.
213213
*/
214214
PHP_FUNCTION( datefmt_set_lenient )

0 commit comments

Comments
 (0)