]> granicus.if.org Git - php/commitdiff
- Fixed segmentation fault (test added)
authorChristian Seiler <cseiler@php.net>
Mon, 11 Aug 2008 22:08:58 +0000 (22:08 +0000)
committerChristian Seiler <cseiler@php.net>
Mon, 11 Aug 2008 22:08:58 +0000 (22:08 +0000)
ext/reflection/php_reflection.c
ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt [new file with mode: 0644]

index 2e0a9e97f84087c90a97b0eb54e5e7fd726e916a..d2b3bc5aef3ca4db90add107e7488df21e1e8a8a 100644 (file)
@@ -1871,7 +1871,7 @@ ZEND_METHOD(reflection_parameter, __construct)
                                if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) {
                                        efree(lcname);
                                        zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
-                                               "Method %s::%s() does not exist", Z_STRVAL_PP(classref), Z_TYPE_PP(method), Z_STRVAL_PP(method));
+                                               "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method));
                                        return;
                                }
                                efree(lcname);
diff --git a/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt
new file mode 100644 (file)
index 0000000..3118c17
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ReflectionParameter::__construct(): Invalid method as constructor
+--FILE-- 
+<?php
+
+// Invalid class name
+try {
+       new ReflectionParameter (array ('A', 'b'), 0);
+} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
+
+// Invalid class method
+try {
+       new ReflectionParameter (array ('C', 'b'), 0);
+} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
+
+// Invalid object method
+try {
+       new ReflectionParameter (array (new C, 'b'), 0);
+} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
+
+echo "Done.\n";
+
+class C {
+}
+
+?>
+--EXPECTF--
+Class A does not exist
+Method C::b() does not exist
+Method C::b() does not exist
+Done.