Bug #72223 [Opn->Nab]: regression with _isset, __get call precedence

From: Date: Mon, 16 May 2016 15:15:00 +0000
Subject: Bug #72223 [Opn->Nab]: regression with _isset, __get call precedence
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201132@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72223&edit=1

 ID:                 72223
 Updated by:         requinix@php.net
 Reported by:        koubel at seznam dot cz
 Summary:            regression with _isset, __get call precedence
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   Linux
 PHP Version:        7.0.6
 Block user comment: N
 Private report:     N

 New Comment:

The fact that __isset was not being called before was a bug. This is a bug fix.
See bug #72117.


Previous Comments:
------------------------------------------------------------------------
[2016-05-16 15:09:49] koubel at seznam dot cz

Hmm, it seems that without any __isset it works fine.
In real case we inherit from "generic" __isset from other library. 
I still thinking it's BC break and needs to be documented in migration guide.

------------------------------------------------------------------------
[2016-05-16 14:46:08] koubel at seznam dot cz

So, maybe it's related with fix mentioned in https://bugs.php.net/bug.php?id=72117. It means
that

function __isset($property) {
 return $property == "arr";
}

fixed this bug.

But this one isn't mentioned case. Caller know that magic property exists and it's array.
Returning this array and call isset on it is expected. Implement __isset doesn't make any sense
in this case.

If you want to keep new behaviour, it's necessary to mention it on documentation on magic
properties and also in migration with from 5.6.x to 7.0.x, because it's BC break.

------------------------------------------------------------------------
[2016-05-16 13:00:20] koubel at seznam dot cz

Description:
------------
When we wanted migrate from PHP 5 to PHP 7 (7.0.6), we hitted BC break with __isset and __get call
precedence. It stops migration, because we have a tons of lines with
isset($instance->magicProperty["index")) calls.

There is also no mention about this break in documentation.

P.S. According https://3v4l.org/ka9na, it seems that something
changed in PHP 7.0.6, 7.0.5 works fine.

Test script:
---------------
class IsGet {
	private $arr = [1 => 1, 2 => 2, 3 => 3];

	function &__get($property) {
		echo "__get\n";
		return $this->arr;
	}

	function __isset($property) {
		echo "__isset\n";
		return false;
	}
}

$instance = new IsGet();
var_dump(isset($instance->arr[1]));


Expected result:
----------------
__get
bool(true)

Actual result:
--------------
__isset
bool(false)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72223&edit=1


Thread (5 messages)

« previous php.bugs (#201132) next »