~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/class_object/get_object_vars_basic_002.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
get_object_vars(): visibility from non static methods (target object passed as arg)
 
3
--FILE--
 
4
<?php
 
5
/* Prototype  : proto array get_object_vars(object obj)
 
6
 * Description: Returns an array of object properties 
 
7
 * Source code: Zend/zend_builtin_functions.c
 
8
 * Alias to functions: 
 
9
 */
 
10
 
 
11
Class A {
 
12
        private $hiddenPriv = 'A::hiddenPriv';
 
13
 
 
14
        public function testA($b) {
 
15
                echo __METHOD__ . "\n"; 
 
16
                var_dump(get_object_vars($b));
 
17
        } 
 
18
}
 
19
 
 
20
Class B extends A {
 
21
        private $hiddenPriv = 'B::hiddenPriv';  
 
22
        private $priv = 'B::priv';
 
23
        protected $prot = 'B::prot';
 
24
        public $pub = 'B::pub';
 
25
 
 
26
        public function testB($b) {
 
27
                echo __METHOD__ . "\n";         
 
28
                var_dump(get_object_vars($b));
 
29
        } 
 
30
}
 
31
 
 
32
 
 
33
$b = new B;
 
34
echo "\n---( Declaring class: )---\n";
 
35
$b->testB($b);
 
36
echo "\n---( Superclass: )---\n";
 
37
$b->testA($b);
 
38
 
 
39
?>
 
40
--EXPECTF--
 
41
 
 
42
---( Declaring class: )---
 
43
B::testB
 
44
array(4) {
 
45
  ["hiddenPriv"]=>
 
46
  string(13) "B::hiddenPriv"
 
47
  ["priv"]=>
 
48
  string(7) "B::priv"
 
49
  ["prot"]=>
 
50
  string(7) "B::prot"
 
51
  ["pub"]=>
 
52
  string(6) "B::pub"
 
53
}
 
54
 
 
55
---( Superclass: )---
 
56
A::testA
 
57
array(3) {
 
58
  ["prot"]=>
 
59
  string(7) "B::prot"
 
60
  ["pub"]=>
 
61
  string(6) "B::pub"
 
62
  ["hiddenPriv"]=>
 
63
  string(13) "A::hiddenPriv"
 
64
}
 
 
b'\\ No newline at end of file'