php.net |  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
Have you experienced this issue?
Rate the importance of this bug to you:

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

Test script:
---------------
<?php
$ao = new ArrayObject(['foo' => 'bar'], ArrayObject::ARRAY_AS_PROPS);
var_dump(get_object_vars($ao));
// []
var_dump(method_exists($ao, '__get'));
// false
var_dump($ao->foo);
// "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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-01 08:46 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-09-01 08:46 UTC] cmb@php.net
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();
<https://3v4l.org/6emoD> looks fined to me.
 [2020-09-01 09:39 UTC] antonfedonyuk at gmail dot com
cmb@php.net "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] cmb@php.net
-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] cmb@php.net
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] <https://www.php.net/mailing-lists.php#internals>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC