|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47476 Overloading does not work internally
Submitted: 2009-02-22 17:30 UTC Modified: 2013-02-18 00:33 UTC
From: nullhility at gmail dot com Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.2.8 OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: nullhility at gmail dot com
New email:
PHP Version: OS:


 [2009-02-22 17:30 UTC] nullhility at gmail dot com
I was attempting to overload some object members when I came to the realization that members defined as unaccessible from inside an object are ones that have not been initialized at all. I was attempting to call a defined but not yet set private member from a method in the class, I expected the __get definition to execute and hopefully do a late member cast but PHP saw it as accessible, this caused a problem because the method was calling a NULL value.

The way I see it is that a NULL, aside from still being a value itself, is pretty inaccessible as an actual value. My main concern is that calling an undefined member returns NULL but is also defined as inaccessible, yet calling a defined (but unset/not set) private/protected from within the object, though returning null, is accessible.

In the end I know it's about scope and correctness, but is this issue up for change?

Reproduce code:

Expected result:
Hello World!
Hello Universe!
Hello Everyone!

Actual result:
Hello World!

Hello Everyone!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-22 19:34 UTC] nullhility at gmail dot com
I re-evaluated the problem itself and found that the magic methods for overloading aren't called automatically from "inside" the object if the member has been initialized in the class regardless of access.

I've made two examples of this "internal" call to overloading behavior, the first works, the second does not but the average user would expect it to.

calls the magic methods directly:

expects the magic methods to be called directly:
 [2011-04-08 20:39 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Class/Object related
 [2011-04-08 20:39 UTC]
Your pastebin stuff isn't available anymore, please put the examples straight into this report.
 [2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 12:01:28 2024 UTC