Hello everyone,
I have created a simple patch that extends PHP ReflectionException
Messages in the case of a missing property or method when calling:
$reflClass->getProperty('notKnown');
$reflClass->getMethod('notKnown');
Currently, in both cases only the unknown property and method names are
referenced but not the class-name. In our Doctrine 2
code basis, where we use Reflection heavily this can be pretty annoying
for users to debug, since there is no context to check
against.
The interesting portion of the patch is here, the whole patch file
contains changes to the test-cases also:
Index: ext/reflection/php_reflection.c
--- ext/reflection/php_reflection.c (revision 296963)
+++ ext/reflection/php_reflection.c (working copy)
@@ -3425,7 +3425,7 @@
} else {
efree(lc_name);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
-
"Method %s does not exist", name);
-
}"Method %s::%s() does not exist", ce->name, name); return;
}
@@ -3602,7 +3602,7 @@
}
}
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
-
"Property %s does not exist", name);
-
"Property %s::%s does not exist", ce->name, name);
}
/* }}} *
The patch is against SVN trunk.
greetings,
Benjamin
Index: ext/reflection/php_reflection.c
--- ext/reflection/php_reflection.c (revision 296963)
+++ ext/reflection/php_reflection.c (working copy)
@@ -3425,7 +3425,7 @@
} else {
efree(lc_name);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %s does not exist", name);
}"Method %s::%s() does not exist", ce->name, name); return;
}
@@ -3602,7 +3602,7 @@
}
}
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Property %s does not exist", name);
"Property %s::%s does not exist", ce->name, name);
}
/* }}} *The patch is against SVN trunk.
looks good for me. if there are no objections from someone else I'll
commit it tomorrow.
Index: ext/reflection/php_reflection.c
--- ext/reflection/php_reflection.c (revision 296963)
+++ ext/reflection/php_reflection.c (working copy)
@@ -3425,7 +3425,7 @@
} else {
efree(lc_name);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %s does not exist", name);
return;"Method %s::%s() does not exist", ce->name, name);
}
}
@@ -3602,7 +3602,7 @@
}
}
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Property %s does not exist", name);
"Property %s::%s does not exist", ce->name, name);
}
/* }}} *The patch is against SVN trunk.
looks good for me. if there are no objections from someone else I'll
commit it tomorrow.
@David: seems like you forgot to commit this?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org
looks good for me. if there are no objections from someone else I'll
commit it tomorrow.@David: seems like you forgot to commit this?
David will be back in 10 days.
Cheers,
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
@@ -3602,7 +3602,7 @@
}
}
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Property %s does not exist", name);
"Property %s::%s does not exist", ce->name, name);
}
/* }}} *The patch is against SVN trunk.
looks good for me. if there are no objections from someone else I'll
commit it tomorrow.@David: seems like you forgot to commit this?
Hi,
I'm sorry. I haven't had time to commit it. If someone want's to commit it, go for it, otherwise I'll do it on April 20.