summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/array_walk_objects.phpt
blob: 9f3ac8c1cd668f970dab6157dbad56080c03b513 (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
--TEST--
array_walk() and objects
--FILE--
<?php

function walk($key, $value) {
	var_dump($value, $key);
}

class test {
	private $var_pri = "test_private";
	protected $var_pro = "test_protected";
	public $var_pub = "test_public";
}

$stdclass = new stdclass;
$stdclass->foo = "foo";
$stdclass->bar = "bar";
array_walk($stdclass, "walk");

$t = new test;
array_walk($t, "walk");

$var = array();
array_walk($var, "walk");
$var = "";
try {
    array_walk($var, "walk");
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

echo "Done\n";
?>
--EXPECTF--
string(3) "foo"
string(3) "foo"
string(3) "bar"
string(3) "bar"
string(13) "%r\0%rtest%r\0%rvar_pri"
string(12) "test_private"
string(10) "%r\0%r*%r\0%rvar_pro"
string(14) "test_protected"
string(7) "var_pub"
string(11) "test_public"
array_walk() expects parameter 1 to be array, string given
Done