php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31788 __get, __set, __call etc cannot be set private
Submitted: 2005-02-01 03:25 UTC Modified: 2005-02-01 09:25 UTC
From: davey@php.net Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.3 OS: Irrelevant
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davey@php.net
New email:
PHP Version: OS:

 

 [2005-02-01 03:25 UTC] davey@php.net
Description:
------------
The magic methods __get, __set, __call and __clone (and maybe others too) cannot be set as private methods when clearly, this is what they should be. They should not be called from outside of the object except by the engine which shouldn't count.

Allowing public access to these could cause users to start using them.

- Davey

Reproduce code:
---------------
<?php

class foo {
    private function __get($var)
    {
        echo __FUNCTION__ . ' called';
    }
}

$foo = new foo;

$foo->bar;

?>

Expected result:
----------------
__get called

Actual result:
--------------
<b>Fatal error</b>:  Call to private method foo::__get() from context '' in <b>PHPDocument2</b> on line <b>22</b><br />

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-01 09:25 UTC] derick@php.net
Not a bug, this is how it was meant. Changing to a Feature Request and close it as "Wont fix" as changing this will break scripts. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 03:01:30 2024 UTC