php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40372 Unlogical behaviour with private/public properties and __get
Submitted: 2007-02-06 14:02 UTC Modified: 2007-02-06 14:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: djungowski at chipxonio dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.0 OS: Ubuntu
Private report: No CVE-ID: None
 [2007-02-06 14:02 UTC] 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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-06 14:09 UTC] 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:16 UTC] 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:49 UTC] djungowski at chipxonio dot de
Ok, i think I have it now ;) My bad
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC