Skip to content

Commit

Permalink
Add separate arginfo structures for createFromFormat methods
Browse files Browse the repository at this point in the history
In PHP 8 these methods do not have return types whilst their matching
functions do.
  • Loading branch information
cs278 committed Dec 24, 2021
1 parent 43a484b commit 74ed572
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timecop_php7.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static zend_function_entry timecop_funcs_timecop[] = {
static zend_function_entry timecop_funcs_date[] = {
PHP_ME(TimecopDateTime, __construct, arginfo_class_TimecopDateTime___construct,
ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(createFromFormat, timecop_date_create_from_format, arginfo_timecop_date_create_from_format,
PHP_ME_MAPPING(createFromFormat, timecop_date_create_from_format, arginfo_class_TimecopDateTime_createFromFormat,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
{NULL, NULL, NULL}
};
Expand All @@ -155,7 +155,7 @@ static zend_function_entry timecop_funcs_orig_date[] = {
static zend_function_entry timecop_funcs_immutable[] = {
PHP_ME(TimecopDateTimeImmutable, __construct, arginfo_class_TimecopDateTimeImmutable___construct,
ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(createFromFormat, timecop_date_create_immutable_from_format, arginfo_timecop_date_create_immutable_from_format,
PHP_ME_MAPPING(createFromFormat, timecop_date_create_immutable_from_format, arginfo_class_TimecopDateTimeImmutable_createFromFormat,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
{NULL, NULL, NULL}
};
Expand Down
6 changes: 6 additions & 0 deletions timecop_php7_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ ZEND_END_ARG_INFO()
// TimecopDateTime::__construct()
#define arginfo_class_TimecopDateTime___construct arginfo_timecop_date_create

// TimecopDateTime::createFromFormat()
#define arginfo_class_TimecopDateTime_createFromFormat arginfo_timecop_date_create_from_format

// timecop_date_create_immutable()
#define arginfo_timecop_date_create_immutable arginfo_timecop_date_create

Expand All @@ -130,3 +133,6 @@ ZEND_END_ARG_INFO()

// TimecopDateTimeImmutable::__construct
#define arginfo_class_TimecopDateTimeImmutable___construct arginfo_class_TimecopDateTime___construct

// TimecopDateTimeImmutable::createFromFormat
#define arginfo_class_TimecopDateTimeImmutable_createFromFormat arginfo_timecop_date_create_immutable_from_format
22 changes: 22 additions & 0 deletions timecop_php8_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_TimecopDateTime___construct, 0, 0, 0)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, timezone, DateTimeZone, 1, "null")
ZEND_END_ARG_INFO()

// TimecopDateTime::createFromFormat()
#if PHP_VERSION_ID >= 80100
#define arginfo_class_TimecopDateTime_createFromFormat arginfo_timecop_date_create_from_format
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_TimecopDateTime_createFromFormat, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, timezone, DateTimeZone, 1, "null")
ZEND_END_ARG_INFO()
#endif

// timecop_date_create_immutable()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_timecop_date_create_immutable, 0, 0, TimecopDateTimeImmutable, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, datetime, IS_STRING, 0, "\"now\"")
Expand All @@ -133,3 +144,14 @@ ZEND_END_ARG_INFO()

// TimecopDateTimeImmutable::__construct
#define arginfo_class_TimecopDateTimeImmutable___construct arginfo_class_TimecopDateTime___construct

// TimecopDateTimeImmutable::createFromFormat
#if PHP_VERSION_ID >= 80100
#define arginfo_class_TimecopDateTimeImmutable_createFromFormat arginfo_timecop_date_create_immutable_from_format
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_TimecopDateTimeImmutable_createFromFormat, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, timezone, DateTimeZone, 1, "null")
ZEND_END_ARG_INFO()
#endif

0 comments on commit 74ed572

Please sign in to comment.