Req #80042 [Com]: ArrayObject not implement magic methods, but use they

From: Date: Tue, 01 Sep 2020 09:39:56 +0000
Subject: Req #80042 [Com]: ArrayObject not implement magic methods, but use they
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228831@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 Comment by: antonfedonyuk at gmail dot com Reported by: antonfedonyuk at gmail dot com Summary: ArrayObject not implement magic methods, but use they Status: Not a bug Type: Feature/Change Request Package: Class/Object related Operating System: Any PHP Version: 7.4.9 Assigned To: cmb Block user comment: N Private report: N New Comment: 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: Previous Comments: ------------------------------------------------------------------------ [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 (#228831) next »