mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01:00
Introduces a ZEND_PARSE_PARAMS_THROW flag for zpp, which forces to report FAILURE errors using a TypeException instead of a Warning, like it would happen in strict mode. Adds a zend_parse_parameters_throw() convenience function, which invokes zpp with this flag. Converts all cases I could identify, where we currently have throwing zpp usage in constructors and replaces them with this API. Error handling is still replaced to EH_THROW in some cases to handle other, domain-specific errors in constructors.
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
--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"; }
|
|
|
|
|
|
class C {
|
|
}
|
|
|
|
try {
|
|
new ReflectionParameter(array ('A', 'b'));
|
|
}
|
|
catch(TypeException $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.
|