#40372 [Opn->Bgs]: Unlogical behaviour with private/public properties and __get
ID: 40372
Updated by: derick@php.net
Reported By: djungowski at chipxonio dot de
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Ubuntu
PHP Version: 5.2.0
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
.
Previous Comments:
------------------------------------------------------------------------
[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)