Skip to content

Commit 9e4b511

Browse files
committed
Convert some SPL Exceptions to normal Errors in spl_directory.c
1 parent 275ed2c commit 9e4b511

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

ext/spl/spl_directory.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto
718718
}
719719

720720
if (!len) {
721-
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Directory name must not be empty.");
721+
zend_value_error("Directory name must not be empty");
722722
return;
723723
}
724724

@@ -850,7 +850,7 @@ SPL_METHOD(DirectoryIterator, seek)
850850
valid = zend_is_true(&retval);
851851
zval_ptr_dtor(&retval);
852852
if (!valid) {
853-
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos);
853+
zend_value_error("Seek position " ZEND_LONG_FMT " is out of range", pos);
854854
RETURN_THROWS();
855855
}
856856
zend_call_method_with_0_params(Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_next, "next", NULL);
@@ -2460,7 +2460,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen)
24602460
}
24612461

24622462
if (max_len < 0) {
2463-
zend_throw_exception_ex(spl_ce_DomainException, 0, "Maximum line length must be greater than or equal zero");
2463+
zend_value_error("Maximum line length must be greater than or equal zero");
24642464
RETURN_THROWS();
24652465
}
24662466

@@ -2925,7 +2925,7 @@ SPL_METHOD(SplFileObject, seek)
29252925
}
29262926

29272927
if (line_pos < 0) {
2928-
zend_throw_exception_ex(spl_ce_LogicException, 0, "Can't seek file %s to negative line " ZEND_LONG_FMT, intern->file_name, line_pos);
2928+
zend_value_error("Can't seek file %s to negative line", intern->file_name);
29292929
RETURN_THROWS();
29302930
}
29312931

ext/spl/tests/DirectoryIterator_empty_constructor.phpt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ Havard Eide <nucleuz@gmail.com>
55
#PHPTestFest2009 Norway 2009-06-09 \o/
66
--FILE--
77
<?php
8-
$it = new DirectoryIterator("");
8+
9+
try {
10+
new DirectoryIterator("");
11+
} catch (\ValueError $ex) {
12+
echo $ex->getMessage() . PHP_EOL;
13+
}
14+
915
?>
10-
--EXPECTF--
11-
Fatal error: Uncaught RuntimeException: Directory name must not be empty. in %s:%d
12-
Stack trace:
13-
#0 %s(%d): DirectoryIterator->__construct('')
14-
#1 {main}
15-
thrown in %s on line %d
16+
--EXPECT--
17+
Directory name must not be empty

ext/spl/tests/SplFileObject_seek_error_001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ SplFileObject::seek function - test parameters
44
<?php
55
$obj = new SplFileObject(__FILE__);
66
try {
7-
$obj->seek(-1);
8-
} catch (LogicException $e) {
9-
echo($e->getMessage());
7+
$obj->seek(-1);
8+
} catch (\ValueError $e) {
9+
echo($e->getMessage());
1010
}
1111
?>
1212
--EXPECTF--
13-
Can't seek file %s to negative line -1
13+
Can't seek file %s to negative line

ext/spl/tests/bug70561.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ while ($di->valid()) {
1313

1414
try {
1515
$di->seek($cnt+1);
16-
} catch (OutOfBoundsException $ex) {
16+
} catch (\ValueError $ex) {
1717
echo $ex->getMessage() . PHP_EOL;
1818
}
1919
echo "Is valid? " . (int) $di->valid() . PHP_EOL;

ext/spl/tests/dit_006.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ try {
3434
$p = 0;
3535
$di->seek($o+1);
3636
$p = 1;
37-
} catch (\OutOfBoundsException $ex) {
37+
} catch (\ValueError $ex) {
3838
echo $ex->getMessage() . PHP_EOL;
3939
}
4040

ext/spl/tests/fileobject_setmaxlinelen_error001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ $s = new SplFileObject( __FILE__ );
88
try {
99
$s->setMaxLineLen(-1);
1010
}
11-
catch (DomainException $e) {
12-
echo 'DomainException thrown';
11+
catch (\ValueError $e) {
12+
echo($e->getMessage());
1313
}
1414

1515
?>
1616
--EXPECT--
17-
DomainException thrown
17+
Maximum line length must be greater than or equal zero

0 commit comments

Comments
 (0)