summaryrefslogtreecommitdiff
path: root/tests/classes/private_members.phpt
blob: 1832ea0c437f67a7609e200e3cea842367203aed (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--TEST--
ZE2 A private member is 
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php

class base
{
  private $member;

  function __construct()
  {
  	echo __METHOD__ . "(begin)\n";
    $this->member = 'base::member';
    $this->test();
  	echo __METHOD__ . "(end)\n";
  }

  function test()
  {
  	echo __METHOD__ . "\n";
    print_r($this);
  }
}

class derived extends base
{
  public $member = 'derived::member (default)';

  function __construct()
  {
  	echo __METHOD__ . "(begin)\n";
  	parent::__construct();
  	parent::test();
  	$this->test();
    $this->member = 'derived::member';
  	echo __METHOD__ . "(end)\n";
  }

  function test()
  {
  	parent::test();
  	echo __METHOD__ . "\n";
    print_r($this);
  }
}

$t = new derived;
$t->test();
unset($t);

echo "Done\n";

?>
--EXPECTF--
derived::__construct(begin)
base::__construct(begin)
base::test
derived Object
(
    [member] => derived::member (default)
    [member:private] => base::member
)
derived::test
derived Object
(
    [member] => derived::member (default)
    [member:private] => base::member
)
base::__construct(end)
base::test
derived Object
(
    [member] => derived::member (default)
    [member:private] => base::member
)
base::test
derived Object
(
    [member] => derived::member (default)
    [member:private] => base::member
)
derived::test
derived Object
(
    [member] => derived::member (default)
    [member:private] => base::member
)
derived::__construct(end)
base::test
derived Object
(
    [member] => derived::member
    [member:private] => base::member
)
derived::test
derived Object
(
    [member] => derived::member
    [member:private] => base::member
)
Done