xref: /php-src/ext/date/tests/bug65672.phpt (revision 902d6439)
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--EXPECTF--
36string(5) "stuff"
37string(8) "modified"
38array(1) {
39  [0]=>
40  string(5) "array"
41}
42bool(false)
43
44Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic1 is deprecated in %s on line %d
45string(7) "dynamic"
46
47Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic2 is deprecated in %s on line %d
48array(1) {
49  [0]=>
50  string(5) "array"
51}
52
53Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic3 is deprecated in %s on line %d
54array(1) {
55  [0]=>
56  string(5) "array"
57}
58