Skip to content

Commit bdbaf6d

Browse files
committed
Add stubs for Collator
1 parent 735c4ca commit bdbaf6d

File tree

4 files changed

+218
-89
lines changed

4 files changed

+218
-89
lines changed

ext/intl/collator/collator.stub.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
class Collator
4+
{
5+
public function __construct(string $locale) {}
6+
7+
/** @return Collator|null */
8+
public static function create(string $locale) {}
9+
10+
/** @return int|false */
11+
public function compare(string $str1, string $str2) {}
12+
13+
/** @return bool */
14+
public function sort(array &$arr, $sort_flag = Collator::SORT_REGULAR) {}
15+
16+
/** @return bool */
17+
public function sortWithSortKeys(array &$arr) {}
18+
19+
/** @return bool */
20+
public function asort(array &$arr, int $sort_flag = Collator::SORT_REGULAR) {}
21+
22+
/** @return int|false */
23+
public function getAttribute(int $attr) {}
24+
25+
/** @return bool */
26+
public function setAttribute(int $attr, int $val) {}
27+
28+
/** @return int|false */
29+
public function getStrength() {}
30+
31+
/** @return bool */
32+
public function setStrength(int $strength) {}
33+
34+
/** @return string|false */
35+
public function getLocale(int $type) {}
36+
37+
/** @return int|false */
38+
public function getErrorCode() {}
39+
40+
/** @return string|false */
41+
public function getErrorMessage() {}
42+
43+
/** @return string|false */
44+
public function getSortKey(string $str) {}
45+
}
46+
47+
function collator_create(string $locale): ?Collator {}
48+
49+
/** @return int|false */
50+
function collator_compare(Collator $object, string $str1, string $str2) {}
51+
52+
/** @return int|false */
53+
function collator_get_attribute(Collator $object, int $attr) {}
54+
55+
function collator_set_attribute(Collator $object, int $attr, int $val): bool {}
56+
57+
/** @return int|false */
58+
function collator_get_strength(Collator $object) {}
59+
60+
function collator_set_strength(Collator $object, int $strength): bool {}
61+
62+
function collator_sort(Collator $object, array &$arr, int $sort_flag = Collator::SORT_REGULAR): bool {}
63+
64+
function collator_sort_with_sort_keys(Collator $object, array &$arr): bool {}
65+
66+
function collator_asort(Collator $object, array &$arr, int $sort_flag = Collator::SORT_REGULAR): bool {}
67+
68+
/** @return string|false */
69+
function collator_get_locale(Collator $object, int $type) {}
70+
71+
/** @return int|false */
72+
function collator_get_error_code(Collator $object) {}
73+
74+
/** @return string|false */
75+
function collator_get_error_message(Collator $object) {}
76+
77+
/** @return string|false */
78+
function collator_get_sort_key(Collator $object, string $str) {}

