Skip to content

Commit db90744

Browse files
committed
Add stubs for ResourceBundle
1 parent 41ab446 commit db90744

File tree

4 files changed

+105
-77
lines changed

4 files changed

+105
-77
lines changed

ext/intl/php_intl.c

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "dateformat/dateformat_data.h"
7070

7171
#include "resourcebundle/resourcebundle_class.h"
72+
#include "resourcebundle/resourcebundle_arginfo.h"
7273

7374
#include "transliterator/transliterator.h"
7475
#include "transliterator/transliterator_class.h"
@@ -335,34 +336,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_create, 0, 0, 3)
335336
ZEND_ARG_INFO(0, pattern)
336337
ZEND_END_ARG_INFO()
337338

338-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_create_proc, 0, 0, 2 )
339-
ZEND_ARG_INFO( 0, locale )
340-
ZEND_ARG_INFO( 0, bundlename )
341-
ZEND_ARG_INFO( 0, fallback )
342-
ZEND_END_ARG_INFO()
343-
344-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_proc, 0, 0, 2 )
345-
ZEND_ARG_INFO( 0, bundle )
346-
ZEND_ARG_INFO( 0, index )
347-
ZEND_ARG_INFO( 0, fallback )
348-
ZEND_END_ARG_INFO()
349-
350-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count_proc, 0, 0, 1 )
351-
ZEND_ARG_INFO( 0, bundle )
352-
ZEND_END_ARG_INFO()
353-
354-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_locales_proc, 0, 0, 1 )
355-
ZEND_ARG_INFO( 0, bundlename )
356-
ZEND_END_ARG_INFO()
357-
358-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code_proc, 0, 0, 1 )
359-
ZEND_ARG_INFO( 0, bundle )
360-
ZEND_END_ARG_INFO()
361-
362-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message_proc, 0, 0, 1 )
363-
ZEND_ARG_INFO( 0, bundle )
364-
ZEND_END_ARG_INFO()
365-
366339
ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_void, 0, 0, 0 )
367340
ZEND_END_ARG_INFO()
368341

@@ -638,12 +611,12 @@ static const zend_function_entry intl_functions[] = {
638611
PHP_FE( idn_to_utf8, arginfo_idn_to_utf8)
639612

640613
/* ResourceBundle functions */
641-
PHP_FE( resourcebundle_create, arginfo_resourcebundle_create_proc )
642-
PHP_FE( resourcebundle_get, arginfo_resourcebundle_get_proc )
643-
PHP_FE( resourcebundle_count, arginfo_resourcebundle_count_proc )
644-
PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales_proc )
645-
PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code_proc )
646-
PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message_proc )
614+
PHP_FE( resourcebundle_create, arginfo_resourcebundle_create )
615+
PHP_FE( resourcebundle_get, arginfo_resourcebundle_get )
616+
PHP_FE( resourcebundle_count, arginfo_resourcebundle_count )
617+
PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales )
618+
PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code )
619+
PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message )
647620

