#40372 [Bgs->Csd]: Unlogical behaviour with private/public properties and __get
ID: 40372
User updated by: djungowski at chipxonio dot de
Reported By: djungowski at chipxonio dot de
-Status: Bogus
+Status: Closed
Bug Type: Class/Object related
Operating System: Ubuntu
PHP Version: 5.2.0
New Comment:
Ok, i think I have it now ;) My bad
Previous Comments:
------------------------------------------------------------------------
[2007-02-06 14:16:28] djungowski at chipxonio dot de
Redeclaring a private property as public is a heavy security issue and
should not be permitted if you ask me...
------------------------------------------------------------------------
[2007-02-06 14:10:32] tony2001@php.net
See http://www.php.net/manual/en/language.oop5.overloading.php
------------------------------------------------------------------------
[2007-02-06 14:09:40] derick@php.net
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
.
------------------------------------------------------------------------
[2007-02-06 14:02:32] djungowski at chipxonio dot de
Description:
------------
__get() does not seem to work properly when predeclaring the property
When declared as public, __get isn't referenced, private properties are
being redeclared as public!
Reproduce code:
---------------
class param
{
public $a;
private $b;
function __get($memberName)
{
switch($memberName)
{
case 'a':
$var = 'a';
break;
case 'b':
$var = 'b';
break;
}
return $var;
}
}
$p = new param();
$a = $p->a;
$b = $p->b;
Expected result:
----------------
$a = 'a'
$b should throw an error, since param->b has been declared as private
Actual result:
--------------
$a = ''
$b = 'b'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40372&edit=1
Thread (6 messages)