In php 8.0: unable to distinguish between instance variable being null and unset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Our codebase depends on distinguishing whether an instance variable is unset, or simply null:

class C { public int $v = 123; }
$x = new C; unset($x->v);
$y = new C; $u->v = null;

In php <8.0 we made this work with @array_key_exists($x, 'v'), which stopped working. isset($x->x) doesn't work, as it will return true for 'null' as well. property_exists($x, 'v') will always return true as long as the variable is declared: php-src here.

Apart from using debug_zval_dump (too expensive), any hints? This feels like quite the oversight honestly :).

Best,

Emiel

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux