8000 Add DateInterval's __serialize and __unserialize methods · php/php-src@f869a54 · GitHub
[go: up one dir, main page]

Skip to content

Commit f869a54

Browse files
committed
Add DateInterval's __serialize and __unserialize methods
1 parent 3be8b5f commit f869a54

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

ext/date/php_date.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,6 +4204,44 @@ PHP_METHOD(DateInterval, __set_state)
42044204
}
42054205
/* }}} */
42064206

4207+
/* {{{ */
4208+
PHP_METHOD(DateInterval, __serialize)
4209+
{
4210+
zval *object = ZEND_THIS;
4211+
php_interval_obj *intervalobj;
4212+
HashTable *myht;
4213+
4214+
ZEND_PARSE_PARAMETERS_NONE();
4215+
4216+
intervalobj = Z_PHPINTERVAL_P(object);
4217+
DATE_CHECK_INITIALIZED(intervalobj->initialized, DateInterval);
4218+
4219+
array_init(return_value);
4220+
myht = Z_ARRVAL_P(return_value);
4221+
date_interval_object_to_hash(intervalobj, myht, true);
4222+
}
4223+
/* }}} */
4224+
4225+
4226+
/* {{{ */
4227+
PHP_METHOD(DateInterval, __unserialize)
4228+
{
4229+
zval *object = ZEND_THIS;
4230+
php_interval_obj *intervalobj;
4231+
zval *array;
4232+
HashTable *myht;
4233+
4234+
ZEND_PARSE_PARAMETERS_START(1, 1)
4235+
Z_PARAM_ARRAY(array)
4236+
ZEND_PARSE_PARAMETERS_END();
4237+
4238+
intervalobj = Z_PHPINTERVAL_P(object);
4239+
myht = Z_ARRVAL_P(array);
4240+
4241+
php_date_interval_initialize_from_hash(&object, &intervalobj, myht);
4242+
}
4243+
/* }}} */
4244+
42074245
/* {{{ */
42084246
PHP_METHOD(DateInterval, __wakeup)
42094247
{

ext/date/php_date.stub.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ public static function createFromDateString(string $datetime): DateInterval|fals
480480
*/
481481
public function format(string $format): string {}
482482

483+
public function __serialize(): array;
484+
485+
public function __unserialize(array $data): void;
486+
483487
/** @tentative-return-type */
484488
public function __wakeup(): void {}
485489

ext/date/php_date_arginfo.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: a157de6bca4bcf5a9ddace9e81ef700f132b4dda */
2+
* Stub hash: 4845891ab3872f292438de639953e2022f849125 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
@@ -451,6 +451,10 @@ ZEND_END_ARG_INFO()
451451

452452
#define arginfo_class_DateInterval_format arginfo_class_DateTimeInterface_format
453453

454+
#define arginfo_class_DateInterval___serialize arginfo_timezone_abbreviations_list
455+
456+
#define arginfo_class_DateInterval___unserialize arginfo_class_DateTimeInterface___unserialize
457+
454458
#define arginfo_class_DateInterval___wakeup arginfo_class_DateTimeInterface___wakeup
455459

456460
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateInterval___set_state, 0, 1, DateInterval, 0)
@@ -562,6 +566,8 @@ ZEND_METHOD(DateTimeZone, __unserialize);
562566
ZEND_METHOD(DateTimeZone, __wakeup);
563567
ZEND_METHOD(DateTimeZone, __set_state);
564568
ZEND_METHOD(DateInterval, __construct);
569+
ZEND_METHOD(DateInterval, __serialize);
570+
ZEND_METHOD(DateInterval, __unserialize);
565571
ZEND_METHOD(DateInterval, __wakeup);
566572
ZEND_METHOD(DateInterval, __set_state);
567573
ZEND_METHOD(DatePeriod, __construct);
@@ -714,6 +720,8 @@ static const zend_function_entry class_DateInterval_methods[] = {
714720
ZEND_ME(DateInterval, __construct, arginfo_class_DateInterval___construct, ZEND_ACC_PUBLIC)
715721
ZEND_ME_MAPPING(createFromDateString, date_interval_create_from_date_string, arginfo_class_DateInterval_createFromDateString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
716722
ZEND_ME_MAPPING(format, date_interval_format, arginfo_class_DateInterval_format, ZEND_ACC_PUBLIC)
723+
ZEND_ME(DateInterval, __serialize, arginfo_class_DateInterval___serialize, ZEND_ACC_PUBLIC)
724+
ZEND_ME(DateInterval, __unserialize, arginfo_class_DateInterval___unserialize, ZEND_ACC_PUBLIC)
717725
ZEND_ME(DateInterval, __wakeup, arginfo_class_DateInterval___wakeup, ZEND_ACC_PUBLIC)
718726
ZEND_ME(DateInterval, __set_state, arginfo_class_DateInterval___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
719727
ZEND_FE_END

0 commit comments

Comments
 (0)
0