Rowan Collins wrote:

> On 24/07/2015 09:21, Xinchen Hui wrote:
>>
>>      I made a small PR about changes output of some types name in
>> debug_zval_dump, to make it behavior consistently with var_dump.
>> https://github.com/php/php-src/pull/1434
> 
> That function desperately needs an updated manual page. The current one
> recommends using call-time pass-by-reference (impossible since 5.4), and
> the changes to zvals in PHP 7 make its behaviour completely different
> from anything in PHP 5.

I agree that the manual page needs an update, but it seems that would
result in an even more lengthy explanation of the caveats due to the
different behavior under PHP 5 and PHP 7, respectively.

> I've thought before that it might be best to simply deprecate it,
> because the only information it gives is a highly questionable refcount
> - though playing around, it seems to be less influenced by the act of
> calling the function in PHP 7.

It seems to me that the basic issue of debug_zval_dump() is that it is a
function and not a language construct, so the refcounts are never "quite
right".  The variadic nature of the function may add to the confusion,
see <http://3v4l.org/UuRse>.

> For instance, an IS_REFERENCE zval could be shown as such, with a
> separate refcount from the referenced value, so that you could follow
> along with the examples in this blog post:
> http://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1
> The current implementation just adds 1 to the target refcount, per this
> experiment: http://3v4l.org/NejOM

Apparently, this has been done deliberately for compatibility reasons[1].

[1]
<https://github.com/php/php-src/blob/php-7.0.0beta2/ext/standard/var.c#L357-L363>

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to