#40372 [Bgs]: Unlogical behaviour with private/public properties and __get

From: Date: Tue, 06 Feb 2007 14:10:32 +0000
Subject: #40372 [Bgs]: Unlogical behaviour with private/public properties and __get
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-108488@lists.php.net to get a copy of this message
ID: 40372 Updated by: tony2001@php.net Reported By: djungowski at chipxonio dot de Status: Bogus Bug Type: Class/Object related Operating System: Ubuntu PHP Version: 5.2.0 New Comment: See http://www.php.net/manual/en/language.oop5.overloading.php Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#108488) next »