Skip to content

Commit 1d94286

Browse files
committed
Use ValueError instead of exceptions in spl_fixedarray.c
1 parent 030dad3 commit 1d94286

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ PHP_METHOD(SplFixedArray, __construct)
529529
}
530530

531531
if (size < 0) {
532-
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero");
532+
zend_argument_value_error(1, "must be greater than or equal to 0");
533533
RETURN_THROWS();
534534
}
535535

@@ -704,7 +704,7 @@ PHP_METHOD(SplFixedArray, setSize)
704704
}
705705

706706
if (size < 0) {
707-
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero");
707+
zend_argument_value_error(1, "must be greater than or equal to 0");
708708
RETURN_THROWS();
709709
}
710710

ext/spl/tests/fixedarray_021.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ var_dump($a->count());
1212
/* negative init value */
1313
try {
1414
$b = new SplFixedArray(-10);
15-
} catch (Exception $e) {
16-
var_dump($e->getMessage());
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage() . \PHP_EOL;
1717
}
1818

1919
/* resize and negative value */
2020
$b = new SplFixedArray();
2121
try {
2222
$b->setSize(-5);
23-
} catch (Exception $e) {
24-
var_dump($e->getMessage());
23+
} catch (\ValueError $e) {
24+
echo $e->getMessage() . \PHP_EOL;
2525
}
2626

2727
/* calling __construct() twice */
@@ -63,8 +63,8 @@ var_dump(empty($a["3"]));
6363
--EXPECTF--
6464
int(0)
6565
int(0)
66-
string(35) "array size cannot be less than zero"
67-
string(35) "array size cannot be less than zero"
66+
SplFixedArray::__construct(): Argument #1 ($size) must be greater than or equal to 0
67+
SplFixedArray::setSize(): Argument #1 ($size) must be greater than or equal to 0
6868
NULL
6969
int(0)
7070
int(0)

0 commit comments

Comments
 (0)