Edit report at https://bugs.php.net/bug.php?id=71359&edit=1
ID: 71359
Comment by: arjen at react dot com
Reported by: kostasxx at gmail dot com
Summary: Coalescing operator on classes with overridden
__get() method
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux 4.1.13
PHP Version: 7.0.2
Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
This is only fixed in master, what about 7.0?
See https://bugs.php.net/bug.php?id=50813 and https://github.com/php/php-src/commit/373da7aa6f5e7bf57d434fd449f97770fb479d3e
Similar issue when using ?? and offsetSet/offsetExists and ArrayAccess
(https://bugs.php.net/bug.php?id=71731) has been fixed in 7.0.
Previous Comments:
------------------------------------------------------------------------
[2016-03-26 11:11:55] krakjoe@php.net
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2016-03-20 17:39:18] nikic@php.net
The root cause for this is bug #50813.
------------------------------------------------------------------------
[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