Skip to content

Commit 57a635c

Browse files
Ayeshnikic
authored andcommitted
Move resource-object classes of PSpell to \PSpell namespace
[namespaces in bundled extensions](https://wiki.php.net/rfc/namespaces_in_bundled_extensions) changes for PSpell. - Rename `PSpell` class to `\PSpell\Dictionary` - Rename `PSpellConfig` class to `\PSpell\Config` - Add entries to `UPGRADING` file. Related: bd12c94
1 parent 3ccc040 commit 57a635c

File tree

6 files changed

+70
-55
lines changed

6 files changed

+70
-55
lines changed

NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ PHP NEWS
9999
. Fixed bug #38334 (Proper data-type support for PDO_SQLITE). (Nikita)
100100

101101
- PSpell:
102-
. Convert resource<pspell> to object \PSpell. (Sara)
103-
. Convert resource<pspell config> to object \PSpellConfig. (Sara)
102+
. Convert resource<pspell> to object \PSpell\Dictionary. (Sara)
103+
. Convert resource<pspell config> to object \PSpell\Config. (Sara)
104104

105105
- Sodium:
106106
. Added the XChaCha20 stream cipher functions. (P.I.E. Security Team)

UPGRADING

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ PHP 8.1 UPGRADE NOTES
120120
types. You can restore the previous behavior by enabling the
121121
PDO::ATTR_STRINGIFY_FETCHES option.
122122

123+
- PSpell:
124+
. The PSpell functions now accept and return, respectively, PSpell\Dictionary objects
125+
instead of "pspell" resources. Return value checks using is_resource()
126+
should be replaced with checks for `false`.
127+
. The PSpell functions now accept and return, respectively, PSpell\Config objects
128+
instead of "pspell config" resources. Return value checks using is_resource()
129+
should be replaced with checks for `false`.
130+
123131
- Standard:
124132
. version_compare() no longer accepts undocumented operator abbreviations.
125133
. htmlspecialchars(), htmlentities(), htmlspecialchars_decode(),

ext/pspell/pspell.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static zend_object *php_pspell_object_to_zend_object(php_pspell_object *obj) {
8888

8989
static zend_function *php_pspell_object_get_constructor(zend_object *object)
9090
{
91-
zend_throw_error(NULL, "You cannot initialize a PSpell object except through helper functions");
91+
zend_throw_error(NULL, "You cannot initialize a PSpell\\Dictionary object except through helper functions");
9292
return NULL;
9393
}
9494

@@ -126,7 +126,7 @@ static zend_object *php_pspell_config_object_to_zend_object(php_pspell_config_ob
126126

127127
static zend_function *php_pspell_config_object_get_constructor(zend_object *object)
128128
{
129-
zend_throw_error(NULL, "You cannot initialize a PSpellConfig object except through helper functions");
129+
zend_throw_error(NULL, "You cannot initialize a PSpell\\Config object except through helper functions");
130130
return NULL;
131131
}
132132

@@ -150,7 +150,7 @@ static void php_pspell_config_object_free(zend_object *zobj) {
150150
/* {{{ PHP_MINIT_FUNCTION */
151151
static PHP_MINIT_FUNCTION(pspell)
152152
{
153-
php_pspell_ce = register_class_PSpell();
153+
php_pspell_ce = register_class_PSpell_Dictionary();
154154
php_pspell_ce->create_object = php_pspell_object_create;
155155
php_pspell_ce->serialize = zend_class_serialize_deny;
156156
php_pspell_ce->unserialize = zend_class_unserialize_deny;
@@ -161,7 +161,7 @@ static PHP_MINIT_FUNCTION(pspell)
161161
php_pspell_handlers.get_constructor = php_pspell_object_get_constructor;
162162
php_pspell_handlers.offset = XtOffsetOf(php_pspell_object, std);
163163

164-
php_pspell_config_ce = register_class_PSpellConfig();
164+
php_pspell_config_ce = register_class_PSpell_Config();
165165
php_pspell_config_ce->create_object = php_pspell_config_object_create;
166166
php_pspell_config_ce->serialize = zend_class_serialize_deny;
167167
php_pspell_config_ce->unserialize = zend_class_unserialize_deny;

ext/pspell/pspell.stub.php

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

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

5-
/** @strict-properties */
6-
final class PSpell {}
7-
/** @strict-properties */
8-
final class PSpellConfig {}
5+
namespace PSpell {
6+
/** @strict-properties */
7+
final class Dictionary {}
98

10-
function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): PSpell|false {}
9+
/** @strict-properties */
10+
final class Config {}
11+
}
12+
13+
namespace {
14+
15+
function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): PSpell\Dictionary|false {}
1116

1217
function pspell_new_personal(
1318
string $filename,
@@ -16,24 +21,26 @@ function pspell_new_personal(
1621
string $jargon = "",
1722
string $encoding = "",
1823
int $mode = 0
19-
): PSpell|false {}
20-
21-
function pspell_new_config(PSpellConfig $config): PSpell|false {}
22-
23-
function pspell_check(PSpell $dictionary, string $word): bool {}
24-
function pspell_suggest(PSpell $dictionary, string $word): array|false {}
25-
function pspell_store_replacement(PSpell $dictionary, string $misspelled, string $correct): bool {}
26-
function pspell_add_to_personal(PSpell $dictionary, string $word): bool {}
27-
function pspell_add_to_session(PSpell $dictionary, string $word): bool {}
28-
function pspell_clear_session(PSpell $dictionary): bool {}
29-
function pspell_save_wordlist(PSpell $dictionary): bool {}
30-
31-
function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): PSpellConfig {}
32-
function pspell_config_runtogether(PSpellConfig $config, bool $allow): bool {}
33-
function pspell_config_mode(PSpellConfig $config, int $mode): bool {}
34-
function pspell_config_ignore(PSpellConfig $config, int $min_length): bool {}
35-
function pspell_config_personal(PSpellConfig $config, string $filename): bool {}
36-
function pspell_config_dict_dir(PSpellConfig $config, string $directory): bool {}
37-
function pspell_config_data_dir(PSpellConfig $config, string $directory): bool {}
38-
function pspell_config_repl(PSpellConfig $config, string $filename): bool {}
39-
function pspell_config_save_repl(PSpellConfig $config, bool $save): bool {}
24+
): PSpell\Dictionary|false {}
25+
26+
function pspell_new_config(PSpell\Config $config): PSpell\Dictionary|false {}
27+
28+
function pspell_check(PSpell\Dictionary $dictionary, string $word): bool {}
29+
function pspell_suggest(PSpell\Dictionary $dictionary, string $word): array|false {}
30+
function pspell_store_replacement(PSpell\Dictionary $dictionary, string $misspelled, string $correct): bool {}
31+
function pspell_add_to_personal(PSpell\Dictionary $dictionary, string $word): bool {}
32+
function pspell_add_to_session(PSpell\Dictionary $dictionary, string $word): bool {}
33+
function pspell_clear_session(PSpell\Dictionary $dictionary): bool {}
34+
function pspell_save_wordlist(PSpell\Dictionary $dictionary): bool {}
35+
36+
function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): PSpell\Config {}
37+
function pspell_config_runtogether(PSpell\Config $config, bool $allow): bool {}
38+
function pspell_config_mode(PSpell\Config $config, int $mode): bool {}
39+
function pspell_config_ignore(PSpell\Config $config, int $min_length): bool {}
40+
function pspell_config_personal(PSpell\Config $config, string $filename): bool {}
41+
function pspell_config_dict_dir(PSpell\Config $config, string $directory): bool {}
42+
function pspell_config_data_dir(PSpell\Config $config, string $directory): bool {}
43+
function pspell_config_repl(PSpell\Config $config, string $filename): bool {}
44+
function pspell_config_save_repl(PSpell\Config $config, bool $save): bool {}
45+
46+
}

ext/pspell/pspell_arginfo.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: d7a2f6b4aa719778166e5a255432f03100184a42 */
2+
* Stub hash: aedd25078f730be3892804dbe0c722fec2fbcf7e */
33

4-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new, 0, 1, PSpell, MAY_BE_FALSE)
4+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new, 0, 1, PSpell\\Dictionary, MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0)
66
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"")
77
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, jargon, IS_STRING, 0, "\"\"")
88
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"")
99
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
1010
ZEND_END_ARG_INFO()
1111

