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

From: Date: Tue, 06 Feb 2007 14:51:24 +0000
Subject: #40372 [Csd->Bgs]: Unlogical behaviour with private/public properties and __get
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-108491@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:           Closed
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Ubuntu
 PHP Version:      5.2.0


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

[2007-02-06 14:49:37] djungowski at chipxonio dot de

Ok, i think I have it now ;) My bad

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

[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)

« previous php.bugs (#108491) next »