Use name to be consistent with Zend in backtraces

Generators should specify function names as the name instead of the
full name for consistency with Zend 5.5 (and more importantly because
this breaks PHPUnit), this was exposed by the backtrace removal of
file and line info
Esse commit está contido em:
seanc
2013-04-10 17:33:04 -07:00
commit de Sara Golemon
commit 0840deb71a
14 arquivos alterados com 169 adições e 24 exclusões
+14
Ver Arquivo
@@ -4180,6 +4180,13 @@ class ReflectionFunctionAbstract {
}
return $count;
}
public function getReturnTypehintText() {
if (isset($this->info['return_type'])) {
return $this->info['return_type'];
}
return '';
}
}
///////////////////////////////////////////////////////////////////////////////
@@ -5415,6 +5422,13 @@ class ReflectionProperty implements Reflector {
public function getDocComment() {
return $this->info['doc'];
}
public function getTypehintText() {
if (isset($this->info['type'])) {
return $this->info['type'];
}
return '';
}
}
///////////////////////////////////////////////////////////////////////////////
+8
Ver Arquivo
@@ -351,6 +351,14 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => 'getCalledClass',
'return' => array(
'type' => String,
),
));
DefineFunction(
array(
'name' => '__clone',
+7 -13
Ver Arquivo
@@ -155,26 +155,20 @@ void c_Continuation::t_raised() {
}
String c_Continuation::t_getorigfuncname() {
return m_origFuncName;
}
String c_Continuation::t_getcalledclass() {
String called_class;
if (actRec()->hasThis()) {
called_class = actRec()->getThis()->getVMClass()->name()->data();
} else if (actRec()->hasClass()) {
called_class = actRec()->getClass()->name()->data();
}
if (called_class.size() == 0) {
return m_origFuncName;
} else {
called_class = String("");
}
/*
Replace the class name in m_origFuncName with the LSB class. This
produces more useful traces.
*/
size_t method_pos = m_origFuncName.find("::");
if (method_pos != std::string::npos) {
return concat3(called_class, "::", m_origFuncName.substr(method_pos+2));
} else {
return m_origFuncName;
}
return called_class;
}
Variant c_Continuation::t___clone() {
@@ -728,6 +728,44 @@ TypedValue* tg_12Continuation_getOrigFuncName(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::String HPHP::c_Continuation::t_getcalledclass()
_ZN4HPHP14c_Continuation16t_getcalledclassEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_12Continuation_getCalledClass(Value* _rv, ObjectData* this_) asm("_ZN4HPHP14c_Continuation16t_getcalledclassEv");
TypedValue* tg_12Continuation_getCalledClass(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfString;
th_12Continuation_getCalledClass((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Continuation::getCalledClass", 0, 1);
}
} else {
throw_instance_method_fatal("Continuation::getCalledClass");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Variant HPHP::c_Continuation::t___clone()
_ZN4HPHP14c_Continuation9t___cloneEv
+1
Ver Arquivo
@@ -61,6 +61,7 @@ class c_Continuation : public ExtObjectData {
public: void t_raise(CVarRef v);
public: void t_raised();
public: String t_getorigfuncname();
public: String t_getcalledclass();
public: Variant t___clone();
static c_Continuation* alloc(VM::Class* cls, int nLocals, int nIters) {
+3 -1
Ver Arquivo
@@ -2455,6 +2455,7 @@ TypedValue* tg_12Continuation_valid(VM::ActRec *ar);
TypedValue* tg_12Continuation_send(VM::ActRec *ar);
TypedValue* tg_12Continuation_raise(VM::ActRec *ar);
TypedValue* tg_12Continuation_getOrigFuncName(VM::ActRec *ar);
TypedValue* tg_12Continuation_getCalledClass(VM::ActRec *ar);
TypedValue* tg_12Continuation___clone(VM::ActRec *ar);
VM::Instance* new_DummyContinuation_Instance(VM::Class*);
TypedValue* tg_17DummyContinuation___construct(VM::ActRec *ar);
@@ -5545,7 +5546,7 @@ static const HhbcExtMethodInfo hhbc_ext_methods_PairIterator[] = {
{ "rewind", tg_12PairIterator_rewind }
};
static const long long hhbc_ext_method_count_Continuation = 16;
static const long long hhbc_ext_method_count_Continuation = 17;
static const HhbcExtMethodInfo hhbc_ext_methods_Continuation[] = {
{ "__construct", tg_12Continuation___construct },
{ "update", tg_12Continuation_update },
@@ -5562,6 +5563,7 @@ static const HhbcExtMethodInfo hhbc_ext_methods_Continuation[] = {
{ "send", tg_12Continuation_send },
{ "raise", tg_12Continuation_raise },
{ "getOrigFuncName", tg_12Continuation_getOrigFuncName },
{ "getCalledClass", tg_12Continuation_getCalledClass },
{ "__clone", tg_12Continuation___clone }
};
+1 -1
Ver Arquivo
@@ -6699,7 +6699,7 @@ VMExecutionContext::createContinuation(ActRec* fp,
}
static const StringData* closure = StringData::GetStaticString("{closure}");
const StringData* origName =
origFunc->isClosureBody() ? closure : origFunc->fullName();
origFunc->isClosureBody() ? closure : origFunc->name();
int nLocals = genFunc->numLocals();
int nIters = genFunc->numIterators();
Class* genClass = SystemLib::s_ContinuationClass;
+5
Ver Arquivo
@@ -22021,6 +22021,11 @@ const char *g_class_map[] = {
(const char *)0x14, NULL,
NULL,
NULL,
(const char *)0x10006040, "getCalledClass", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/continuation.getcalledclass.php\n * )\n *\n *\n * @return string\n */",
(const char *)0x14, NULL,
NULL,
NULL,
(const char *)0x10006040, "__clone", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/continuation.clone.php )\n *\n *\n * @return mixed\n */",
(const char *)0xffffffff, NULL,
+1 -1
Ver Arquivo
@@ -6,7 +6,7 @@
#elif EXT_TYPE == 1
#elif EXT_TYPE == 2
"Continuation", "", "iterator","awaitable",NULL, "__construct", T(Void), S(0), "func", T(Int64), NULL, S(0), NULL, S(0), "origFuncName", T(String), NULL, S(0), NULL, S(0), "obj", T(Variant), "N;", S(2), "null", S(0), "args", T(Array), "N;", S(2), "null", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.construct.php )\n *\n *\n * @func int\n * @origFuncName\n * string\n * @obj mixed\n * @args map\n */", S(16384),"update", T(Void), S(0), "label", T(Int64), NULL, S(0), NULL, S(0), "value", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.update.php )\n *\n *\n * @label int\n * @value mixed\n */", S(16384),"getWaitHandle", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getwaithandle.php )\n *\n * Start asynchronous execution of this Continuation and return the wait\n * handle\n *\n * @return object\n */", S(16384),"getLabel", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getlabel.php )\n *\n *\n * @return int\n */", S(16384),"num_args", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.num-args.php )\n *\n *\n * @return int\n */", S(16384),"get_args", T(Array), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.get-args.php )\n *\n *\n * @return vector\n */", S(16384),"get_arg", T(Variant), S(0), "id", T(Int64), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.get-arg.php )\n *\n *\n * @id int\n *\n * @return mixed\n */", S(16384),"current", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.current.php )\n *\n *\n * @return mixed\n */", S(16384),"key", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.key.php )\n *\n *\n * @return int\n */", S(16384),"next", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.next.php )\n *\n *\n */", S(16384),"rewind", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.rewind.php )\n *\n *\n */", S(16384),"valid", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.valid.php )\n *\n *\n * @return bool\n */", S(16384),"send", T(Void), S(0), "v", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.send.php )\n *\n *\n * @v mixed\n */", S(16384),"raise", T(Void), S(0), "v", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.raise.php )\n *\n *\n * @v mixed\n */", S(16384),"getOrigFuncName", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getorigfuncname.php\n * )\n *\n *\n * @return string\n */", S(16384),"__clone", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.clone.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
"Continuation", "", "iterator","awaitable",NULL, "__construct", T(Void), S(0), "func", T(Int64), NULL, S(0), NULL, S(0), "origFuncName", T(String), NULL, S(0), NULL, S(0), "obj", T(Variant), "N;", S(2), "null", S(0), "args", T(Array), "N;", S(2), "null", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.construct.php )\n *\n *\n * @func int\n * @origFuncName\n * string\n * @obj mixed\n * @args map\n */", S(16384),"update", T(Void), S(0), "label", T(Int64), NULL, S(0), NULL, S(0), "value", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.update.php )\n *\n *\n * @label int\n * @value mixed\n */", S(16384),"getWaitHandle", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getwaithandle.php )\n *\n * Start asynchronous execution of this Continuation and return the wait\n * handle\n *\n * @return object\n */", S(16384),"getLabel", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getlabel.php )\n *\n *\n * @return int\n */", S(16384),"num_args", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.num-args.php )\n *\n *\n * @return int\n */", S(16384),"get_args", T(Array), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.get-args.php )\n *\n *\n * @return vector\n */", S(16384),"get_arg", T(Variant), S(0), "id", T(Int64), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.get-arg.php )\n *\n *\n * @id int\n *\n * @return mixed\n */", S(16384),"current", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.current.php )\n *\n *\n * @return mixed\n */", S(16384),"key", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.key.php )\n *\n *\n * @return int\n */", S(16384),"next", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.next.php )\n *\n *\n */", S(16384),"rewind", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.rewind.php )\n *\n *\n */", S(16384),"valid", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.valid.php )\n *\n *\n * @return bool\n */", S(16384),"send", T(Void), S(0), "v", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.send.php )\n *\n *\n * @v mixed\n */", S(16384),"raise", T(Void), S(0), "v", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.raise.php )\n *\n *\n * @v mixed\n */", S(16384),"getOrigFuncName", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getorigfuncname.php\n * )\n *\n *\n * @return string\n */", S(16384),"getCalledClass", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.getcalledclass.php\n * )\n *\n *\n * @return string\n */", S(16384),"__clone", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/continuation.clone.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
S(16416), "/**\n * ( excerpt from http://php.net/manual/en/class.continuation.php )\n *\n *\n */", "DummyContinuation", "", "iterator",NULL, "__construct", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.construct.php\n * )\n *\n *\n */", S(16384),"current", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.current.php )\n *\n *\n * @return mixed\n */", S(16384),"key", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.key.php )\n *\n *\n * @return int\n */", S(16384),"next", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.next.php )\n *\n *\n */", S(16384),"rewind", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.rewind.php )\n *\n *\n */", S(16384),"valid", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/dummycontinuation.valid.php )\n *\n *\n * @return bool\n */", S(16384),NULL,NULL,NULL,
S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.dummycontinuation.php )\n *\n * Represents an invalid continuation which will fatal when used.\n *\n */",
#endif
+23 -6
Ver Arquivo
@@ -26013,6 +26013,7 @@ bool TestCodeRun::TestYield() {
"}\n"
"$c = f(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"class X {\n"
" function f($x) { yield $x; }\n"
" static function g($x) { yield get_called_class(); }\n"
@@ -26021,18 +26022,28 @@ bool TestCodeRun::TestYield() {
"$x = new X;\n"
"$c = $x->f(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"$c = X::g(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"$c = Y::g(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"$fcn = function ($x) { yield $x; };\n"
"$c = $fcn(32);\n"
"var_dump($c->getOrigFuncName());\n",
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
,
"string(1) \"f\"\n"
"string(4) \"X::f\"\n"
"string(4) \"X::g\"\n"
"string(4) \"Y::g\"\n"
"string(9) \"{closure}\"\n");
"string(0) \"\"\n"
"string(1) \"f\"\n"
"string(1) \"X\"\n"
"string(1) \"g\"\n"
"string(1) \"X\"\n"
"string(1) \"g\"\n"
"string(1) \"Y\"\n"
"string(9) \"{closure}\"\n"
"string(0) \"\"\n");
MVCRO("<?php "
"function gen() {"
@@ -34198,6 +34209,7 @@ bool TestCodeRun::TestTraits() {
"}\n"
"$c = f(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"trait T {\n"
" function f($x) { yield get_called_class(); }\n"
"}\n"
@@ -34205,13 +34217,18 @@ bool TestCodeRun::TestTraits() {
"$x = new X;\n"
"$c = $x->f(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
"$fcn = function ($x) { yield $x; };\n"
"$c = $fcn(32);\n"
"var_dump($c->getOrigFuncName());\n"
"var_dump($c->getCalledClass());\n"
,
"string(1) \"f\"\n"
"string(4) \"X::f\"\n"
"string(0) \"\"\n"
"string(1) \"f\"\n"
"string(1) \"X\"\n"
"string(9) \"{closure}\"\n"
"string(0) \"\"\n"
);
MVCRO("<?php "
+1
Ver Arquivo
@@ -10,3 +10,4 @@ class ShortDerp extends BaseDerp {}
$sd = new ShortDerp;
var_dump($sd->genDerp()->getOrigFuncName());
var_dump($sd->genDerp()->getCalledClass());
+2 -1
Ver Arquivo
@@ -1 +1,2 @@
string(18) "ShortDerp::genDerp"
string(7) "genDerp"
string(9) "ShortDerp"
@@ -10,4 +10,18 @@ function my_wrapper() {
$gen->send(null);
}
class my_class {
static function my_member_generator() {
$value = yield null;
var_dump(debug_backtrace());
}
}
function my_class_wrapper() {
$gen = my_class::my_member_generator();
$gen->next();
$gen->send(null);
}
my_wrapper();
my_class_wrapper();
@@ -36,7 +36,7 @@ array(3) {
["file"]=>
string(%d) "%s"
["line"]=>
int(13)
int(26)
["function"]=>
string(10) "my_wrapper"
["args"]=>
@@ -44,3 +44,53 @@ array(3) {
}
}
}
array(3) {
[0]=>
array(4) {
["function"]=>
string(19) "my_member_generator"
["class"]=>
string(8) "my_class"
["type"]=>
string(2) "::"
["args"]=>
array(1) {
[0]=>
object(Continuation)#1 (0) {
}
}
}
[1]=>
array(7) {
["file"]=>
string(%d) "%s"
["line"]=>
int(23)
["function"]=>
string(4) "send"
["class"]=>
string(12) "Continuation"
["object"]=>
object(Continuation)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
NULL
}
}
[2]=>
array(4) {
["file"]=>
string(%d) "%s"
["line"]=>
int(27)
["function"]=>
string(16) "my_class_wrapper"
["args"]=>
array(0) {
}
}
}