com php-src: Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.: ext/pdo/tests/pdorow.phpt ext/reflection/ php_reflection.c
ext/reflection/tests/ReflectionFunction _construct.001.phpt ext/reflection/tests/Reflecti onMethod_006.phpt ext/reflection/tests/ReflectionMe
thod_constructor_error2.phpt ext/reflection/tests/Ref lectionParameter_invalidMethodInConstructor.phpt
| From: | Dmitry Stogov | Date: | Sun, 01 Mar 2015 13:06:58 +0000 |
| Subject: | com php-src: Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.: ext/pdo/tests/pdorow.phpt ext/reflection/ php_reflection.c ext/reflection/tests/ReflectionFunction _construct.001.phpt ext/reflection/tests/Reflecti onMethod_006.phpt ext/reflection/tests/ReflectionMe thod_constructor_error2.phpt ext/reflection/tests/Ref lectionParameter_invalidMethodInConstructor.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86007@lists.php.net to get a copy of this message | ||
Commit: 043a02605f7bbf03f8a085354bfa617689a919d3
Author: Danack <Danack@basereality.com> Sun, 1 Mar 2015 13:06:58 +0000
Parents: b00cd68d7419bea8d8155ae585b85cf4f5fe8897
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=043a02605f7bbf03f8a085354bfa617689a919d3
Log:
Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
Changed paths:
M ext/pdo/tests/pdorow..phpt
M ext/reflection/php_reflection.c
M ext/reflection/tests/ReflectionFunction_construct.001.phpt
M ext/reflection/tests/ReflectionMethod_006.phpt
M ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
M ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt
diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt index 3b46604..fca40a1 100644 --- a/ext/pdo/tests/pdorow.phpt +++ b/ext/pdo/tests/pdorow.phpt @@ -18,7 +18,7 @@ catch(PDOException $pe) { } } catch(\Exception $e) { - echo "Failed to "; + echo "Exception throw was not of type PDOException instead was ".get_class($e).PHP_EOL; } ?> diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 80e0404..a01a0d6 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1576,6 +1576,8 @@ ZEND_METHOD(reflection_function, __construct) zend_function *fptr; char *name_str; size_t name_len; + int rv; + zend_error_handling zeh; object = getThis(); intern = Z_REFLECTION_P(object); @@ -1586,27 +1588,32 @@ ZEND_METHOD(reflection_function, __construct) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &closure, zend_ce_closure) == SUCCESS) { fptr = (zend_function*)zend_get_closure_method_def(closure); Z_ADDREF_P(closure); - } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == SUCCESS) { - char *nsname; - - lcname = zend_str_tolower_dup(name_str, name_len); - - /* Ignore leading "\" */ - nsname = lcname; - if (lcname[0] == '\\') { - nsname = &lcname[1]; - name_len--; - } - - if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) { + } else { + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len); + zend_restore_error_handling(&zeh TSRMLS_CC); + if (rv == SUCCESS) { + char *nsname; + lcname = zend_str_tolower_dup(name_str, name_len); + + /* Ignore leading "\" */ + nsname = lcname; + if (lcname[0] == '\\') { + nsname = &lcname[1]; + name_len--; + } + + if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) { + efree(lcname); + zend_throw_exception_ex(reflection_exception_ptr, 0, + "Function %s() does not exist", name_str); + return; + } efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Function %s() does not exist", name_str); + } else { + //Exception has been thrown. return; } - efree(lcname); - } else { - return; } ZVAL_STR_COPY(&name, fptr->common.function_name); @@ -2128,10 +2135,14 @@ ZEND_METHOD(reflection_parameter, __construct) zend_class_entry *ce = NULL; zend_bool is_closure = 0; zend_bool is_invoke = 0; + zend_error_handling zeh; + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &reference, ¶meter) == FAILURE) { + zend_restore_error_handling(&zeh TSRMLS_CC); return; } + zend_restore_error_handling(&zeh TSRMLS_CC); object = getThis(); intern = Z_REFLECTION_P(object); @@ -2712,7 +2723,13 @@ ZEND_METHOD(reflection_method, __construct) zval ztmp; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) { + zend_error_handling zeh; + int rv; + + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len); + zend_restore_error_handling(&zeh TSRMLS_CC); + if (rv == FAILURE) { return; } if ((tmp = strstr(name_str, "::")) == NULL) { diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt index c8e0a17..90259ac 100644 --- a/ext/reflection/tests/ReflectionFunction_construct.001.phpt +++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt @@ -6,18 +6,41 @@ Steve Seear <stevseea@php.net> --FILE-- <?php -$a = new ReflectionFunction(array(1, 2, 3)); +try { + $a = new ReflectionFunction(array(1, 2, 3)); + echo "exception not thrown.".PHP_EOL; +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} try { $a = new ReflectionFunction('nonExistentFunction'); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction(); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction(1, 2); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction([]); } -$a = new ReflectionFunction(); -$a = new ReflectionFunction(1, 2); +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + ?> --EXPECTF-- -Warning: ReflectionFunction::__construct() expects parameter 1 to be string, array given in %s on line %d +Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given Function nonExistentFunction() does not exist -Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 0 given in %s on line %d - -Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 2 given in %s on line %d +Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 0 given +Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 2 given +Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt index a516419..0b82289 100644 --- a/ext/reflection/tests/ReflectionMethod_006.phpt +++ b/ext/reflection/tests/ReflectionMethod_006.phpt @@ -6,8 +6,18 @@ Steve Seear <stevseea@php.net> --FILE-- <?php -var_dump(new ReflectionMethod()); -var_dump(new ReflectionMethod('a', 'b', 'c')); +try { + new ReflectionMethod(); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + new ReflectionMethod('a', 'b', 'c'); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} class C { public function f() {} @@ -35,21 +45,8 @@ var_dump($rm->getName(1)); ?> --EXPECTF-- -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line %d -object(ReflectionMethod)#%d (2) { - ["name"]=> - string(0) "" - ["class"]=> - string(0) "" -} - -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line %d -object(ReflectionMethod)#%d (2) { - ["name"]=> - string(0) "" - ["class"]=> - string(0) "" -} +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given Warning: ReflectionMethod::isFinal() expects exactly 0 parameters, 1 given in %s on line %d NULL diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt index 1c2d3a1..85f8097 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt @@ -16,22 +16,47 @@ class TestClass try { echo "Too few arguments:\n"; $methodInfo = new ReflectionMethod(); -} catch (Exception $e) { - print $e->__toString(); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; } try { echo "\nToo many arguments:\n"; $methodInfo = new ReflectionMethod("TestClass", "foo", true); -} catch (Exception $e) { - print $e->__toString(); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + + +try { + //invalid class + $methodInfo = new ReflectionMethod("InvalidClassName", "foo"); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + + +try { + //invalid 1st param + $methodInfo = new ReflectionMethod([], "foo"); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + +try{ + //invalid 2nd param + $methodInfo = new ReflectionMethod("TestClass", []); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> --EXPECTF-- Too few arguments: - -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line 12 +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given Too many arguments: +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given +Ok - Class InvalidClassName does not exist +Ok - The parameter class is expected to be either a string or an object +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 2 given -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line 18 diff --git a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt index 3118c17..1775dee 100644 --- a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt @@ -6,7 +6,7 @@ ReflectionParameter::__construct(): Invalid method as constructor // Invalid class name try { new ReflectionParameter (array ('A', 'b'), 0); -} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } +} catch (ReflectionException $e) { echo $e->getMessage()."\n"; } // Invalid class method try { @@ -18,14 +18,31 @@ try { new ReflectionParameter (array (new C, 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } -echo "Done.\n"; class C { } +try { + new ReflectionParameter(array ('A', 'b')); +} +catch(ReflectionException $e) { + printf( "Ok - %s\n", $e->getMessage()); +} + +try { + new ReflectionParameter(0, 0); +} +catch(ReflectionException $e) { + printf( "Ok - %s\n", $e->getMessage()); +} + +echo "Done.\n"; + ?> --EXPECTF-- Class A does not exist Method C::b() does not exist Method C::b() does not exist +Ok - ReflectionParameter::__construct() expects exactly 2 parameters, 1 given +Ok - The parameter class is expected to be either a string, an array(class, method) or a callable object Done.
diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt index 3b46604..fca40a1 100644 --- a/ext/pdo/tests/pdorow.phpt +++ b/ext/pdo/tests/pdorow.phpt @@ -18,7 +18,7 @@ catch(PDOException $pe) { } } catch(\Exception $e) { - echo "Failed to "; + echo "Exception throw was not of type PDOException instead was ".get_class($e).PHP_EOL; } ?> diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 80e0404..a01a0d6 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1576,6 +1576,8 @@ ZEND_METHOD(reflection_function, __construct) zend_function *fptr; char *name_str; size_t name_len; + int rv; + zend_error_handling zeh; object = getThis(); intern = Z_REFLECTION_P(object); @@ -1586,27 +1588,32 @@ ZEND_METHOD(reflection_function, __construct) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &closure, zend_ce_closure) == SUCCESS) { fptr = (zend_function*)zend_get_closure_method_def(closure); Z_ADDREF_P(closure); - } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == SUCCESS) { - char *nsname; - - lcname = zend_str_tolower_dup(name_str, name_len); - - /* Ignore leading "\" */ - nsname = lcname; - if (lcname[0] == '\\') { - nsname = &lcname[1]; - name_len--; - } - - if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) { + } else { + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len); + zend_restore_error_handling(&zeh TSRMLS_CC); + if (rv == SUCCESS) { + char *nsname; + lcname = zend_str_tolower_dup(name_str, name_len); + + /* Ignore leading "\" */ + nsname = lcname; + if (lcname[0] == '\\') { + nsname = &lcname[1]; + name_len--; + } + + if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) { + efree(lcname); + zend_throw_exception_ex(reflection_exception_ptr, 0, + "Function %s() does not exist", name_str); + return; + } efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Function %s() does not exist", name_str); + } else { + //Exception has been thrown. return; } - efree(lcname); - } else { - return; } ZVAL_STR_COPY(&name, fptr->common.function_name); @@ -2128,10 +2135,14 @@ ZEND_METHOD(reflection_parameter, __construct) zend_class_entry *ce = NULL; zend_bool is_closure = 0; zend_bool is_invoke = 0; + zend_error_handling zeh; + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &reference, ¶meter) == FAILURE) { + zend_restore_error_handling(&zeh TSRMLS_CC); return; } + zend_restore_error_handling(&zeh TSRMLS_CC); object = getThis(); intern = Z_REFLECTION_P(object); @@ -2712,7 +2723,13 @@ ZEND_METHOD(reflection_method, __construct) zval ztmp; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) { + zend_error_handling zeh; + int rv; + + zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len); + zend_restore_error_handling(&zeh TSRMLS_CC); + if (rv == FAILURE) { return; } if ((tmp = strstr(name_str, "::")) == NULL) { diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt index c8e0a17..90259ac 100644 --- a/ext/reflection/tests/ReflectionFunction_construct.001.phpt +++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt @@ -6,18 +6,41 @@ Steve Seear <stevseea@php.net> --FILE-- <?php -$a = new ReflectionFunction(array(1, 2, 3)); +try { + $a = new ReflectionFunction(array(1, 2, 3)); + echo "exception not thrown.".PHP_EOL; +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} try { $a = new ReflectionFunction('nonExistentFunction'); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction(); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction(1, 2); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + $a = new ReflectionFunction([]); } -$a = new ReflectionFunction(); -$a = new ReflectionFunction(1, 2); +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + ?> --EXPECTF-- -Warning: ReflectionFunction::__construct() expects parameter 1 to be string, array given in %s on line %d +Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given Function nonExistentFunction() does not exist -Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 0 given in %s on line %d - -Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 2 given in %s on line %d +Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 0 given +Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 2 given +Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt index a516419..0b82289 100644 --- a/ext/reflection/tests/ReflectionMethod_006.phpt +++ b/ext/reflection/tests/ReflectionMethod_006.phpt @@ -6,8 +6,18 @@ Steve Seear <stevseea@php.net> --FILE-- <?php -var_dump(new ReflectionMethod()); -var_dump(new ReflectionMethod('a', 'b', 'c')); +try { + new ReflectionMethod(); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} +try { + new ReflectionMethod('a', 'b', 'c'); +} +catch(ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} class C { public function f() {} @@ -35,21 +45,8 @@ var_dump($rm->getName(1)); ?> --EXPECTF-- -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line %d -object(ReflectionMethod)#%d (2) { - ["name"]=> - string(0) "" - ["class"]=> - string(0) "" -} - -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line %d -object(ReflectionMethod)#%d (2) { - ["name"]=> - string(0) "" - ["class"]=> - string(0) "" -} +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given Warning: ReflectionMethod::isFinal() expects exactly 0 parameters, 1 given in %s on line %d NULL diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt index 1c2d3a1..85f8097 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt @@ -16,22 +16,47 @@ class TestClass try { echo "Too few arguments:\n"; $methodInfo = new ReflectionMethod(); -} catch (Exception $e) { - print $e->__toString(); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; } try { echo "\nToo many arguments:\n"; $methodInfo = new ReflectionMethod("TestClass", "foo", true); -} catch (Exception $e) { - print $e->__toString(); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + + +try { + //invalid class + $methodInfo = new ReflectionMethod("InvalidClassName", "foo"); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + + +try { + //invalid 1st param + $methodInfo = new ReflectionMethod([], "foo"); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; +} + +try{ + //invalid 2nd param + $methodInfo = new ReflectionMethod("TestClass", []); +} catch (ReflectionException $re) { + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> --EXPECTF-- Too few arguments: - -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line 12 +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given Too many arguments: +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given +Ok - Class InvalidClassName does not exist +Ok - The parameter class is expected to be either a string or an object +Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 2 given -Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line 18 diff --git a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt index 3118c17..1775dee 100644 --- a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt @@ -6,7 +6,7 @@ ReflectionParameter::__construct(): Invalid method as constructor // Invalid class name try { new ReflectionParameter (array ('A', 'b'), 0); -} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } +} catch (ReflectionException $e) { echo $e->getMessage()."\n"; } // Invalid class method try { @@ -18,14 +18,31 @@ try { new ReflectionParameter (array (new C, 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } -echo "Done.\n"; class C { } +try { + new ReflectionParameter(array ('A', 'b')); +} +catch(ReflectionException $e) { + printf( "Ok - %s\n", $e->getMessage()); +} + +try { + new ReflectionParameter(0, 0); +} +catch(ReflectionException $e) { + printf( "Ok - %s\n", $e->getMessage()); +} + +echo "Done.\n"; + ?> --EXPECTF-- Class A does not exist Method C::b() does not exist Method C::b() does not exist +Ok - ReflectionParameter::__construct() expects exactly 2 parameters, 1 given +Ok - The parameter class is expected to be either a string, an array(class, method) or a callable object Done.