ext/intl/collator/collator_arginfo.h

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator___construct, 0, 0, 1)
4+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
5+
ZEND_END_ARG_INFO()
6+
7+
#define arginfo_class_Collator_create arginfo_class_Collator___construct
8+
9+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_compare, 0, 0, 2)
10+
ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
11+
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
12+
ZEND_END_ARG_INFO()
13+
14+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_sort, 0, 0, 1)
15+
ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0)
16+
ZEND_ARG_INFO(0, sort_flag)
17+
ZEND_END_ARG_INFO()
18+
19+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_sortWithSortKeys, 0, 0, 1)
20+
ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0)
21+
ZEND_END_ARG_INFO()
22+
23+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_asort, 0, 0, 1)
24+
ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0)
25+
ZEND_ARG_TYPE_INFO(0, sort_flag, IS_LONG, 0)
26+
ZEND_END_ARG_INFO()
27+
28+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_getAttribute, 0, 0, 1)
29+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
30+
ZEND_END_ARG_INFO()
31+
32+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_setAttribute, 0, 0, 2)
33+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
34+
ZEND_ARG_TYPE_INFO(0, val, IS_LONG, 0)
35+
ZEND_END_ARG_INFO()
36+
37+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_getStrength, 0, 0, 0)
38+
ZEND_END_ARG_INFO()
39+
40+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_setStrength, 0, 0, 1)
41+
ZEND_ARG_TYPE_INFO(0, strength, IS_LONG, 0)
42+
ZEND_END_ARG_INFO()
43+
44+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_getLocale, 0, 0, 1)
45+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
46+
ZEND_END_ARG_INFO()
47+
48+
#define arginfo_class_Collator_getErrorCode arginfo_class_Collator_getStrength
49+
50+
#define arginfo_class_Collator_getErrorMessage arginfo_class_Collator_getStrength
51+
52+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_getSortKey, 0, 0, 1)
53+
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
54+
ZEND_END_ARG_INFO()
55+
56+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_collator_create, 0, 1, Collator, 1)
57+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
58+
ZEND_END_ARG_INFO()
59+
60+
ZEND_BEGIN_ARG_INFO_EX(arginfo_collator_compare, 0, 0, 3)
61+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
62+
ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
63+
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
64+
ZEND_END_ARG_INFO()
65+
66+
ZEND_BEGIN_ARG_INFO_EX(arginfo_collator_get_attribute, 0, 0, 2)
67+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
68+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
69+
ZEND_END_ARG_INFO()
70+
71+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_collator_set_attribute, 0, 3, _IS_BOOL, 0)
72+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
73+
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
74+
ZEND_ARG_TYPE_INFO(0, val, IS_LONG, 0)
75+
ZEND_END_ARG_INFO()
76+
77+
ZEND_BEGIN_ARG_INFO_EX(arginfo_collator_get_strength, 0, 0, 1)
78+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
79+
ZEND_END_ARG_INFO()
80+
81+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_collator_set_strength, 0, 2, _IS_BOOL, 0)
82+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
83+
ZEND_ARG_TYPE_INFO(0, strength, IS_LONG, 0)
84+
ZEND_END_ARG_INFO()
85+
86+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_collator_sort, 0, 2, _IS_BOOL, 0)
87+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
88+
ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0)
89+
ZEND_ARG_TYPE_INFO(0, sort_flag, IS_LONG, 0)
90+
ZEND_END_ARG_INFO()
91+
92+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_collator_sort_with_sort_keys, 0, 2, _IS_BOOL, 0)
93+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
94+
ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0)
95+
ZEND_END_ARG_INFO()
96+
97+
#define arginfo_collator_asort arginfo_collator_sort
98+
99+
ZEND_BEGIN_ARG_INFO_EX(arginfo_collator_get_locale, 0, 0, 2)
100+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
101+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
102+
ZEND_END_ARG_INFO()
103+
104+
#define arginfo_collator_get_error_code arginfo_collator_get_strength
105+
106+
#define arginfo_collator_get_error_message arginfo_collator_get_strength
107+
108+
ZEND_BEGIN_ARG_INFO_EX(arginfo_collator_get_sort_key, 0, 0, 2)
109+
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
110+
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
111+
ZEND_END_ARG_INFO()

ext/intl/collator/collator_class.c

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "collator_locale.h"
2323
#include "collator_create.h"
2424
#include "collator_error.h"
25+
#include "collator_arginfo.h"
2526
#include "intl_error.h"
2627

2728
#include <unicode/ucol.h>
@@ -62,53 +63,25 @@ zend_object *Collator_object_create(zend_class_entry *ce )
6263
* 'Collator' class registration structures & functions
6364
*/
6465

65-
/* {{{ Collator methods arguments info */
66-
/* NOTE: modifying 'collator_XX_args' do not forget to
67-
modify approptiate 'collator_XX_args' for
68-
the procedural API.
69-
*/
70-
ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 0 )
71-
ZEND_END_ARG_INFO()
72-
73-
ZEND_BEGIN_ARG_INFO_EX( collator_1_arg, 0, 0, 1 )
74-
ZEND_ARG_INFO( 0, arg1 )
75-
ZEND_END_ARG_INFO()
76-
77-
ZEND_BEGIN_ARG_INFO_EX( collator_2_args, 0, 0, 2 )
78-
ZEND_ARG_INFO( 0, arg1 )
79-
ZEND_ARG_INFO( 0, arg2 )
80-
ZEND_END_ARG_INFO()
81-
82-
ZEND_BEGIN_ARG_INFO_EX( collator_sort_args, 0, 0, 1 )
83-
ZEND_ARG_ARRAY_INFO( 1, arr, 0 )
84-
ZEND_ARG_INFO( 0, flags )
85-
ZEND_END_ARG_INFO()
86-
87-
ZEND_BEGIN_ARG_INFO_EX( collator_sort_with_sort_keys_args, 0, 0, 1 )
88-
ZEND_ARG_ARRAY_INFO( 1, arr, 0 )
89-
ZEND_END_ARG_INFO()
90-
91-
/* }}} */
92-
9366
/* {{{ Collator_class_functions
9467
* Every 'Collator' class method has an entry in this table
9568
*/
9669

