Skip to content

Commit 4e1d034

Browse files
committed
convert enchant resources to objects of new classes
- EnchantBroker - EnchantDict add OO interface deprecate enchant_broker_free* (use unset instead) deprecate ENCHANT_MYSPELL and ENCHANT_ISPELL constants
1 parent f987219 commit 4e1d034

31 files changed

+565
-279
lines changed

ext/enchant/enchant.c

Lines changed: 202 additions & 139 deletions
Large diffs are not rendered by default.

ext/enchant/enchant.stub.php

Lines changed: 87 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,129 @@
22

33
/** @generate-function-entries */
44

5-
/** @return resource|false */
6-
function enchant_broker_init() {}
5+
final class EnchantBroker
6+
{
7+
/** @alias enchant_broker_init */
8+
public function __construct() {}
79

8-
/** @param resource $broker */
9-
function enchant_broker_free($broker): bool {}
10+
/** @alias enchant_broker_get_error */
11+
public function getError(): string|false {}
12+
13+
/** @alias enchant_broker_list_dicts */
14+
public function listDicts(): ?array {}
15+
16+
/** @alias enchant_broker_request_dict */
17+
public function requestDict(string $tag): EnchantDict|false {}
18+
19+
/** @alias enchant_broker_request_pwl_dict */
20+
public function requestPWL(string $filename): EnchantDict|false {}
21+
22+
/** @alias enchant_broker_dict_exists */
23+
public function isDict(string $tag): bool {}
24+
25+
/** @alias enchant_broker_set_ordering */
26+
public function setOrdering(string $tag, string $ordering): bool {}
27+
28+
/** @alias enchant_broker_describe */
29+
public function describe(): ?array {}
30+
}
31+
32+
final class EnchantDict
33+
{
34+
public function __construct(EnchantBroker $broker, string $tag) {}
35+
36+
/** @alias enchant_dict_quick_check */
37+
public function checkAndSuggest(string $word, &$suggestions = null): bool {}
38+
39+
/** @alias enchant_dict_check */
40+
public function check(string $word): bool {}
41+
42+
/** @alias enchant_dict_suggest */
43+
public function suggest(string $word): ?array {}
44+
45+
/** @alias enchant_dict_add */
46+
public function add(string $word): void {}
47+
48+
/** @alias enchant_dict_add_to_session */
49+
public function addToSession(string $word): void {}
50+
51+
/** @alias enchant_dict_is_added */
52+
public function isAdded(string $word): bool {}
53+
54+
/** @alias enchant_dict_store_replacement */
55+
public function storeReplacement(string $mis, string $cor): void {}
56+
57+
/** @alias enchant_dict_get_error */
58+
public function getError(): string|false {}
59+
60+
/** @alias enchant_dict_describe */
61+
public function describe(): array {}
62+
}
63+
64+
function enchant_broker_init(): EnchantBroker|false {}
1065

1166
/**
12-
* @param resource $broker
13-
* @return string|false
67+
* @deprecated
1468
*/
15-
function enchant_broker_get_error($broker) {}
69+
function enchant_broker_free(EnchantBroker $broker): bool {}
70+
71+
function enchant_broker_get_error(EnchantBroker $broker): string|false {}
1672

1773
/**
18-
* @param resource $broker
1974
* @deprecated
2075
*/
21-
function enchant_broker_set_dict_path($broker, int $name, string $value): bool {}
76+
function enchant_broker_set_dict_path(EnchantBroker $broker, int $name, string $value): bool {}
2277

2378
/**
24-
* @param resource $broker
2579
* @deprecated
2680
*/
27-
function enchant_broker_get_dict_path($broker, int $name): string|false {}
81+
function enchant_broker_get_dict_path(EnchantBroker $broker, int $name): string|false {}
2882

29-
/** @param resource $broker */
30-
function enchant_broker_list_dicts($broker): ?array {}
83+
function enchant_broker_list_dicts(EnchantBroker $broker): ?array {}
3184

