#31788 [Opn->WFx]: __get, __set, __call etc cannot be set private

From: Date: Tue, 01 Feb 2005 08:25:17 +0000
Subject: #31788 [Opn->WFx]: __get, __set, __call etc cannot be set private
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73177@lists.php.net to get a copy of this message
 ID:               31788
 Updated by:       derick@php.net
 Reported By:      davey@php.net
-Status:           Open
+Status:           Wont fix
-Bug Type:         Zend Engine 2 problem
+Bug Type:         Feature/Change Request
 Operating System: Irrelevant
 PHP Version:      5.0.3
 New Comment:

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. 


Previous Comments:
------------------------------------------------------------------------

[2005-02-01 03:25:44] 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 />


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31788&edit=1


Thread (2 messages)

« previous php.bugs (#73177) next »