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:
Paul Tarjan
2013-05-23 16:18:28 -07:00
commit de sgolemon
commit ae4d1a0def
3 arquivos alterados com 22 adições e 5 exclusões
+8 -3
Ver Arquivo
@@ -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
+11 -1
Ver Arquivo
@@ -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();
+3 -1
Ver Arquivo
@@ -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"