FYI, this issue is preventing PHPUnit "skipped" tests from functioning, because it compares exceptions using instanceof against a variable containing 'Throwable'.
EDIT: Changed hhvm.php.all=1 to hhvm.php7.all=1.
HipHop VM 3.15.2 (rel)
Compiler: tags/HHVM-3.15.2-0-g83ac3e5e3f5657be0cf4c55884044f86a7818b90
Repo schema: 608339137764e8365964a1adaa7a27d125b6076f
IMPORTANT: Code must be run with the INI setting hhvm.php7.all=1.
<?php
$e = new Exception();
$type = 'Throwable';
var_dump($e instanceof Throwable);
var_dump($e instanceof $type);
bool(true)
bool(true)
With the INI setting hhvm.php7.all=1:
bool(true)
bool(false)
also an issue in hhvm 3.12.0 - 3.13.2 in php7 mode
https://3v4l.org/eZYqZ
and hhvm 3.15.3-3.16.0-dev in php7 mode
@mofarrell please remove the php5 incompatibility tag as this is only a php 7 mode issue.
see this build showing the correct behavior for php5 mode with both returning false
@photodude Does that mean 3v4l.org has HHVM "PHP 7 mode" support now? How do you enable/disable it?
@ezzatron 3v4l.org has enabled HHVM's PHP 7 mode by default. Read this feature request (and please contribute to that discussion) https://3v4l.uservoice.com/forums/219058-general/suggestions/16257685-hhvm-in-php-5-mode
Briefly looked into this. It isn't just Throwable, it's all the new classes in PHP7. HHVM implements that with a parser-level aliasing mechanism into the SystemLib namespace (where the classes reside even in PHP5 mode). It looks like instanceof with a dynamic argument doesn't respect that?
<?php
echo "Exception:\n";
$e = new Exception();
$type = 'Throwable';
$type2 = '\__SystemLib\Throwable';
var_dump($e instanceof Throwable);
var_dump($e instanceof $type);
var_dump($e instanceof $type2);
echo "DivisionByZeroError:\n";
$e = new DivisionByZeroError();
$type = 'DivisionByZeroError';
$type2 = '\__SystemLib\DivisionByZeroError';
var_dump($e instanceof DivisionByZeroError);
var_dump($e instanceof $type);
var_dump($e instanceof $type2);
Exception:
bool(true)
bool(false)
bool(true)
DivisionByZeroError:
bool(true)
bool(false)
bool(true)
It's also true of all the the HH specific classes we import via the same mechanism. https://3v4l.org/lY1R1
It's a somewhat less of a big deal for the Hack-specific ones though since doing this is much less common/useful given Hack's typing system (and is totally banned in strict mode).
Problems aren't just for dynamic usages - see https://3v4l.org/fKiQ3 #6747