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

From: Date: Sat, 26 Mar 2016 11:11:59 +0000
Subject: Bug #71359 [Ver->Csd]: Coalescing operator on classes with overridden __get() method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200104@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:         krakjoe@php.net
 Reported by:        kostasxx at gmail dot com
 Summary:            Coalescing operator on classes with overridden
                     __get() method
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux 4.1.13
 PHP Version:        7.0.2
-Assigned To:        
+Assigned To:        krakjoe
 Block user comment: N
 Private report:     N

 New Comment:

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.




Previous Comments:
------------------------------------------------------------------------
[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


Thread (15 messages)

« previous php.bugs (#200104) next »