Skip to content

Commit 9a71d47

Browse files
committed
Throw ValueError on empty tag in enchant_broker_request_dict()
1 parent 0ba31e1 commit 9a71d47

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ext/enchant/enchant.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ PHP_FUNCTION(enchant_broker_request_dict)
455455
PHP_ENCHANT_GET_BROKER;
456456

457457
if (taglen == 0) {
458-
php_error_docref(NULL, E_WARNING, "Tag cannot be empty");
459-
RETURN_FALSE;
458+
zend_argument_value_error(2, "cannot be empty");
459+
RETURN_THROWS();
460460
}
461461

462462
pdict = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
enchant_broker_request_dict() must throw ValueError on empty tag
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('enchant')) die('skip, enchant not loader');
6+
if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
7+
?>
8+
--FILE--
9+
<?php
10+
$broker = enchant_broker_init();
11+
12+
try {
13+
var_dump(enchant_broker_request_dict($broker, ''));
14+
} catch (\ValueError $e) {
15+
echo $e->getMessage() . \PHP_EOL;
16+
}
17+
18+
?>
19+
--EXPECT--
20+
enchant_broker_request_dict(): Argument #2 ($tag) cannot be empty

0 commit comments

Comments
 (0)