12-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new_personal, 0, 2, PSpell, MAY_BE_FALSE)
12+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new_personal, 0, 2, PSpell\\Dictionary, MAY_BE_FALSE)
1313
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
1414
ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0)
1515
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"")
@@ -18,22 +18,22 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new_personal, 0, 2, P
1818
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
1919
ZEND_END_ARG_INFO()
2020

21-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new_config, 0, 1, PSpell, MAY_BE_FALSE)
22-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
21+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pspell_new_config, 0, 1, PSpell\\Dictionary, MAY_BE_FALSE)
22+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
2323
ZEND_END_ARG_INFO()
2424

2525
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_check, 0, 2, _IS_BOOL, 0)
26-
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell, 0)
26+
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell\\Dictionary, 0)
2727
ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0)
2828
ZEND_END_ARG_INFO()
2929

3030
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pspell_suggest, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
31-
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell, 0)
31+
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell\\Dictionary, 0)
3232
ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0)
3333
ZEND_END_ARG_INFO()
3434

3535
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_store_replacement, 0, 3, _IS_BOOL, 0)
36-
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell, 0)
36+
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell\\Dictionary, 0)
3737
ZEND_ARG_TYPE_INFO(0, misspelled, IS_STRING, 0)
3838
ZEND_ARG_TYPE_INFO(0, correct, IS_STRING, 0)
3939
ZEND_END_ARG_INFO()
@@ -43,40 +43,40 @@ ZEND_END_ARG_INFO()
4343
#define arginfo_pspell_add_to_session arginfo_pspell_check
4444

