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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: djungowski at chipxonio dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 21:01:34 2025 UTC