xref: /PHP-8.3/ext/spl/tests/bug69264.phpt (revision c6357b80)
1--TEST--
2Bug #69264 (__debugInfo() ignored while extending SPL classes)
3--FILE--
4<?php
5class MyFileInfo extends SplFileInfo {
6    public function __debugInfo(): array {
7        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
8    }
9}
10
11class MyDoublyLinkedList extends SplDoublyLinkedList {
12    public function __debugInfo(): array {
13        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
14    }
15}
16
17class MyObjectStorage extends SplObjectStorage {
18    public function __debugInfo(): array {
19        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
20    }
21}
22
23class MyMultipleIterator extends MultipleIterator {
24    public function __debugInfo(): array {
25        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
26    }
27}
28
29class MyArrayObject extends ArrayObject {
30    public function __debugInfo(): array {
31        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
32    }
33}
34
35class MyArrayIterator extends ArrayIterator {
36    public function __debugInfo(): array {
37        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
38    }
39}
40
41class MyMaxHeap extends SplMaxHeap {
42    public function __debugInfo(): array {
43        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
44    }
45}
46
47class MyPriorityQueue extends SplPriorityQueue {
48    public function __debugInfo(): array {
49        return ['child' => 42, 'parent' => count(parent::__debugInfo())];
50    }
51}
52
53var_dump(
54    new MyFileInfo(__FILE__),
55    new MyDoublyLinkedList(),
56    new MyObjectStorage(),
57    new MyMultipleIterator(),
58    new MyArrayObject(),
59    new MyArrayIterator(),
60    new MyMaxHeap(),
61    new MyPriorityQueue(),
62);
63?>
64--EXPECTF--
65object(MyFileInfo)#%d (2) {
66  ["child"]=>
67  int(42)
68  ["parent"]=>
69  int(2)
70}
71object(MyDoublyLinkedList)#%d (2) {
72  ["child"]=>
73  int(42)
74  ["parent"]=>
75  int(2)
76}
77object(MyObjectStorage)#%d (2) {
78  ["child"]=>
79  int(42)
80  ["parent"]=>
81  int(1)
82}
83object(MyMultipleIterator)#%d (2) {
84  ["child"]=>
85  int(42)
86  ["parent"]=>
87  int(1)
88}
89object(MyArrayObject)#%d (2) {
90  ["child"]=>
91  int(42)
92  ["parent"]=>
93  int(1)
94}
95object(MyArrayIterator)#%d (2) {
96  ["child"]=>
97  int(42)
98  ["parent"]=>
99  int(1)
100}
101object(MyMaxHeap)#%d (2) {
102  ["child"]=>
103  int(42)
104  ["parent"]=>
105  int(3)
106}
107object(MyPriorityQueue)#%d (2) {
108  ["child"]=>
109  int(42)
110  ["parent"]=>
111  int(3)
112}
113