xref: /PHP-8.0/ext/date/tests/bug65672.phpt (revision 01d30f88)
1--TEST--
2Test for bug #65672: Broken classes inherited from DatePeriod
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7
8$interval = new DateInterval('P1D');
9$period = new class(new DateTime, $interval, new DateTime) extends DatePeriod {
10    public $extra = "stuff";
11};
12
13var_dump($period->extra);
14$period->extra = "modified";
15var_dump($period->extra);
16
17# Ensure we can modify properties (retrieve for write)
18$period->extra = [];
19$period->extra[] = "array";
20var_dump($period->extra);
21
22var_dump(isset($period->dynamic1));
23$period->dynamic1 = "dynamic";
24var_dump($period->dynamic1);
25
26# Ensure we can modify properties (retrieve for write)
27$period->dynamic2 = [];
28$period->dynamic2[] = "array";
29var_dump($period->dynamic2);
30
31$period->dynamic3[] = "array";
32var_dump($period->dynamic3);
33
34?>
35--EXPECT--
36string(5) "stuff"
37string(8) "modified"
38array(1) {
39  [0]=>
40  string(5) "array"
41}
42bool(false)
43string(7) "dynamic"
44array(1) {
45  [0]=>
46  string(5) "array"
47}
48array(1) {
49  [0]=>
50  string(5) "array"
51}
52