4545
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_clear_session, 0, 1, _IS_BOOL, 0)
46-
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell, 0)
46+
ZEND_ARG_OBJ_INFO(0, dictionary, PSpell\\Dictionary, 0)
4747
ZEND_END_ARG_INFO()
4848

4949
#define arginfo_pspell_save_wordlist arginfo_pspell_clear_session
5050

51-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_pspell_config_create, 0, 1, PSpellConfig, 0)
51+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_pspell_config_create, 0, 1, PSpell\\Config, 0)
5252
ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0)
5353
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"")
5454
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, jargon, IS_STRING, 0, "\"\"")
5555
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"")
5656
ZEND_END_ARG_INFO()
5757

5858
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_runtogether, 0, 2, _IS_BOOL, 0)
59-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
59+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
6060
ZEND_ARG_TYPE_INFO(0, allow, _IS_BOOL, 0)
6161
ZEND_END_ARG_INFO()
6262

6363
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_mode, 0, 2, _IS_BOOL, 0)
64-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
64+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
6565
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
6666
ZEND_END_ARG_INFO()
6767

6868
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_ignore, 0, 2, _IS_BOOL, 0)
69-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
69+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
7070
ZEND_ARG_TYPE_INFO(0, min_length, IS_LONG, 0)
7171
ZEND_END_ARG_INFO()
7272

7373
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_personal, 0, 2, _IS_BOOL, 0)
74-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
74+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
7575
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
7676
ZEND_END_ARG_INFO()
7777

7878
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_dict_dir, 0, 2, _IS_BOOL, 0)
79-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
79+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
8080
ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 0)
8181
ZEND_END_ARG_INFO()
8282

@@ -85,7 +85,7 @@ ZEND_END_ARG_INFO()
8585
#define arginfo_pspell_config_repl arginfo_pspell_config_personal
8686

8787
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_save_repl, 0, 2, _IS_BOOL, 0)
88-
ZEND_ARG_OBJ_INFO(0, config, PSpellConfig, 0)
88+
ZEND_ARG_OBJ_INFO(0, config, PSpell\\Config, 0)
8989
ZEND_ARG_TYPE_INFO(0, save, _IS_BOOL, 0)
9090
ZEND_END_ARG_INFO()
9191

@@ -135,31 +135,31 @@ static const zend_function_entry ext_functions[] = {
135135
};
136136

137137

138-
static const zend_function_entry class_PSpell_methods[] = {
138+
static const zend_function_entry class_PSpell_Dictionary_methods[] = {
139139
ZEND_FE_END
140140
};
141141

142142

143-
static const zend_function_entry class_PSpellConfig_methods[] = {
143+
static const zend_function_entry class_PSpell_Config_methods[] = {
144144
ZEND_FE_END
145145
};
146146

147-
static zend_class_entry *register_class_PSpell(void)
147+
static zend_class_entry *register_class_PSpell_Dictionary(void)
148148
{
149149
zend_class_entry ce, *class_entry;
150150

151-
INIT_CLASS_ENTRY(ce, "PSpell", class_PSpell_methods);
151+
INIT_NS_CLASS_ENTRY(ce, "PSpell", "Dictionary", class_PSpell_Dictionary_methods);
152152
class_entry = zend_register_internal_class_ex(&ce, NULL);
153153
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
154154

155155
return class_entry;
156156
}
157157

158-
static zend_class_entry *register_class_PSpellConfig(void)
158+
static zend_class_entry *register_class_PSpell_Config(void)
159159
{
160160
zend_class_entry ce, *class_entry;
161161

162-
INIT_CLASS_ENTRY(ce, "PSpellConfig", class_PSpellConfig_methods);
162+
INIT_NS_CLASS_ENTRY(ce, "PSpell", "Config", class_PSpell_Config_methods);
163163
class_entry = zend_register_internal_class_ex(&ce, NULL);
164164
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
165165

ext/pspell/tests/003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var_dump(pspell_config_ignore($cfg, PHP_INT_MAX));
3434
bool(false)
3535

3636
Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9
37-
pspell_check(): Argument #1 ($dictionary) must be of type PSpell, bool given
37+
pspell_check(): Argument #1 ($dictionary) must be of type PSpell\Dictionary, bool given
3838
---
3939
bool(true)
4040
bool(true)

0 commit comments

Comments
 (0)