Skip to content

Commit 247c37a

Browse files
committed
- enchant_broker_list_dicts() and enchant_broker_describe() return null` if no broker is available - raise exception on Invalid object
1 parent 0f367e2 commit 247c37a

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

ext/enchant/enchant.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ PHP_MINFO_FUNCTION(enchant)
275275
#define PHP_ENCHANT_GET_BROKER \
276276
pbroker = Z_ENCHANT_BROKER_P(broker); \
277277
if (!pbroker || !pbroker->pbroker) { \
278-
php_error_docref(NULL, E_WARNING, "Invalid EnchantBroker object"); \
279-
RETURN_FALSE; \
278+
zend_value_error("Invalid or uninitialized EnchantBroker object"); \
279+
RETURN_THROWS(); \
280280
}
281281

282282
#define PHP_ENCHANT_GET_DICT \
283283
pdict = Z_ENCHANT_DICT_P(dict); \
284284
if (!pdict || !pdict->pdict) { \
285-
php_error_docref(NULL, E_WARNING, "Invalid EnchantDict object"); \
286-
RETURN_FALSE; \
285+
zend_value_error("Invalid or uninitialized EnchantBroker object"); \
286+
RETURN_THROWS(); \
287287
}
288288

289289
/* {{{ proto resource enchant_broker_init()
@@ -545,7 +545,7 @@ PHP_METHOD(EnchantDict, __construct)
545545
dict->pdict =pdict;
546546
ZVAL_COPY(&dict->zbroker, broker);
547547
} else {
548-
zend_throw_exception(spl_ce_RuntimeException, "Can't create a new EnchantBroker", 0);
548+
zend_throw_exception(spl_ce_RuntimeException, "Can't create a new EnchantDict", 0);
549549
}
550550
}
551551
/* }}} */

ext/enchant/enchant.stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct() {}
1111
public function getError(): string|false {}
1212

1313
/** @alias enchant_broker_list_dicts */
14-
public function listDicts(): array {}
14+
public function listDicts(): ?array {}
1515

1616
/** @alias enchant_broker_request_dict */
1717
public function requestDict(string $tag): EnchantDict|false {}
@@ -26,7 +26,7 @@ public function isDict(string $tag): bool {}
2626
public function setOrdering(string $tag, string $ordering): bool {}
2727

2828
/** @alias enchant_broker_describe */
29-
public function describe($broker): array {}
29+
public function describe(): ?array {}
3030
}
3131

3232
final class EnchantDict
@@ -80,7 +80,7 @@ function enchant_broker_set_dict_path(EnchantBroker $broker, int $name, string $
8080
*/
8181
function enchant_broker_get_dict_path(EnchantBroker $broker, int $name): string|false {}
8282

83-
function enchant_broker_list_dicts(EnchantBroker $broker): array {}
83+
function enchant_broker_list_dicts(EnchantBroker $broker): ?array {}
8484

8585
function enchant_broker_request_dict(EnchantBroker $broker, string $tag): EnchantDict|false {}
8686

@@ -95,7 +95,7 @@ function enchant_broker_dict_exists(EnchantBroker $broker, string $tag): bool {}
9595

9696
function enchant_broker_set_ordering(EnchantBroker $broker, string $tag, string $ordering): bool {}
9797

98-
function enchant_broker_describe(EnchantBroker $broker): array {}
98+
function enchant_broker_describe(EnchantBroker $broker): ?array {}
9999

100100
function enchant_dict_quick_check(EnchantDict $dict, string $word, &$suggestions = UNKNOWN): bool {}
101101

ext/enchant/enchant_arginfo.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_enchant_broker_get_dict_path, 0,
2222
ZEND_ARG_TYPE_INFO(0, name, IS_LONG, 0)
2323
ZEND_END_ARG_INFO()
2424

25-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_broker_list_dicts, 0, 1, IS_ARRAY, 0)
25+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_broker_list_dicts, 0, 1, IS_ARRAY, 1)
2626
ZEND_ARG_OBJ_INFO(0, broker, EnchantBroker, 0)
2727
ZEND_END_ARG_INFO()
2828

@@ -102,7 +102,7 @@ ZEND_END_ARG_INFO()
102102
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_EnchantBroker_getError, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
103103
ZEND_END_ARG_INFO()
104104

105-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_EnchantBroker_listDicts, 0, 0, IS_ARRAY, 0)
105+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_EnchantBroker_listDicts, 0, 0, IS_ARRAY, 1)
106106
ZEND_END_ARG_INFO()
107107

108108
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_EnchantBroker_requestDict, 0, 1, EnchantDict, MAY_BE_FALSE)
@@ -122,9 +122,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_EnchantBroker_setOrdering,
122122
ZEND_ARG_TYPE_INFO(0, ordering, IS_STRING, 0)
123123
ZEND_END_ARG_INFO()
124124

125-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_EnchantBroker_describe, 0, 1, IS_ARRAY, 0)
126-
ZEND_ARG_INFO(0, broker)
127-
ZEND_END_ARG_INFO()
125+
#define arginfo_class_EnchantBroker_describe arginfo_class_EnchantBroker_listDicts
128126

129127
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EnchantDict___construct, 0, 0, 2)
130128
ZEND_ARG_OBJ_INFO(0, broker, EnchantBroker, 0)
@@ -159,7 +157,8 @@ ZEND_END_ARG_INFO()
159157

160158
#define arginfo_class_EnchantDict_getError arginfo_class_EnchantBroker_getError
161159

162-
#define arginfo_class_EnchantDict_describe arginfo_class_EnchantBroker_listDicts
160+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_EnchantDict_describe, 0, 0, IS_ARRAY, 0)
161+
ZEND_END_ARG_INFO()
163162

164163

165164
ZEND_FUNCTION(enchant_broker_init);

0 commit comments

Comments
 (0)