Skip to content

Commit 73138be

Browse files
committed
Core: convert bail-out for incorect __debugInfo return type to TypeError
1 parent 9437c32 commit 73138be

14 files changed

+107
-253
lines changed

Zend/tests/debug_info-error-0.0.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-0.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-1.0.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-1.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-empty_str.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-false.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-object.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

Zend/tests/debug_info-error-resource.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Testing __debugInfo() magic method with bad returns
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public $val;
8+
public function __debugInfo() {
9+
return $this->val;
10+
}
11+
public function __construct($val) {
12+
$this->val = $val;
13+
}
14+
}
15+
16+
$VALUES = [
17+
false,
18+
true,
19+
0,
20+
0.0,
21+
1.0,
22+
1,
23+
"",
24+
"foo",
25+
new stdClass(),
26+
STDERR,
27+
];
28+
29+
foreach ($VALUES as $value) {
30+
$c = new C($value);
31+
32+
try {
33+
var_dump($c);
34+
} catch (Throwable $e) {
35+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
36+
}
37+
}
38+
?>
39+
--EXPECT--
40+
TypeError: __debuginfo() must return an array
41+
TypeError: __debuginfo() must return an array
42+
TypeError: __debuginfo() must return an array
43+
TypeError: __debuginfo() must return an array
44+
TypeError: __debuginfo() must return an array
45+
TypeError: __debuginfo() must return an array
46+
TypeError: __debuginfo() must return an array
47+
TypeError: __debuginfo() must return an array
48+
TypeError: __debuginfo() must return an array
49+
TypeError: __debuginfo() must return an array

Zend/tests/debug_info-error-str.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)