9770
static const zend_function_entry Collator_class_functions[] = {
98-
PHP_ME( Collator, __construct, collator_1_arg, ZEND_ACC_PUBLIC )
99-
ZEND_FENTRY( create, ZEND_FN( collator_create ), collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
100-
PHP_NAMED_FE( compare, ZEND_FN( collator_compare ), collator_2_args )
101-
PHP_NAMED_FE( sort, ZEND_FN( collator_sort ), collator_sort_args )
102-
PHP_NAMED_FE( sortWithSortKeys, ZEND_FN( collator_sort_with_sort_keys ), collator_sort_with_sort_keys_args )
103-
PHP_NAMED_FE( asort, ZEND_FN( collator_asort ), collator_sort_args )
104-
PHP_NAMED_FE( getAttribute, ZEND_FN( collator_get_attribute ), collator_1_arg )
105-
PHP_NAMED_FE( setAttribute, ZEND_FN( collator_set_attribute ), collator_2_args )
106-
PHP_NAMED_FE( getStrength, ZEND_FN( collator_get_strength ), collator_0_args )
107-
PHP_NAMED_FE( setStrength, ZEND_FN( collator_set_strength ), collator_1_arg )
108-
PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), collator_1_arg )
109-
PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), collator_0_args )
110-
PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), collator_0_args )
111-
PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_1_arg )
71+
PHP_ME( Collator, __construct, arginfo_class_Collator___construct, ZEND_ACC_PUBLIC )
72+
ZEND_FENTRY( create, ZEND_FN( collator_create ), arginfo_class_Collator_create, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
73+
PHP_NAMED_FE( compare, ZEND_FN( collator_compare ), arginfo_class_Collator_compare )
74+
PHP_NAMED_FE( sort, ZEND_FN( collator_sort ), arginfo_class_Collator_sort )
75+
PHP_NAMED_FE( sortWithSortKeys, ZEND_FN( collator_sort_with_sort_keys ), arginfo_class_Collator_sortWithSortKeys )
76+
PHP_NAMED_FE( asort, ZEND_FN( collator_asort ), arginfo_class_Collator_asort )
77+
PHP_NAMED_FE( getAttribute, ZEND_FN( collator_get_attribute ), arginfo_class_Collator_getAttribute )
78+
PHP_NAMED_FE( setAttribute, ZEND_FN( collator_set_attribute ), arginfo_class_Collator_setAttribute )
79+
PHP_NAMED_FE( getStrength, ZEND_FN( collator_get_strength ), arginfo_class_Collator_getStrength )
80+
PHP_NAMED_FE( setStrength, ZEND_FN( collator_set_strength ), arginfo_class_Collator_setStrength )
81+
PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), arginfo_class_Collator_getLocale )
82+
PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), arginfo_class_Collator_getErrorCode )
83+
PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), arginfo_class_Collator_getErrorMessage )
84+
PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), arginfo_class_Collator_getSortKey )
11285
PHP_FE_END
11386
};
11487
/* }}} */

ext/intl/php_intl.c

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "collator/collator_locale.h"
3232
#include "collator/collator_create.h"
3333
#include "collator/collator_error.h"
34+
#include "collator/collator_arginfo.h"
3435

3536
#include "converter/converter.h"
3637

@@ -121,40 +122,6 @@ const char *intl_locale_get_default( void )
121122
return INTL_G(default_locale);
122123
}
123124

