ID:               24543
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dafrancesch at yahoo dot com dot ar
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Win2000
 PHP Version:      5CVS-2003-07-08 (dev)
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You're wrong about other languages.

A derived class knows nothing about private members of inherited
classes.

Now reconsider your expectations.


Previous Comments:
------------------------------------------------------------------------

[2003-07-08 13:23:50] dafrancesch at yahoo dot com dot ar

Description:
------------
Accessing private or protected members from outside a class generate
errors like:
Fatal error: Cannot access private property a::$vProtected in
C:\www\test\php5\class.php on line xx
While accessing a private member of A from B does not. (see the example
for classes A and B)


I'm using the the Win32 snapshot 200307081030


Reproduce code:
---------------
http://www.agendamagica.com.ar/php5/class.php.html

Expected result:
----------------
I expect one of these situations:

1. A warning when you try to access a private member of A from B, and
when you try to access private or protected member form outside the
class.

[[ Error in cosntructor of B, accessing A::vPrivate1 ]]
A::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in A]
::vPrivate2 = [Set in A]

B::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in B]  <<-- Error accessing A::vPrivate1
::vPrivate2 = []          <<-- Error accessing A::vPrivate2
::vPrivate3 = [Set in B]

Show $vB
vB->vAny = []
vB->vPublic = [Set in B]
vB->vPrivate1 = [Set in B] <<-- Error accessing A::vPrivate1
vB->vPrivate2 = []         <<-- Error accessing A::vPrivate2
vB->vPrivate3 = []         <<-- Error accessing B::vPrivate3
vB->vProtected = []       <<-- Error accessing A::vProtected


2. the actual behavior inside a class, and display nothing from outside
the class (as described in http://www.php.net/zend-engine-2.php)

A::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in A]
::vPrivate2 = [Set in A]

B::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in B]
::vPrivate2 = []
::vPrivate3 = [Set in B]

Show $vB
vB->vAny = []
vB->vPublic = [Set in B]
vB->vPrivate1 = [Set in B]
vB->vPrivate2 = []
vB->vPrivate3 = []
vB->vProtected = []


The first one is preferable, and is likely other OO Lenguages.


Actual result:
--------------
A::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in A]
::vPrivate2 = [Set in A]

B::show()
::vPublic = [Set in B]
::vProtected = [Set in B]
::vPrivate1 = [Set in B]
::vPrivate2 = []
::vPrivate3 = [Set in B]

Show $vB
vB->vAny = []
vB->vPublic = [Set in B]
vB->vPrivate1 = [Set in B]
vB->vPrivate2 = []

Fatal error: Cannot access private property b::$vPrivate3 in
C:\www\test\php5\class.php on line 53



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24543&edit=1

Reply via email to