|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71359 Coalescing operator on classes with overridden __get() method
Submitted: 2016-01-13 14:57 UTC Modified: 2016-06-15 07:19 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: kostasxx at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.2 OS: Linux 4.1.13
Private report: No CVE-ID: None
 [2016-01-13 14:57 UTC] kostasxx at gmail dot com
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:

Expected result:
The expexted result should be not to trigger the error within the __get() method

string(6) "value1"
string(7) "default"

Actual result:
The error is triggered

string(6) "value1"
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
string(7) "default"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-13 20:21 UTC]
-Status: Open +Status: Verified
 [2016-01-13 20:21 UTC]

($x ?? $y) is defined as being equivalent to (isset($x) ? $x : $y) so __isset() should be getting called.
 [2016-03-20 17:39 UTC]
The root cause for this is bug #50813.
 [2016-03-26 11:11 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2016-03-26 11:11 UTC]
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

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2016-04-01 13:44 UTC] arjen at react dot com
This is only fixed in master, what about 7.0?

See and

Similar issue when using ?? and offsetSet/offsetExists and ArrayAccess ( has been fixed in 7.0.
 [2016-04-01 14:51 UTC]
It was merged into 7.0 too.
 [2016-04-04 08:05 UTC] arjen at react dot com
Then it's not in the NEWS file ;)
 [2016-04-04 08:23 UTC]
My commits are bad, and I feel bad ... added ;)
 [2016-06-15 03:12 UTC] frej dot akki at gmail dot com
this bug has been resurfaced in 7.0.6/7
 [2016-06-15 05:40 UTC]
I don't see it:
 [2016-06-15 07:05 UTC] kostasxx at gmail dot com
It isn't exactly the same error. The error appears when __isset() is not defined. Then, it executes first __get() before native isset().

See here:
 [2016-06-15 07:08 UTC]
Open a new report please, someone will look at it.
 [2016-06-15 07:14 UTC] kostasxx at gmail dot com
I don't think it needs another issue. It's still the same, in different approach.
The first code example I used had, besides __get(), the __isset() method overridden. That part of the bug is, indeed, fixed.
The issue still occurs when the __isset() is not overridden. So, the bug that is related to __get() override still, partially, exists.

See here please:

Thanks :)
 [2016-06-15 07:19 UTC]
It's a related, but different issue.
 [2016-06-15 07:21 UTC] kostasxx at gmail dot com
OK. I will create a new issue.

Thanks again
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC