Skip to content

Commit d8ca9cc

Browse files
committed
Add tests for DatePeriod properties
1 parent a468752 commit d8ca9cc

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

ext/date/php_date.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,8 +2148,6 @@ static void date_register_classes(void) /* {{{ */
21482148
date_object_handlers_period.get_properties = date_object_get_properties_period;
21492149
date_object_handlers_period.get_property_ptr_ptr = NULL;
21502150
date_object_handlers_period.get_gc = date_object_get_gc_period;
2151-
date_object_handlers_period.read_property = date_period_read_property;
2152-
date_object_handlers_period.write_property = date_period_write_property;
21532151

21542152
#define REGISTER_PERIOD_CLASS_CONST_STRING(const_name, value) \
21552153
zend_declare_class_constant_long(date_ce_period, const_name, sizeof(const_name)-1, value);
@@ -5255,34 +5253,6 @@ PHP_METHOD(DatePeriod, __wakeup)
52555253
}
52565254
/* }}} */
52575255

5258-
/* {{{ date_period_read_property */
5259-
static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
5260-
{
5261-
zval *zv;
5262-
if (type != BP_VAR_IS && type != BP_VAR_R) {
5263-
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
5264-
return &EG(uninitialized_zval);
5265-
}
5266-
5267-
Z_OBJPROP_P(object); /* build properties hash table */
5268-
5269-
zv = std_object_handlers.read_property(object, member, type, cache_slot, rv);
5270-
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
5271-
/* defensive copy */
5272-
ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv));
5273-
}
5274-
5275-
return zv;
5276-
}
5277-
/* }}} */
5278-
5279-
/* {{{ date_period_write_property */
5280-
static void date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot)
5281-
{
5282-
zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported");
5283-
}
5284-
/* }}} */
5285-
52865256
/*
52875257
* Local variables:
52885258
* tab-width: 4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
DatePeriod: Test properties
3+
--INI--
4+
date.timezone=UTC
5+
--FILE--
6+
<?php
7+
$interval = new DateInterval('P1D');
8+
$period = new class(new DateTime, $interval, new DateTime) extends DatePeriod {
9+
public $extra = "stuff";
10+
};
11+
12+
var_dump($period->extra);
13+
$period->extra = "modified";
14+
var_dump($period->extra);
15+
?>
16+
--EXPECT--
17+
string(5) "stuff"
18+
string(8) "modified"

0 commit comments

Comments
 (0)