mirror of
https://github.com/php/php-src.git
synced 2026-04-22 15:38:49 +02:00
122d759618
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.
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
--TEST--
|
|
SPL: Calling __construct(void) on class extending SPL iterator
|
|
--CREDITS--
|
|
Sebastian Schürmann
|
|
--FILE--
|
|
<?php
|
|
|
|
class myFilterIterator extends FilterIterator {
|
|
function accept() { }
|
|
}
|
|
|
|
class myCachingIterator extends CachingIterator { }
|
|
|
|
class myRecursiveCachingIterator extends RecursiveCachingIterator { }
|
|
|
|
class myParentIterator extends ParentIterator { }
|
|
|
|
class myLimitIterator extends LimitIterator { }
|
|
|
|
class myNoRewindIterator extends NoRewindIterator {}
|
|
|
|
try {
|
|
$it = new myFilterIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
$it = new myCachingIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
$it = new myRecursiveCachingIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
$it = new myParentIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
try {
|
|
$it = new myLimitIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
$it = new myNoRewindIterator();
|
|
} catch (TypeException $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
FilterIterator::__construct() expects exactly 1 parameter, 0 given
|
|
CachingIterator::__construct() expects at least 1 parameter, 0 given
|
|
RecursiveCachingIterator::__construct() expects at least 1 parameter, 0 given
|
|
ParentIterator::__construct() expects exactly 1 parameter, 0 given
|
|
LimitIterator::__construct() expects at least 1 parameter, 0 given
|
|
NoRewindIterator::__construct() expects exactly 1 parameter, 0 given
|