Created
May 5, 2014 22:09
-
-
Save jwoschitz/bba710a35418e701636d to your computer and use it in GitHub Desktop.
Workaround for get_parent_class in hhvm if spl_autoloader is used
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
spl_autoload_register(function ($class) { | |
// in hhvm, this will not get executed | |
include 'parent_file.php'; | |
}); | |
// this will return false in hhvm due to https://github.com/facebook/hhvm/issues/2097 | |
var_dump(get_parent_class('C')); | |
// this works in hhvm (should be considered only as a temp workaround) | |
// see https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/ext_spl.cpp#L173 for implementation details | |
var_dump(array_shift(class_parents('C'))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class B {} | |
class C extends B {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment