Req #80042 [Nab->Sus]: ArrayObject should implement magic methods

From: Date: Tue, 01 Sep 2020 09:55:20 +0000
Subject: Req #80042 [Nab->Sus]: ArrayObject should implement magic methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228832@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80042&edit=1 ID: 80042 Updated by: cmb@php.net Reported by: antonfedonyuk at gmail dot com -Summary: ArrayObject not implement magic methods, but use they +Summary: ArrayObject should implement magic methods -Status: Not a bug +Status: Suspended Type: Feature/Change Request Package: Class/Object related Operating System: Any -PHP Version: 7.4.9 +PHP Version: Next Minor Version -Assigned To: cmb +Assigned To: Block user comment: N Private report: N New Comment: 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> Previous Comments: ------------------------------------------------------------------------ [2020-09-01 09:39:56] 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 08:46:48] 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-08-31 19:20:22] 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" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80042&edit=1

« previous php.bugs (#228832) next »