Bug #71359 [Ver]: Coalescing operator on classes with overridden __get() method

From: Date: Sun, 20 Mar 2016 17:39:19 +0000
Subject: Bug #71359 [Ver]: Coalescing operator on classes with overridden __get() method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199969@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71359&edit=1 ID: 71359 Updated by: nikic@php.net Reported by: kostasxx at gmail dot com Summary: Coalescing operator on classes with overridden __get() method Status: Verified Type: Bug Package: Scripting Engine problem Operating System: Linux 4.1.13 PHP Version: 7.0.2 Block user comment: N Private report: N New Comment: The root cause for this is bug #50813. Previous Comments: ------------------------------------------------------------------------ [2016-01-13 20:21:17] requinix@php.net https://3v4l.org/HBQRr ($x ?? $y) is defined as being equivalent to (isset($x) ? $x : $y) so __isset() should be getting called. ------------------------------------------------------------------------ [2016-01-13 14:57:50] kostasxx at gmail dot com Description: ------------ The issue appears when using the new null coalescing operator on object parameters, when the defined class has override the magic __get() and an error is triggered inside it. The script runs the __get() method and not the __isset(), so the error on __get() is triggered when the operator is used. Test script: --------------- http://www.pastebucket.com/97499 Expected result: ---------------- The expexted result should be not to trigger the error within the __get() method GET string(6) "value1" GET string(7) "default" Actual result: -------------- The error is triggered GET string(6) "value1" GET PHP Notice: Property attribute2 does not exist in /var/www/html/test.php on line 23 PHP Stack trace: PHP 1. {main}() /var/www/html/test.php:0 PHP 2. Coalescing->__get() /var/www/html/test.php:41 PHP 3. trigger_error() /var/www/html/test.php:23 /var/www/html/test.php:41: string(7) "default" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71359&edit=1

« previous php.bugs (#199969) next »