fix callble typehint in interp mode
Somehow the JIT doesn't hit this codepath, but with interp mode the param is a string, but we think `callable` means an object of type callable. I hate to hadd another top-level if statement to every call. Would a switch statement on the type be better?
Esse commit está contido em:
@@ -182,9 +182,14 @@ TypeConstraint::check(const TypedValue* tv, const Func* func) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isObjectOrTypedef() && !isCallable()
|
||||
? checkTypedefNonObj(tv)
|
||||
: equivDataTypes(m_type.m_dt, tv->m_type);
|
||||
if (isObjectOrTypedef()) {
|
||||
if (isCallable()) {
|
||||
return f_is_callable(tvAsCVarRef(tv));
|
||||
}
|
||||
return checkTypedefNonObj(tv);
|
||||
}
|
||||
|
||||
return equivDataTypes(m_type.m_dt, tv->m_type);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -5,9 +5,19 @@ function check($f) {
|
||||
var_dump(is_callable($f));
|
||||
}
|
||||
|
||||
function typehint(callable $a) {
|
||||
var_dump('worked');
|
||||
}
|
||||
|
||||
function id() {}
|
||||
|
||||
function main() {
|
||||
check('');
|
||||
check('main');
|
||||
check('id');
|
||||
check('blarblah');
|
||||
|
||||
$cl = function() { return 'closure'; };
|
||||
typehint($cl);
|
||||
typehint('id');
|
||||
}
|
||||
main();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
string(0) ""
|
||||
bool(false)
|
||||
string(4) "main"
|
||||
string(2) "id"
|
||||
bool(true)
|
||||
string(8) "blarblah"
|
||||
bool(false)
|
||||
string(6) "worked"
|
||||
string(6) "worked"
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário