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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
18 + 28 = ?
Subscribe to this entry?

 
 [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 10:01:31 2024 UTC