124-
/* {{{ Arguments info */
125-
ZEND_BEGIN_ARG_INFO_EX(collator_static_0_args, 0, 0, 0)
126-
ZEND_END_ARG_INFO()
127-
128-
ZEND_BEGIN_ARG_INFO_EX(collator_static_1_arg, 0, 0, 1)
129-
ZEND_ARG_INFO(0, arg1)
130-
ZEND_END_ARG_INFO()
131-
132-
ZEND_BEGIN_ARG_INFO_EX(collator_0_args, 0, 0, 1)
133-
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
134-
ZEND_END_ARG_INFO()
135-
136-
ZEND_BEGIN_ARG_INFO_EX(collator_1_arg, 0, 0, 2)
137-
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
138-
ZEND_ARG_INFO(0, arg1)
139-
ZEND_END_ARG_INFO()
140-
141-
ZEND_BEGIN_ARG_INFO_EX(collator_2_args, 0, 0, 3)
142-
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
143-
ZEND_ARG_INFO(0, arg1)
144-
ZEND_ARG_INFO(0, arg2)
145-
ZEND_END_ARG_INFO()
146-
147-
ZEND_BEGIN_ARG_INFO_EX(collator_sort_args, 0, 0, 2)
148-
ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
149-
ZEND_ARG_ARRAY_INFO(1, arr, 0)
150-
ZEND_ARG_INFO(0, sort_flags)
151-
ZEND_END_ARG_INFO()
152-
153-
ZEND_BEGIN_ARG_INFO_EX(collator_sort_with_sort_keys_args, 0, 0, 2)
154-
ZEND_ARG_OBJ_INFO(0, coll, Collator, 0)
155-
ZEND_ARG_ARRAY_INFO(1, arr, 0)
156-
ZEND_END_ARG_INFO()
157-
158125
ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_arginfo, 0, 0, 2)
159126
ZEND_ARG_INFO(0, formatter)
160127
ZEND_ARG_INFO(0, string)
@@ -574,19 +541,19 @@ ZEND_END_ARG_INFO()
574541
static const zend_function_entry intl_functions[] = {
575542

576543
/* collator functions */
577-
PHP_FE( collator_create, collator_static_1_arg )
578-
PHP_FE( collator_compare, collator_2_args )
579-
PHP_FE( collator_get_attribute, collator_1_arg )
580-
PHP_FE( collator_set_attribute, collator_2_args )
581-
PHP_FE( collator_get_strength, collator_0_args )
582-
PHP_FE( collator_set_strength, collator_1_arg )
583-
PHP_FE( collator_sort, collator_sort_args )
584-
PHP_FE( collator_sort_with_sort_keys, collator_sort_with_sort_keys_args )
585-
PHP_FE( collator_asort, collator_sort_args )
586-
PHP_FE( collator_get_locale, collator_1_arg )
587-
PHP_FE( collator_get_error_code, collator_0_args )
588-
PHP_FE( collator_get_error_message, collator_0_args )
589-
PHP_FE( collator_get_sort_key, collator_1_arg )
544+
PHP_FE( collator_create, arginfo_collator_create )
545+
PHP_FE( collator_compare, arginfo_collator_compare )
546+
PHP_FE( collator_get_attribute, arginfo_collator_get_attribute )
547+
PHP_FE( collator_set_attribute, arginfo_collator_set_attribute )
548+
PHP_FE( collator_get_strength, arginfo_collator_get_strength )
549+
PHP_FE( collator_set_strength, arginfo_collator_set_strength )
550+
PHP_FE( collator_sort, arginfo_collator_sort )
551+
PHP_FE( collator_sort_with_sort_keys, arginfo_collator_sort_with_sort_keys )
552+
PHP_FE( collator_asort, arginfo_collator_asort )
553+
PHP_FE( collator_get_locale, arginfo_collator_get_locale )
554+
PHP_FE( collator_get_error_code, arginfo_collator_get_error_code )
555+
PHP_FE( collator_get_error_message, arginfo_collator_get_error_message )
556+
PHP_FE( collator_get_sort_key, arginfo_collator_get_sort_key )
590557

591558
/* formatter functions */
592559
PHP_FE( numfmt_create, arginfo_numfmt_create )

0 commit comments

Comments
 (0)