Files
php-src/ext/spl/tests/ArrayObject/arrayObject___construct_error1.phpt
Gina Peter Banyard ee908f5542 Zend: normalise behaviour around class name ZPP specifier (#23359)
Splitting the behavioural change of #23052 out into this and come up with something that is hopefully more sensible and consistent between fast and slow ZPP and the object or class_name Fast ZPP specifier.
2026-08-21 13:31:45 +01:00

26 lines
778 B
PHP

--TEST--
SPL: ArrayObject::__construct with bad iterator.
--FILE--
<?php
echo "Bad iterator type:\n";
$a = new stdClass;
$a->p = 1;
try {
var_dump(new ArrayObject($a, 0, "Exception"));
} catch (TypeError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "Non-existent class:\n";
try {
var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
} catch (TypeError $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Bad iterator type:
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, "Exception" given
Non-existent class:
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, "nonExistentClassName" given