Conversion of SplFileInfo instances to boolean

From: Date: Wed, 03 Dec 2014 20:35:41 +0000
Subject: Conversion of SplFileInfo instances to boolean
Groups: php.internals 
Request: Send a blank email to internals+get-79399@lists.php.net to get a copy of this message
Hello internals, today I stumbled over issue #65213[1] which has been reported as a bug, but was changed to a feature request without any hint why the conversion of SplFileInfo instances to boolean throws a catchable fatal error. Even worse, due to optimizations in OPcache (and maybe other optimizers as well), this does not always happen. Consider the following snippet: <?php $o = new SplFileObject('.'); if (!$o) { } else { var_dump(!$o); } Without any optimization this throws the error in line 4 (the if clause); with OPcache the error is thrown in line 6. Apparently that is caused by a optimization where BOOL_NOT,JMPZ is converted to NOP,JMPNZ[2]. IOW: with OPcache enabled if (!$o) works fine, but without OPcache it is an error. IMHO both should behave identically. [1] <https://bugs.php.net/bug.php?id=65213> [2] <http://lxr.php.net/xref/PHP_5_5/ext/opcache/Optimizer/block_pass.c#816> -- Christoph M. Becker

« previous php.internals (#79399) next »