1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/spl/tests/arrayObject___construct_error2.phpt
Nikita Popov 122d759618 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.
2015-04-06 11:27:34 +02:00

23 lines
504 B
PHP

--TEST--
SPL: ArrayObject::__construct with too many arguments.
--FILE--
<?php
echo "Too many arguments:\n";
Class C implements Iterator {
function current() {}
function next() {}
function key() {}
function valid() {}
function rewind() {}
}
try {
var_dump(new ArrayObject(new stdClass, 0, "C", "extra"));
} catch (TypeException $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
}
?>
--EXPECTF--
Too many arguments:
ArrayObject::__construct() expects at most 3 parameters, 4 given(12)