summaryrefslogtreecommitdiff
path: root/ext/spl/tests/fixedarray_005.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-04-02 18:52:32 +0200
committerNikita Popov <nikic@php.net>2015-04-06 11:27:34 +0200
commit122d759618a42bff105971b923fbbb5be02e34b9 (patch)
treefd4487414ffa3f120c77b19b9eb7dc409659c57e /ext/spl/tests/fixedarray_005.phpt
parent884b0365dbe718f667d048dbc3d1cd9d9f12ab84 (diff)
downloadphp-git-122d759618a42bff105971b923fbbb5be02e34b9.tar.gz
Always throw TypeException on throwing zpp failures
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.
Diffstat (limited to 'ext/spl/tests/fixedarray_005.phpt')
-rw-r--r--ext/spl/tests/fixedarray_005.phpt24
1 files changed, 18 insertions, 6 deletions
diff --git a/ext/spl/tests/fixedarray_005.phpt b/ext/spl/tests/fixedarray_005.phpt
index 72970a9a1f..83727a23b9 100644
--- a/ext/spl/tests/fixedarray_005.phpt
+++ b/ext/spl/tests/fixedarray_005.phpt
@@ -1,18 +1,30 @@
--TEST--
-SPL: FixedArray: Trying to instantiate passing object to constructor parameter
+SPL: FixedArray: Invalid arguments
--FILE--
<?php
-$b = new stdClass;
-
try {
- $a = new SplFixedArray($b);
+ $a = new SplFixedArray(new stdClass);
+} catch (TypeException $iae) {
+ echo "Ok - ".$iae->getMessage().PHP_EOL;
}
-catch(InvalidArgumentException $iae) {
+
+try {
+ $a = new SplFixedArray('FOO');
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
+try {
+ $a = new SplFixedArray('');
+} catch (TypeException $iae) {
+ echo "Ok - ".$iae->getMessage().PHP_EOL;
+}
?>
---EXPECTF--
+===DONE===
+--EXPECT--
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given
+===DONE===