32-
/**
33-
* @param resource $broker
34-
* @return resource|false
35-
*/
36-
function enchant_broker_request_dict($broker, string $tag) {}
85+
function enchant_broker_request_dict(EnchantBroker $broker, string $tag): EnchantDict|false {}
3786

38-
/**
39-
* @param resource $broker
40-
* @return resource|false
41-
*/
42-
function enchant_broker_request_pwl_dict($broker, string $filename) {}
87+
function enchant_broker_request_pwl_dict(EnchantBroker $broker, string $filename): EnchantDict|false {}
4388

44-
/** @param resource $dict */
45-
function enchant_broker_free_dict($dict): bool {}
89+
/**
90+
* @deprecated
91+
*/
92+
function enchant_broker_free_dict(EnchantDict $dict): bool {}
4693

47-
/** @param resource $broker */
48-
function enchant_broker_dict_exists($broker, string $tag): bool {}
94+
function enchant_broker_dict_exists(EnchantBroker $broker, string $tag): bool {}
4995

50-
/** @param resource $broker */
51-
function enchant_broker_set_ordering($broker, string $tag, string $ordering): bool {}
96+
function enchant_broker_set_ordering(EnchantBroker $broker, string $tag, string $ordering): bool {}
5297

53-
/** @param resource $broker */
54-
function enchant_broker_describe($broker): ?array {}
98+
function enchant_broker_describe(EnchantBroker $broker): ?array {}
5599

56-
/** @param resource $dict */
57-
function enchant_dict_quick_check($dict, string $word, &$suggestions = null): bool {}
100+
function enchant_dict_quick_check(EnchantDict $dict, string $word, &$suggestions = null): bool {}
58101

59-
/** @param resource $dict */
60-
function enchant_dict_check($dict, string $word): bool {}
102+
function enchant_dict_check(EnchantDict $dict, string $word): bool {}
61103

62-
/** @param resource $dict */
63-
function enchant_dict_suggest($dict, string $word): ?array {}
104+
function enchant_dict_suggest(EnchantDict $dict, string $word): ?array {}
64105

65-
/** @param resource $dict */
66-
function enchant_dict_add($dict, string $word): void {}
106+
function enchant_dict_add(EnchantDict $dict, string $word): void {}
67107

68108
/**
69-
* @param resource $dict
70109
* @alias enchant_dict_add
71110
* @deprecated
72111
*/
73-
function enchant_dict_add_to_personal($dict, string $word): void {}
112+
function enchant_dict_add_to_personal(EnchantDict $dict, string $word): void {}
74113

75-
/** @param resource $dict */
76-
function enchant_dict_add_to_session($dict, string $word): void {}
114+
function enchant_dict_add_to_session(EnchantDict $dict, string $word): void {}
77115

78-
/** @param resource $dict */
79-
function enchant_dict_is_added($dict, string $word): bool {}
116+
function enchant_dict_is_added(EnchantDict $dict, string $word): bool {}
80117

81118
/**
82119
* @param resource $dict
83120
* @alias enchant_dict_is_added
84121
* @deprecated
85122
*/
86-
function enchant_dict_is_in_session($dict, string $word): bool {}
123+
function enchant_dict_is_in_session(EnchantDict $dict, string $word): bool {}
124+
125+
function enchant_dict_store_replacement(EnchantDict $dict, string $mis, string $cor): void {}
87126

88-
/** @param resource $dict */
89-
function enchant_dict_store_replacement($dict, string $mis, string $cor): void {}
127+
function enchant_dict_get_error(EnchantDict $dict): string|false {}
90128

91-
/** @param resource $dict */
92-
function enchant_dict_get_error($dict): string|false {}
129+
function enchant_dict_describe(EnchantDict $dict): array {}
93130

94-
/** @param resource $dict */
95-
function enchant_dict_describe($dict): array {}

0 commit comments

Comments
 (0)