summaryrefslogtreecommitdiff
path: root/Zend/tests/debug_info.phpt
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2014-02-17 19:13:00 -0800
committerSara Golemon <pollita@php.net>2014-02-17 19:33:56 -0800
commit1e752ce9c57310cced0a5ba8399778c1f500f2b4 (patch)
tree9eb8723cb77cb2c5e5649886252a8c6d76dbe07a /Zend/tests/debug_info.phpt
parent4e4d319e6207e64d62a65c4238105f250cd13d0d (diff)
downloadphp-git-1e752ce9c57310cced0a5ba8399778c1f500f2b4.tar.gz
Add __debugInfo() magic method
class Foo { private $val = 'Random, meaningless data'; public function count() { return 42; } public function __debugInfo() { return ['count' => $this->count()]; } } $f = new Foo; var_dump($f);
Diffstat (limited to 'Zend/tests/debug_info.phpt')
-rw-r--r--Zend/tests/debug_info.phpt26
1 files changed, 26 insertions, 0 deletions
diff --git a/Zend/tests/debug_info.phpt b/Zend/tests/debug_info.phpt
new file mode 100644
index 0000000000..c7c9f23be5
--- /dev/null
+++ b/Zend/tests/debug_info.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Testing __debugInfo() magic method
+--FILE--
+<?php
+
+class Foo {
+ public $d = 4;
+ protected $e = 5;
+ private $f = 6;
+
+ public function __debugInfo() {
+ return ['a'=>1, "\0*\0b"=>2, "\0Foo\0c"=>3];
+ }
+}
+
+$f = new Foo;
+var_dump($f);
+--EXPECT--
+object(Foo)#1 (3) {
+ ["a"]=>
+ int(1)
+ ["b":protected]=>
+ int(2)
+ ["c":"Foo":private]=>
+ int(3)
+}