|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80042 ArrayObject should implement magic methods
Submitted: 2020-08-31 19:20 UTC Modified: 2020-09-01 09:55 UTC
From: antonfedonyuk at gmail dot com Assigned:
Status: Suspended Package: Class/Object related
PHP Version: Next Minor Version OS: Any
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: antonfedonyuk at gmail dot com
New email:
PHP Version: OS:


 [2020-08-31 19:20 UTC] antonfedonyuk at gmail dot com
Example show: $ao don't have public properties, object not implements method __get, but "magic" still work.

Test script:
$ao = new ArrayObject(['foo' => 'bar'], ArrayObject::ARRAY_AS_PROPS);
// []
var_dump(method_exists($ao, '__get'));
// false
// "bar"

Expected result:
Test object $ao must have public property "foo" or implements magic methods(__get, __set", __isset, __unset) to overloading that property.

Actual result:
get_object_vars($ao); // []
method_exists($ao, '__get'); // false
$ao->foo; // "bar"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-01 08:46 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-09-01 08:46 UTC]
Internal objects do not need to implement the magic functions,
because there are other mechanisms available. If you want to check
whether a certain property is set, use isset();
<> looks fined to me.
 [2020-09-01 09:39 UTC] antonfedonyuk at gmail dot com "other mechanisms available"
I'm know, but it's:
1.not reflectable
2.unexpected results of function calls
3.created problems at extending class

as totaly:
 [2020-09-01 09:55 UTC]
-Summary: ArrayObject not implement magic methods, but use they +Summary: ArrayObject should implement magic methods -Status: Not a bug +Status: Suspended -PHP Version: 7.4.9 +PHP Version: Next Minor Version -Assigned To: cmb +Assigned To:
 [2020-09-01 09:55 UTC]
Okay, it may be an option to change the implementation in the next
minor or major release.  However, that requires discussion which
is beyond the scope of this bug tracker (there are several other
internal classes which behave similar).  Therefore, please write
mail to the internals mailing list[1].  For the time being, I'm
suspending this ticket.

[1] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 29 11:01:24 2023 UTC