648621
/* Transliterator functions */
649622
PHP_FE( transliterator_create, arginfo_transliterator_create )
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
class ResourceBundle implements Traversable
4+
{
5+
public function __construct(?string $locale, ?string $bundlename, bool $fallback = true) {}
6+
7+
/** @return ResourceBundle|false|null */
8+
public static function create(?string $locale, ?string $bundlename, bool $fallback = true) {}
9+
10+
/**
11+
* @param string|int $index
12+
* @return mixed
13+
*/
14+
public function get($index, bool $fallback = true) {}
15+
16+
/** @return int */
17+
public function count() {}
18+
19+
/** @return array|false */
20+
public static function getLocales(string $bundlename) {}
21+
22+
/** @return int */
23+
public function getErrorCode() {}
24+
25+
/** @return string */
26+
public function getErrorMessage() {}
27+
}
28+
29+
/** @return ResourceBundle|false|null */
30+
function resourcebundle_create(?string $locale, ?string $bundlename, bool $fallback = true) {}
31+
32+
/**
33+
* @param string|int $index
34+
* @return ResourceBundle|false|null
35+
*/
36+
function resourcebundle_get(ResourceBundle $bundle, $index) {}
37+
38+
/** @return int */
39+
function resourcebundle_count(ResourceBundle $bundle) {}
40+
41+
/** @return array|false */
42+
function resourcebundle_locales(string $bundlename) {}
43+
44+
/** @return int */
45+
function resourcebundle_get_error_code(ResourceBundle $bundle) {}
46+
47+
/** @return string */
48+
function resourcebundle_get_error_message(ResourceBundle $bundle) {}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle___construct, 0, 0, 2)
4+
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
5+
ZEND_ARG_TYPE_INFO(0, bundlename, IS_STRING, 1)
6+
ZEND_ARG_TYPE_INFO(0, fallback, _IS_BOOL, 0)
7+
ZEND_END_ARG_INFO()
8+
9+
#define arginfo_class_ResourceBundle_create arginfo_class_ResourceBundle___construct
10+
11+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle_get, 0, 0, 1)
12+
ZEND_ARG_INFO(0, index)
13+
ZEND_ARG_TYPE_INFO(0, fallback, _IS_BOOL, 0)
14+
ZEND_END_ARG_INFO()
15+
16+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle_count, 0, 0, 0)
17+
ZEND_END_ARG_INFO()
18+
19+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle_getLocales, 0, 0, 1)
20+
ZEND_ARG_TYPE_INFO(0, bundlename, IS_STRING, 0)
21+
ZEND_END_ARG_INFO()
22+
23+
#define arginfo_class_ResourceBundle_getErrorCode arginfo_class_ResourceBundle_count
24+
25+
#define arginfo_class_ResourceBundle_getErrorMessage arginfo_class_ResourceBundle_count
26+
27+
#define arginfo_resourcebundle_create arginfo_class_ResourceBundle___construct
28+
29+
ZEND_BEGIN_ARG_INFO_EX(arginfo_resourcebundle_get, 0, 0, 2)
30+
ZEND_ARG_OBJ_INFO(0, bundle, ResourceBundle, 0)
31+
ZEND_ARG_INFO(0, index)
32+
ZEND_END_ARG_INFO()
33+
34+
ZEND_BEGIN_ARG_INFO_EX(arginfo_resourcebundle_count, 0, 0, 1)
35+
ZEND_ARG_OBJ_INFO(0, bundle, ResourceBundle, 0)
36+
ZEND_END_ARG_INFO()
37+
38+
#define arginfo_resourcebundle_locales arginfo_class_ResourceBundle_getLocales
39+
40+
#define arginfo_resourcebundle_get_error_code arginfo_resourcebundle_count
41+
42+
#define arginfo_resourcebundle_get_error_message arginfo_resourcebundle_count

ext/intl/resourcebundle/resourcebundle_class.c

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "resourcebundle/resourcebundle.h"
2929
#include "resourcebundle/resourcebundle_iterator.h"
3030
#include "resourcebundle/resourcebundle_class.h"
31+
#include "resourcebundle/resourcebundle_arginfo.h"
3132

3233
zend_class_entry *ResourceBundle_ce_ptr = NULL;
3334

@@ -131,14 +132,6 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
131132
}
132133
/* }}} */
133134

134-
/* {{{ arginfo_resourcebundle__construct */
135-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle___construct, 0, 0, 2 )
136-
ZEND_ARG_INFO( 0, locale )
137-
ZEND_ARG_INFO( 0, bundlename )
138-
ZEND_ARG_INFO( 0, fallback )
139-
ZEND_END_ARG_INFO()
140-
/* }}} */
141-
142135
/* {{{ proto ResourceBundle::__construct( string $locale [, string $bundlename [, bool $fallback = true ]] )
143136
* ResourceBundle object constructor
144137
*/
@@ -236,13 +229,6 @@ zval *resourcebundle_array_get(zend_object *object, zval *offset, int type, zval
236229
}
237230
/* }}} */
238231

239-
/* {{{ arginfo_resourcebundle_get */
240-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get, 0, 0, 1 )
241-
ZEND_ARG_INFO( 0, index )
242-
ZEND_ARG_INFO( 0, fallback )
243-
ZEND_END_ARG_INFO()
244-
/* }}} */
245-
246232
/* {{{ proto mixed ResourceBundle::get( int|string $resindex [, bool $fallback = true ] )
247233
* proto mixed resourcebundle_get( ResourceBundle $rb, int|string $resindex [, bool $fallback = true ] )
248234
* Get resource identified by numerical index or key name.
@@ -278,11 +264,6 @@ int resourcebundle_array_count(zend_object *object, zend_long *count)
278264
}
279265
/* }}} */
280266

