summaryrefslogtreecommitdiff
path: root/tests/lang/bug24658.phpt
blob: 5f35b3a229fb2a5eb8832f33cfa9dea6644005c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--TEST--
Bug #24658 (combo of typehint / reference causes crash)
--FILE--
<?php
class foo {}
function no_typehint($a) {
    var_dump($a);
}
function typehint(foo $a) {
    var_dump($a);
}
function no_typehint_ref(&$a) {
    var_dump($a);
}
function typehint_ref(foo &$a) {
    var_dump($a);
}
$v = new foo();
$a = array(new foo(), 1, 2);
no_typehint($v);
typehint($v);
no_typehint_ref($v);
typehint_ref($v);
echo "===no_typehint===\n";
array_walk($a, 'no_typehint');
echo "===no_typehint_ref===\n";
array_walk($a, 'no_typehint_ref');
echo "===typehint===\n";
array_walk($a, 'typehint');
echo "===typehint_ref===\n";
array_walk($a, 'typehint_ref');
?>
--EXPECTF--
object(foo)#%d (0) {
}
object(foo)#%d (0) {
}
object(foo)#%d (0) {
}
object(foo)#%d (0) {
}
===no_typehint===
object(foo)#%d (0) {
}
int(1)
int(2)
===no_typehint_ref===
object(foo)#%d (0) {
}
int(1)
int(2)
===typehint===
object(foo)#%d (0) {
}

Fatal error: Uncaught TypeError: typehint() expects argument #1 ($a) to be of type foo, int given in %s:%d
Stack trace:
#0 [internal function]: typehint(1, 1)
#1 %s(%d): array_walk(Array, 'typehint')
#2 {main}
  thrown in %s on line %d