Req #80042 [Opn->Nab]: ArrayObject not implement magic methods, but use they

From: Date: Tue, 01 Sep 2020 08:46:48 +0000
Subject: Req #80042 [Opn->Nab]: ArrayObject not implement magic methods, but use they
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228829@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 -Status: Open +Status: Not a bug Type: Feature/Change Request Package: Class/Object related Operating System: Any PHP Version: 7.4.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#228829) next »