Permalink
Browse files

Explicit intish casts in reflection extension

Summary: What is says on the tin--

Reviewed By: mxw

Differential Revision: D13221249

fbshipit-source-id: 01b75e6a169194709b04d7fa4e217bdbf3576b4b
  • Loading branch information...
jjgriego authored and hhvm-bot committed Dec 1, 2018
1 parent 49a8342 commit 3e2fad26f3e714cdc0effe6b997b63a9265c829a
@@ -397,8 +397,10 @@ bool AutoloadHandler::autoloadClassPHP5Impl(const String& className,
// rely on it unless we are forcing a restart (due to spl_autoload_call)
// in which case autoload is allowed to be reentrant.
if (!forceSplStack) {
if (m_loading.exists(className)) { return false; }
m_loading.set(className, className);
const auto arrkey =
m_loading.convertKey<IntishCast::CastSilently>(className);
if (m_loading.exists(arrkey)) { return false; }
m_loading.set(arrkey, make_tv<KindOfString>(className.get()));
} else {
// We can still overflow the stack if there is a loop when using
// spl_autoload_call directly, but this behavior matches PHP5.
@@ -1760,7 +1760,9 @@ static void HHVM_METHOD(ReflectionProperty, __construct,
auto obj = cls_or_obj.toCObjRef().get();
assertx(cls == obj->getVMClass());
if (obj->getAttribute(ObjectData::HasDynPropArr) &&
obj->dynPropArray().exists(prop_name)) {
obj->dynPropArray().exists(
obj->dynPropArray().convertKey<IntishCast::CastSilently>(prop_name))
){
if (RuntimeOption::EvalNoticeOnReadDynamicProp) {
obj->raiseReadDynamicProp(prop_name.get());
}
@@ -0,0 +1,24 @@
<?hh
<<__EntryPoint>>
function main () {
try {
var_dump(new ReflectionClass('42'));
} catch (Exception $e) {}
var_dump(call_user_func(varray['42', 'foo']));
$x = new stdClass();
$x->{42} = 'foo';
try {
var_dump((new ReflectionObject($x))->getProperties());
} catch (Exception $e) {
var_dump($e->getMessage());
}
try {
var_dump((new ReflectionProperty($x, '42')));
} catch (Exception $e) {
var_dump($e->getMessage());
}
}
@@ -0,0 +1,5 @@
Warning: Invalid argument: function: class not found in %s on line %d
NULL
string(36) "Property stdClass::42 does not exist"
string(36) "Property stdClass::42 does not exist"
@@ -0,0 +1,2 @@
-vRuntime.Eval.HackArrCompatCheckIntishCast=1
-vRuntime.Eval.HackArrCompatNotices=true -d hhvm.php7.all=0
@@ -0,0 +1,2 @@
-vEval.HackArrCompatNotices=true
-vEval.HackArrCompatCheckIntishCast=1

0 comments on commit 3e2fad2

Please sign in to comment.