281-
/* {{{ arginfo_resourcebundle_count */
282-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count, 0, 0, 0 )
283-
ZEND_END_ARG_INFO()
284-
/* }}} */
285-
286267
/* {{{ proto int ResourceBundle::count()
287268
* proto int resourcebundle_count( ResourceBundle $bundle )
288269
* Get resources count
@@ -302,12 +283,6 @@ PHP_FUNCTION( resourcebundle_count )
302283
RETURN_LONG( len );
303284
}
304285

305-
/* {{{ arginfo_resourcebundle_getlocales */
306-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_getlocales, 0, 0, 1 )
307-
ZEND_ARG_INFO( 0, bundlename )
308-
ZEND_END_ARG_INFO()
309-
/* }}} */
310-
311286
/* {{{ proto array ResourceBundle::getLocales( string $bundlename )
312287
* proto array resourcebundle_locales( string $bundlename )
313288
* Get available locales from ResourceBundle name
@@ -352,11 +327,6 @@ PHP_FUNCTION( resourcebundle_locales )
352327
}
353328
/* }}} */
354329

355-
/* {{{ arginfo_resourcebundle_get_error_code */
356-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code, 0, 0, 0 )
357-
ZEND_END_ARG_INFO()
358-
/* }}} */
359-
360330
/* {{{ proto string ResourceBundle::getErrorCode( )
361331
* proto string resourcebundle_get_error_code( ResourceBundle $bundle )
362332
* Get text description for ResourceBundle's last error code.
@@ -377,11 +347,6 @@ PHP_FUNCTION( resourcebundle_get_error_code )
377347
}
378348
/* }}} */
379349

380-
/* {{{ arginfo_resourcebundle_get_error_message */
381-
ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message, 0, 0, 0 )
382-
ZEND_END_ARG_INFO()
383-
/* }}} */
384-
385350
/* {{{ proto string ResourceBundle::getErrorMessage( )
386351
* proto string resourcebundle_get_error_message( ResourceBundle $bundle )
387352
* Get text description for ResourceBundle's last error.
@@ -407,13 +372,13 @@ PHP_FUNCTION( resourcebundle_get_error_message )
407372
* Every 'ResourceBundle' class method has an entry in this table
408373
*/
409374
static const zend_function_entry ResourceBundle_class_functions[] = {
410-
PHP_ME( ResourceBundle, __construct, arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC )
411-
ZEND_NAMED_ME( create, ZEND_FN( resourcebundle_create ), arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
412-
ZEND_NAMED_ME( get, ZEND_FN(resourcebundle_get), arginfo_resourcebundle_get, ZEND_ACC_PUBLIC )
413-
ZEND_NAMED_ME( count, ZEND_FN(resourcebundle_count), arginfo_resourcebundle_count, ZEND_ACC_PUBLIC )
414-
ZEND_NAMED_ME( getLocales, ZEND_FN(resourcebundle_locales), arginfo_resourcebundle_getlocales, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
415-
ZEND_NAMED_ME( getErrorCode, ZEND_FN(resourcebundle_get_error_code), arginfo_resourcebundle_get_error_code, ZEND_ACC_PUBLIC )
416-
ZEND_NAMED_ME( getErrorMessage, ZEND_FN(resourcebundle_get_error_message), arginfo_resourcebundle_get_error_message, ZEND_ACC_PUBLIC )
375+
PHP_ME( ResourceBundle, __construct, arginfo_class_ResourceBundle___construct, ZEND_ACC_PUBLIC )
376+
ZEND_NAMED_ME( create, ZEND_FN( resourcebundle_create ), arginfo_class_ResourceBundle_create, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
377+
ZEND_NAMED_ME( get, ZEND_FN(resourcebundle_get), arginfo_class_ResourceBundle_get, ZEND_ACC_PUBLIC )
378+
ZEND_NAMED_ME( count, ZEND_FN(resourcebundle_count), arginfo_class_ResourceBundle_count, ZEND_ACC_PUBLIC )
379+
ZEND_NAMED_ME( getLocales, ZEND_FN(resourcebundle_locales), arginfo_class_ResourceBundle_getLocales, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
380+
ZEND_NAMED_ME( getErrorCode, ZEND_FN(resourcebundle_get_error_code), arginfo_class_ResourceBundle_getErrorCode, ZEND_ACC_PUBLIC )
381+
ZEND_NAMED_ME( getErrorMessage, ZEND_FN(resourcebundle_get_error_message), arginfo_class_ResourceBundle_getErrorMessage, ZEND_ACC_PUBLIC )
417382
PHP_FE_END
418383
};
419384
/* }}} */

0 commit comments

Comments
 (0)