flags |= SPL_FILE_DIR_UNIXPATHS;
}
if (parsed == FAILURE) {
- return;
+ RETURN_THROWS();
}
- if (!len) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Directory name must not be empty.");
- return;
+ if (len == 0) {
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (intern->_path) {
/* object is already initialized */
zend_throw_error(NULL, "Directory object is already initialized");
- return;
+ RETURN_THROWS();
}
intern->flags = flags;
}
if (max_len < 0) {
- zend_throw_exception_ex(spl_ce_DomainException, 0, "Maximum line length must be greater than or equal zero");
+ zend_argument_value_error(1, "must be greater than or equal to 0");
RETURN_THROWS();
}
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
if (line_pos < 0) {
- zend_throw_exception_ex(spl_ce_LogicException, 0, "Can't seek file %s to negative line " ZEND_LONG_FMT, intern->file_name, line_pos);
+ zend_argument_value_error(1, "must be greater than or equal to 0");
RETURN_THROWS();
}
}
if (size < 0) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero");
+ zend_argument_value_error(1, "must be greater than or equal to 0");
RETURN_THROWS();
}
}
if (size < 0) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero");
+ zend_argument_value_error(1, "must be greater than or equal to 0");
RETURN_THROWS();
}
RETURN_THROWS();
}
if (max_depth < -1) {
- zend_throw_exception(spl_ce_OutOfRangeException, "Parameter max_depth must be >= -1", 0);
+ zend_argument_value_error(1, "must be greater than or equal to -1");
RETURN_THROWS();
} else if (max_depth > INT_MAX) {
max_depth = INT_MAX;
}
if (0 > part || part > 5) {
- zend_throw_exception_ex(spl_ce_OutOfRangeException, 0, "Use RecursiveTreeIterator::PREFIX_* constant");
+ zend_argument_value_error(1, "must be a RecursiveTreeIterator::PREFIX_* constant");
RETURN_THROWS();
}
#define SPL_CHECK_CTOR(intern, classname) \
if (intern->dit_type == DIT_Unknown) { \
+ /* TODO Normal Error? */ \
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Classes derived from %s must call %s::__construct()", \
ZSTR_VAL((spl_ce_##classname)->name), ZSTR_VAL((spl_ce_##classname)->name)); \
RETURN_THROWS(); \
return NULL;
}
if (intern->u.limit.offset < 0) {
- zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0);
+ zend_argument_value_error(2, "must be greater than or equal to 0");
return NULL;
}
- if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
- zend_throw_exception(spl_ce_OutOfRangeException, "Parameter count must either be -1 or a value greater than or equal 0", 0);
+ if (intern->u.limit.count < -1) {
+ zend_argument_value_error(3, "must be greater than or equal to -1");
return NULL;
}
break;
return NULL;
}
if (spl_cit_check_flags(flags) != SUCCESS) {
- zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER", 0);
+ zend_argument_value_error(2, "must contain only one of CachingIterator::CALL_TOSTRING, "
+ "CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, "
+ "or CachingIterator::TOSTRING_USE_INNER");
return NULL;
}
intern->u.caching.flags |= flags & CIT_PUBLIC;
return NULL;
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Illegal mode " ZEND_LONG_FMT, mode);
+ zend_argument_value_error(3, "must be RegexIterator::MATCH, RegexIterator::GET_MATCH, "
+ "RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE");
return NULL;
}
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Illegal mode " ZEND_LONG_FMT, mode);
+ zend_argument_value_error(1, "must be RegexIterator::MATCH, RegexIterator::GET_MATCH, "
+ "RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE");
RETURN_THROWS();
}
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (spl_cit_check_flags(flags) != SUCCESS) {
- zend_throw_exception(spl_ce_InvalidArgumentException , "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER", 0);
+ zend_argument_value_error(1, "must contain only one of CachingIterator::CALL_TOSTRING, "
+ "CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, "
+ "or CachingIterator::TOSTRING_USE_INNER");
RETURN_THROWS();
}
if ((intern->u.caching.flags & CIT_CALL_TOSTRING) != 0 && (flags & CIT_CALL_TOSTRING) == 0) {
#PHPTestFest2009 Norway 2009-06-09 \o/
--FILE--
<?php
-$it = new DirectoryIterator("");
+try {
+ $it = new DirectoryIterator("");
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Fatal error: Uncaught RuntimeException: Directory name must not be empty. in %s:%d
-Stack trace:
-#0 %s(%d): DirectoryIterator->__construct('')
-#1 {main}
- thrown in %s on line %d
+--EXPECT--
+DirectoryIterator::__construct(): Argument #1 ($path) cannot be empty
$obj = new SplFileObject(__FILE__);
try {
$obj->seek(-1);
-} catch (LogicException $e) {
+} catch (\ValueError $e) {
echo($e->getMessage());
}
?>
---EXPECTF--
-Can't seek file %s to negative line -1
+--EXPECT--
+SplFileObject::seek(): Argument #1 ($line_pos) must be greater than or equal to 0
$array = array('a', 'b', 'c');
$arrayIterator = new ArrayIterator($array);
-try {
- $limitIterator = new LimitIterator($arrayIterator, 0);
- foreach ($limitIterator as $item) {
+$limitIterator = new LimitIterator($arrayIterator, 0);
+foreach ($limitIterator as $item) {
echo $item . "\n";
- }
-} catch (OutOfRangeException $e){
- print $e->getMessage() . "\n";
}
try {
- $limitIterator = new LimitIterator($arrayIterator, -1);
- foreach ($limitIterator as $item) {
- echo $item . "\n";
- }
-} catch (OutOfRangeException $e){
- print $e->getMessage() . "\n";
+ $limitIterator = new LimitIterator($arrayIterator, -1);
+} catch (\ValueError $e){
+ print $e->getMessage() . "\n";
}
?>
a
b
c
-Parameter offset must be >= 0
+LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0
try {
$s->setMaxLineLen(-1);
}
-catch (DomainException $e) {
- echo 'DomainException thrown';
+catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
-DomainException thrown
+SplFileObject::setMaxLineLen(): Argument #1 ($max_len) must be greater than or equal to 0
/* negative init value */
try {
$b = new SplFixedArray(-10);
-} catch (Exception $e) {
- var_dump($e->getMessage());
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
/* resize and negative value */
$b = new SplFixedArray();
try {
$b->setSize(-5);
-} catch (Exception $e) {
- var_dump($e->getMessage());
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
/* calling __construct() twice */
--EXPECTF--
int(0)
int(0)
-string(35) "array size cannot be less than zero"
-string(35) "array size cannot be less than zero"
+SplFixedArray::__construct(): Argument #1 ($size) must be greater than or equal to 0
+SplFixedArray::setSize(): Argument #1 ($size) must be greater than or equal to 0
NULL
int(0)
int(0)
echo "===-1===\n";
$it->setMaxDepth(-1);
var_dump($it->getMaxDepth());
-try
-{
- $it->setMaxDepth(4);
+$it->setMaxDepth(4);
+try {
$it->setMaxDepth(-2);
-}
-catch(Exception $e)
-{
- var_dump($e->getMessage());
+} catch(\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
var_dump($it->getMaxDepth());
?>
0: 4
===-1===
bool(false)
-string(33) "Parameter max_depth must be >= -1"
+RecursiveIteratorIterator::setMaxDepth(): Argument #1 ($max_depth) must be greater than or equal to -1
int(4)
{
echo "===$flags===\n";
$it = new CachingIterator($ar, 0);
- try
- {
+ try {
$it->setFlags($flags);
- }
- catch (Exception $e)
- {
+ } catch (\ValueError $e) {
echo 'Exception: ' . $e->getMessage() . "\n";
var_dump($it->getFlags());
return;
}
var_dump($it->getFlags());
- try
- {
+ try {
foreach($it as $v)
{
var_dump((string)$it);
}
- }
- catch (Exception $e)
- {
+ } catch (Exception $e) {
echo 'Exception: ' . $e->getMessage() . "\n";
}
}
string(3) "1:2"
string(3) "2:3"
===3===
-Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
int(0)
===5===
-Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
int(0)
===9===
-Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
int(0)
===6===
-Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
int(0)
===10===
-Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
int(0)
===X===
Exception: Unsetting flag CALL_TO_STRING is not possible
}
try {
$it->setPrefixPart(-1, "");
- $it->setPrefixPart(6, "");
-} catch (OutOfRangeException $e) {
- echo "OutOfRangeException thrown\n";
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
try {
$it->setPrefixPart(6, "");
-} catch (OutOfRangeException $e) {
- echo "OutOfRangeException thrown\n";
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
[0] => 0145b
[c] => 045Array
[0] => 0245d
-OutOfRangeException thrown
-OutOfRangeException thrown
+RecursiveTreeIterator::setPrefixPart(): Argument #1 ($part) must be a RecursiveTreeIterator::PREFIX_* constant
+RecursiveTreeIterator::setPrefixPart(): Argument #1 ($part) must be a RecursiveTreeIterator::PREFIX_* constant
try {
$regexIterator->setMode(7);
-} catch (InvalidArgumentException $e) {
- var_dump($e->getMessage());
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
var_dump($e->getCode());
}
?>
--EXPECT--
int(0)
-string(14) "Illegal mode 7"
+RegexIterator::setMode(): Argument #1 ($mode) must be RegexIterator::MATCH, RegexIterator::GET_MATCH, RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE
int(0)
//line 681 ...
$array = array(array(7,8,9),1,2,3,array(4,5,6));
$arrayIterator = new ArrayIterator($array);
+new CachingIterator($arrayIterator, 0); /* TODO Should this throw? */
+new CachingIterator($arrayIterator, CachingIterator::CALL_TOSTRING);
+new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_KEY);
+new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_CURRENT);
+new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_INNER);
try {
-$test = new CachingIterator($arrayIterator, 0);
-$test = new CachingIterator($arrayIterator, 1);
-$test = new CachingIterator($arrayIterator, 2);
-$test = new CachingIterator($arrayIterator, 3); // this throws an exception
-} catch (InvalidArgumentException $e){
+ $test = new CachingIterator($arrayIterator, 3); // this throws an exception
+} catch (\ValueError $e){
print $e->getMessage() . "\n";
}
?>
--EXPECT--
-Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+CachingIterator::__construct(): Argument #2 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER
try {
$limitIterator = new LimitIterator($arrayIterator, -1);
-} catch (OutOfRangeException $e){
+} catch (\ValueError $e){
print $e->getMessage(). "\n";
}
-
try {
$limitIterator = new LimitIterator($arrayIterator, 0, -2);
-} catch (OutOfRangeException $e){
- print $e->getMessage() . "\n";
-}
-
-try {
- $limitIterator = new LimitIterator($arrayIterator, 0, -1);
-} catch (OutOfRangeException $e){
+} catch (\ValueError $e){
print $e->getMessage() . "\n";
}
-
+$limitIterator = new LimitIterator($arrayIterator, 0, -1);
?>
--EXPECT--
-Parameter offset must be >= 0
-Parameter count must either be -1 or a value greater than or equal 0
+LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0
+LimitIterator::__construct(): Argument #3 ($count) must be greater than or equal to -1