From: Máté Kocsis Date: Sat, 12 Oct 2019 19:53:15 +0000 (+0200) Subject: Add stubs for various intl functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e08ce4c13db6e9aecd3497cd270b72d06c649bc7;p=php Add stubs for various intl functions Closes GH-4819 - Add stubs for idn functions - Add stubs for grapheme functions - Add stubs for Spoofchecker - Add stubs for Normalizer - Add stubs for ResourceBundle - Fix arginfos - Add support for union return types - Fix arginfo for resourcebundle_create() --- diff --git a/ext/intl/grapheme/grapheme.stub.php b/ext/intl/grapheme/grapheme.stub.php new file mode 100644 index 0000000000..669b590437 --- /dev/null +++ b/ext/intl/grapheme/grapheme.stub.php @@ -0,0 +1,19 @@ += 56 + /** @return string|null */ + public static function getRawDecomposition(string $input, int $form = Normalizer::FORM_C) {} +#endif +} + +function normalizer_normalize(string $input, int $form = Normalizer::FORM_C): string|false {} + +function normalizer_is_normalized(string $input, int $form = Normalizer::FORM_C): bool {} + +#if U_ICU_VERSION_MAJOR_NUM >= 56 +function normalizer_get_raw_decomposition(string $input, int $form = Normalizer::FORM_C): ?string {} +#endif diff --git a/ext/intl/normalizer/normalizer_arginfo.h b/ext/intl/normalizer/normalizer_arginfo.h new file mode 100644 index 0000000000..858b2fe12d --- /dev/null +++ b/ext/intl/normalizer/normalizer_arginfo.h @@ -0,0 +1,32 @@ +/* This is a generated file, edit the .stub.php file instead. */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Normalizer_normalize, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, form, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Normalizer_isNormalized arginfo_class_Normalizer_normalize + +#if U_ICU_VERSION_MAJOR_NUM >= 56 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Normalizer_getRawDecomposition, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, form, IS_LONG, 0) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, form, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_normalizer_is_normalized, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, form, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#if U_ICU_VERSION_MAJOR_NUM >= 56 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_normalizer_get_raw_decomposition, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, form, IS_LONG, 0) +ZEND_END_ARG_INFO() +#endif diff --git a/ext/intl/normalizer/normalizer_class.c b/ext/intl/normalizer/normalizer_class.c index ec96a163e9..0b6033893c 100644 --- a/ext/intl/normalizer/normalizer_class.c +++ b/ext/intl/normalizer/normalizer_class.c @@ -15,6 +15,7 @@ #include "normalizer_class.h" #include "php_intl.h" #include "normalizer_normalize.h" +#include "normalizer_arginfo.h" #include "intl_error.h" #include @@ -25,30 +26,15 @@ zend_class_entry *Normalizer_ce_ptr = NULL; * 'Normalizer' class registration structures & functions */ -/* {{{ Normalizer methods arguments info */ - -ZEND_BEGIN_ARG_INFO_EX( normalizer_args, 0, 0, 1 ) - ZEND_ARG_INFO( 0, input ) - ZEND_ARG_INFO( 0, form ) -ZEND_END_ARG_INFO() - -#if U_ICU_VERSION_MAJOR_NUM >= 56 -ZEND_BEGIN_ARG_INFO_EX( decomposition_args, 0, 0, 1 ) - ZEND_ARG_INFO( 0, input ) -ZEND_END_ARG_INFO(); -#endif - -/* }}} */ - /* {{{ Normalizer_class_functions * Every 'Normalizer' class method has an entry in this table */ static const zend_function_entry Normalizer_class_functions[] = { - ZEND_FENTRY( normalize, ZEND_FN( normalizer_normalize ), normalizer_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) - ZEND_FENTRY( isNormalized, ZEND_FN( normalizer_is_normalized ), normalizer_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) + ZEND_FENTRY( normalize, ZEND_FN( normalizer_normalize ), arginfo_class_Normalizer_normalize, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) + ZEND_FENTRY( isNormalized, ZEND_FN( normalizer_is_normalized ), arginfo_class_Normalizer_isNormalized, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) #if U_ICU_VERSION_MAJOR_NUM >= 56 - ZEND_FENTRY( getRawDecomposition, ZEND_FN( normalizer_get_raw_decomposition ), decomposition_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) + ZEND_FENTRY( getRawDecomposition, ZEND_FN( normalizer_get_raw_decomposition ), arginfo_class_Normalizer_getRawDecomposition, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) #endif PHP_FE_END }; diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 95481aab79..9d963449a5 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -42,6 +42,7 @@ #include "formatter/formatter_parse.h" #include "grapheme/grapheme.h" +#include "grapheme/grapheme_arginfo.h" #include "msgformat/msgformat.h" #include "msgformat/msgformat_class.h" @@ -52,6 +53,7 @@ #include "normalizer/normalizer.h" #include "normalizer/normalizer_class.h" #include "normalizer/normalizer_normalize.h" +#include "normalizer/normalizer_arginfo.h" #include "locale/locale.h" #include "locale/locale_class.h" @@ -68,6 +70,7 @@ #include "dateformat/dateformat_data.h" #include "resourcebundle/resourcebundle_class.h" +#include "resourcebundle/resourcebundle_arginfo.h" #include "transliterator/transliterator.h" #include "transliterator/transliterator_class.h" @@ -85,6 +88,7 @@ #include "breakiterator/breakiterator_iterators.h" #include "idn/idn.h" +#include "idn/idn_arginfo.h" #include "uchar/uchar.h" # include "spoofchecker/spoofchecker_class.h" @@ -173,47 +177,6 @@ ZEND_END_ARG_INFO() #define intl_0_args collator_static_0_args #define intl_1_arg collator_static_1_arg -ZEND_BEGIN_ARG_INFO_EX(normalizer_args, 0, 0, 1) - ZEND_ARG_INFO(0, input) - ZEND_ARG_INFO(0, form) -ZEND_END_ARG_INFO() - -#if U_ICU_VERSION_MAJOR_NUM >= 56 -ZEND_BEGIN_ARG_INFO_EX(decomposition_args, 0, 0, 1) - ZEND_ARG_INFO(0, input) -ZEND_END_ARG_INFO(); -#endif - -ZEND_BEGIN_ARG_INFO_EX(grapheme_1_arg, 0, 0, 1) - ZEND_ARG_INFO(0, string) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(grapheme_search_args, 0, 0, 2) - ZEND_ARG_INFO(0, haystack) - ZEND_ARG_INFO(0, needle) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(grapheme_substr_args, 0, 0, 2) - ZEND_ARG_INFO(0, string) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, length) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(grapheme_strstr_args, 0, 0, 2) - ZEND_ARG_INFO(0, haystack) - ZEND_ARG_INFO(0, needle) - ZEND_ARG_INFO(0, before_needle) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(grapheme_extract_args, 0, 0, 2) - ZEND_ARG_INFO(0, arg1) - ZEND_ARG_INFO(0, arg2) - ZEND_ARG_INFO(0, arg3) - ZEND_ARG_INFO(0, arg4) - ZEND_ARG_INFO(1, arg5) /* 1 = pass by reference */ -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(datefmt_parse_args, 0, 0, 2) ZEND_ARG_INFO(0, formatter) ZEND_ARG_INFO(0, string) @@ -349,41 +312,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_create, 0, 0, 3) ZEND_ARG_INFO(0, pattern) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_ascii, 0, 0, 1) - ZEND_ARG_INFO(0, domain) - ZEND_ARG_INFO(0, option) - ZEND_ARG_INFO(0, variant) - ZEND_ARG_INFO(1, idn_info) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_create_proc, 0, 0, 2 ) - ZEND_ARG_INFO( 0, locale ) - ZEND_ARG_INFO( 0, bundlename ) - ZEND_ARG_INFO( 0, fallback ) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_proc, 0, 0, 2 ) - ZEND_ARG_INFO( 0, bundle ) - ZEND_ARG_INFO( 0, index ) - ZEND_ARG_INFO( 0, fallback ) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count_proc, 0, 0, 1 ) - ZEND_ARG_INFO( 0, bundle ) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_locales_proc, 0, 0, 1 ) - ZEND_ARG_INFO( 0, bundlename ) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code_proc, 0, 0, 1 ) - ZEND_ARG_INFO( 0, bundle ) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message_proc, 0, 0, 1 ) - ZEND_ARG_INFO( 0, bundle ) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_void, 0, 0, 0 ) ZEND_END_ARG_INFO() @@ -583,10 +511,10 @@ static const zend_function_entry intl_functions[] = { PHP_FE( numfmt_get_error_message, arginfo_numfmt_get_error_code ) /* normalizer functions */ - PHP_FE( normalizer_normalize, normalizer_args ) - PHP_FE( normalizer_is_normalized, normalizer_args ) + PHP_FE( normalizer_normalize, arginfo_normalizer_normalize ) + PHP_FE( normalizer_is_normalized, arginfo_normalizer_is_normalized ) #if U_ICU_VERSION_MAJOR_NUM >= 56 - PHP_FE( normalizer_get_raw_decomposition, decomposition_args ) + PHP_FE( normalizer_get_raw_decomposition, arginfo_normalizer_get_raw_decomposition ) #endif /* Locale functions */ @@ -644,27 +572,27 @@ static const zend_function_entry intl_functions[] = { PHP_FE( datefmt_get_error_message, arginfo_msgfmt_get_error_message ) /* grapheme functions */ - PHP_FE( grapheme_strlen, grapheme_1_arg ) - PHP_FE( grapheme_strpos, grapheme_search_args ) - PHP_FE( grapheme_stripos, grapheme_search_args ) - PHP_FE( grapheme_strrpos, grapheme_search_args ) - PHP_FE( grapheme_strripos, grapheme_search_args ) - PHP_FE( grapheme_substr, grapheme_substr_args ) - PHP_FE( grapheme_strstr, grapheme_strstr_args ) - PHP_FE( grapheme_stristr, grapheme_strstr_args ) - PHP_FE( grapheme_extract, grapheme_extract_args ) + PHP_FE( grapheme_strlen, arginfo_grapheme_strlen ) + PHP_FE( grapheme_strpos, arginfo_grapheme_strpos ) + PHP_FE( grapheme_stripos, arginfo_grapheme_stripos ) + PHP_FE( grapheme_strrpos, arginfo_grapheme_strrpos ) + PHP_FE( grapheme_strripos, arginfo_grapheme_strripos ) + PHP_FE( grapheme_substr, arginfo_grapheme_substr ) + PHP_FE( grapheme_strstr, arginfo_grapheme_strstr ) + PHP_FE( grapheme_stristr, arginfo_grapheme_stristr ) + PHP_FE( grapheme_extract, arginfo_grapheme_extract ) /* IDN functions */ PHP_FE( idn_to_ascii, arginfo_idn_to_ascii) - PHP_FE( idn_to_utf8, arginfo_idn_to_ascii) + PHP_FE( idn_to_utf8, arginfo_idn_to_utf8) /* ResourceBundle functions */ - PHP_FE( resourcebundle_create, arginfo_resourcebundle_create_proc ) - PHP_FE( resourcebundle_get, arginfo_resourcebundle_get_proc ) - PHP_FE( resourcebundle_count, arginfo_resourcebundle_count_proc ) - PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales_proc ) - PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code_proc ) - PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message_proc ) + PHP_FE( resourcebundle_create, arginfo_resourcebundle_create ) + PHP_FE( resourcebundle_get, arginfo_resourcebundle_get ) + PHP_FE( resourcebundle_count, arginfo_resourcebundle_count ) + PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales ) + PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code ) + PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message ) /* Transliterator functions */ PHP_FE( transliterator_create, arginfo_transliterator_create ) diff --git a/ext/intl/resourcebundle/resourcebundle.stub.php b/ext/intl/resourcebundle/resourcebundle.stub.php new file mode 100644 index 0000000000..f3f0dcef1a --- /dev/null +++ b/ext/intl/resourcebundle/resourcebundle.stub.php @@ -0,0 +1,43 @@ += 58 + /** @return null|false */ + public function setRestrictionLevel(int $level) {} +#endif +} diff --git a/ext/intl/spoofchecker/spoofchecker_arginfo.h b/ext/intl/spoofchecker/spoofchecker_arginfo.h new file mode 100644 index 0000000000..8572460fd3 --- /dev/null +++ b/ext/intl/spoofchecker/spoofchecker_arginfo.h @@ -0,0 +1,29 @@ +/* This is a generated file, edit the .stub.php file instead. */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker_isSuspicious, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) + ZEND_ARG_INFO(1, error) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker_areConfusable, 0, 0, 2) + ZEND_ARG_TYPE_INFO(0, s1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, s2, IS_STRING, 0) + ZEND_ARG_INFO(1, error) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker_setAllowedLocales, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, locale_list, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker_setChecks, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, checks, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#if U_ICU_VERSION_MAJOR_NUM >= 58 +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker_setRestrictionLevel, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0) +ZEND_END_ARG_INFO() +#endif diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index 87f40fef49..e6fdcefa08 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -15,6 +15,7 @@ #include "spoofchecker_class.h" #include "spoofchecker_main.h" #include "spoofchecker_create.h" +#include "spoofchecker_arginfo.h" #include "php_intl.h" #include "intl_error.h" @@ -58,49 +59,18 @@ zend_object *Spoofchecker_object_create(zend_class_entry *ce) * 'Spoofchecker' class registration structures & functions */ -/* {{{ Spoofchecker methods arguments info */ -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_0_args, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_checks, 0, 0, 1) - ZEND_ARG_INFO(0, checks) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_allowed_locales, 0, 0, 1) - ZEND_ARG_INFO(0, locale_list) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_is_suspicous, 0, 0, 1) - ZEND_ARG_INFO(0, text) - ZEND_ARG_INFO(1, error) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_are_confusable, 0, 0, 2) - ZEND_ARG_INFO(0, s1) - ZEND_ARG_INFO(0, s2) - ZEND_ARG_INFO(1, error) -ZEND_END_ARG_INFO() - -#if U_ICU_VERSION_MAJOR_NUM >= 58 -ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_restriction_level, 0, 0, 1) - ZEND_ARG_INFO(0, level) -ZEND_END_ARG_INFO() -#endif - -/* }}} */ - /* {{{ Spoofchecker_class_functions * Every 'Spoofchecker' class method has an entry in this table */ static const zend_function_entry Spoofchecker_class_functions[] = { - PHP_ME(Spoofchecker, __construct, spoofchecker_0_args, ZEND_ACC_PUBLIC) - PHP_ME(Spoofchecker, isSuspicious, spoofchecker_is_suspicous, ZEND_ACC_PUBLIC) - PHP_ME(Spoofchecker, areConfusable, spoofchecker_are_confusable, ZEND_ACC_PUBLIC) - PHP_ME(Spoofchecker, setAllowedLocales, spoofchecker_set_allowed_locales, ZEND_ACC_PUBLIC) - PHP_ME(Spoofchecker, setChecks, spoofchecker_set_checks, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, __construct, arginfo_class_Spoofchecker___construct, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, isSuspicious, arginfo_class_Spoofchecker_isSuspicious, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, areConfusable, arginfo_class_Spoofchecker_areConfusable, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, setAllowedLocales, arginfo_class_Spoofchecker_setAllowedLocales, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, setChecks, arginfo_class_Spoofchecker_setChecks, ZEND_ACC_PUBLIC) #if U_ICU_VERSION_MAJOR_NUM >= 58 - PHP_ME(Spoofchecker, setRestrictionLevel, spoofchecker_set_restriction_level, ZEND_ACC_PUBLIC) + PHP_ME(Spoofchecker, setRestrictionLevel, arginfo_class_Spoofchecker_setRestrictionLevel, ZEND_ACC_PUBLIC) #endif PHP_FE_END };