summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-11-15 12:50:44 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-11-15 17:19:26 +0100
commit0cec268d15e5aded8692ee8076e93d2839725918 (patch)
treef291b6a10fea7b3204f373451464182fd1860a73 /ext/date
parent468ecf295d3e15a2b8d0aa3ca6b39bbb29dbffd6 (diff)
downloadphp-git-0cec268d15e5aded8692ee8076e93d2839725918.tar.gz
Support single class unions in gen stubs
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/date/php_date.stub.php26
-rw-r--r--ext/date/php_date_arginfo.h46
3 files changed, 44 insertions, 32 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 59f5a5077f..7dcc212e21 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -93,9 +93,9 @@ static const zend_function_entry date_functions[] = {
/* Advanced Interface */
PHP_FE(date_create, arginfo_date_create)
- PHP_FE(date_create_immutable, arginfo_date_create)
+ PHP_FE(date_create_immutable, arginfo_date_create_immutable)
PHP_FE(date_create_from_format, arginfo_date_create_from_format)
- PHP_FE(date_create_immutable_from_format, arginfo_date_create_from_format)
+ PHP_FE(date_create_immutable_from_format, arginfo_date_create_immutable_from_format)
PHP_FE(date_parse, arginfo_date_parse)
PHP_FE(date_parse_from_format, arginfo_date_parse_from_format)
PHP_FE(date_get_last_errors, arginfo_date_get_last_errors)
diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php
index b76f0bd1df..17d9a848f0 100644
--- a/ext/date/php_date.stub.php
+++ b/ext/date/php_date.stub.php
@@ -31,18 +31,16 @@ function localtime(int $timestamp = UNKNOWN, bool $associative = false): array {
function getdate(int $timestamp = UNKNOWN): array {}
-/** @return DateTime|false */
-function date_create(string $time = "now", ?DateTimeZone $timezone = null) {}
+function date_create(string $time = "now", ?DateTimeZone $timezone = null): DateTime|false {}
-/** @return DateTime|false */
-function date_create_immutable(string $time = "now", ?DateTimeZone $timezone = null) {}
+function date_create_immutable(
+ string $time = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
-/** @return DateTime|false */
-function date_create_from_format(string $format, string $time, ?DateTimeZone $timezone = null) {}
+function date_create_from_format(
+ string $format, string $time, ?DateTimeZone $timezone = null): DateTime|false {}
-/** @return DateTimeImmutable|false */
function date_create_immutable_from_format(
- string $format, string $time, ?DateTimeZone $timezone = null) {}
+ string $format, string $time, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
function date_parse(string $date): array {}
@@ -52,15 +50,13 @@ function date_get_last_errors(): array|false {}
function date_format(DateTimeInterface $object, string $format): string {}
-/** @return DateTime|false */
-function date_modify(DateTime $object, string $modify) {}
+function date_modify(DateTime $object, string $modify): DateTime|false {}
function date_add(DateTime $object, DateInterval $interval): DateTime {}
function date_sub(DateTime $object, DateInterval $interval): DateTime {}
-/** @return DateTimeZone|false */
-function date_timezone_get(DateTimeInterface $object) {}
+function date_timezone_get(DateTimeInterface $object): DateTimeZone|false {}
function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): DateTime {}
@@ -80,8 +76,7 @@ function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}
function date_timestamp_get(DateTimeInterface $object): int|false {}
-/** @return DateTimeZone|false */
-function timezone_open(string $timezone) {}
+function timezone_open(string $timezone): DateTimeZone|false {}
function timezone_name_get(DateTimeZone $object): string {}
@@ -100,8 +95,7 @@ function timezone_abbreviations_list(): array {}
function timezone_version_get(): string {}
-/** @return DateInterval|false */
-function date_interval_create_from_date_string(string $time) {}
+function date_interval_create_from_date_string(string $time): DateInterval|false {}
function date_interval_format(DateInterval $object, string $format): string {}
diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h
index 15c4bd203d..183e3e0d30 100644
--- a/ext/date/php_date_arginfo.h
+++ b/ext/date/php_date_arginfo.h
@@ -53,20 +53,27 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getdate, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create, 0, 0, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_create, 0, 0, DateTime, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
ZEND_END_ARG_INFO()
-#define arginfo_date_create_immutable arginfo_date_create
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_create_immutable, 0, 0, DateTimeImmutable, MAY_BE_FALSE)
+ ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create_from_format, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_create_from_format, 0, 2, DateTime, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
ZEND_END_ARG_INFO()
-#define arginfo_date_create_immutable_from_format arginfo_date_create_from_format
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_create_immutable_from_format, 0, 2, DateTimeImmutable, MAY_BE_FALSE)
+ ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_parse, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, date, IS_STRING, 0)
@@ -85,7 +92,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_format, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_modify, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_modify, 0, 2, DateTime, MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_TYPE_INFO(0, modify, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -97,7 +104,7 @@ ZEND_END_ARG_INFO()
#define arginfo_date_sub arginfo_date_add
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_get, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_timezone_get, 0, 1, DateTimeZone, MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_END_ARG_INFO()
@@ -147,7 +154,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_date_timestamp_get, 0, 1, MAY_BE
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_open, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_timezone_open, 0, 1, DateTimeZone, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -187,7 +194,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_timezone_version_get, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_create_from_date_string, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_interval_create_from_date_string, 0, 1, DateInterval, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -237,7 +244,10 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeInterface___wakeup arginfo_class_DateTimeInterface_getTimezone
-#define arginfo_class_DateTime___construct arginfo_date_create
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime___construct, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime___set_state, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
@@ -247,7 +257,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime_createFromImmutable, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, object, DateTimeImmutable, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_DateTime_createFromFormat arginfo_date_create_from_format
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime_createFromFormat, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
#define arginfo_class_DateTime_getLastErrors arginfo_class_DateTimeInterface_getTimezone
@@ -288,7 +302,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime_setTimestamp, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_DateTimeImmutable___construct arginfo_date_create
+#define arginfo_class_DateTimeImmutable___construct arginfo_class_DateTime___construct
#define arginfo_class_DateTimeImmutable___set_state arginfo_class_DateTime___set_state
@@ -296,7 +310,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeImmutable_createFromMutable, 0, 0,
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_DateTimeImmutable_createFromFormat arginfo_date_create_from_format
+#define arginfo_class_DateTimeImmutable_createFromFormat arginfo_class_DateTime_createFromFormat
#define arginfo_class_DateTimeImmutable_getLastErrors arginfo_class_DateTimeInterface_getTimezone
@@ -316,7 +330,9 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeImmutable_setTimestamp arginfo_class_DateTime_setTimestamp
-#define arginfo_class_DateTimeZone___construct arginfo_timezone_open
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeZone___construct, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
+ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeZone_getName arginfo_class_DateTimeInterface_getTimezone
@@ -346,7 +362,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateInterval___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, interval_spec, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_DateInterval_createFromDateString arginfo_date_interval_create_from_date_string
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateInterval_createFromDateString, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ZEND_END_ARG_INFO()
#define arginfo_class_DateInterval_format arginfo_class_DateTimeInterface_format