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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Sat Apr 20 05:01:27 2024 UTC