diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index 93e5833fa02f0..3b1c8941291ab 100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 @@ -27,7 +27,6 @@ if test "$PHP_INTL" != "no"; then formatter/formatter_data.c \ formatter/formatter_format.c \ formatter/formatter_parse.c \ - normalizer/normalizer.c \ normalizer/normalizer_class.c \ normalizer/normalizer_normalize.c \ locale/locale.c \ diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index e072f46979c21..18ea96ea476b4 100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 @@ -53,7 +53,6 @@ if (PHP_INTL != "no") { grapheme_string.c grapheme_util.c \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/normalizer", "\ - normalizer.c \ normalizer_class.c \ normalizer_normalize.c \ ", "intl"); diff --git a/ext/intl/normalizer/normalizer.c b/ext/intl/normalizer/normalizer.c deleted file mode 100644 index 177070df54614..0000000000000 --- a/ext/intl/normalizer/normalizer.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | https://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Ed Batutis | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "normalizer_class.h" -#include "normalizer.h" - -#include -#include -#include - -/* {{{ normalizer_register_constants - * Register constants common for the both (OO and procedural) - * APIs. - */ -void normalizer_register_constants( INIT_FUNC_ARGS ) -{ - if( !Normalizer_ce_ptr ) - { - zend_error( E_ERROR, "Normalizer class not defined" ); - return; - } - - #define NORMALIZER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS) - #define NORMALIZER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( #x ) - 1, NORMALIZER_##x ); - #define NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( name ) - 1, value ); - - /* Normalization form constants */ - NORMALIZER_EXPOSE_CLASS_CONST( FORM_D ); - NORMALIZER_EXPOSE_CLASS_CONST( NFD ); - NORMALIZER_EXPOSE_CLASS_CONST( FORM_KD ); - NORMALIZER_EXPOSE_CLASS_CONST( NFKD ); - NORMALIZER_EXPOSE_CLASS_CONST( FORM_C ); - NORMALIZER_EXPOSE_CLASS_CONST( NFC ); - NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC ); - NORMALIZER_EXPOSE_CLASS_CONST( NFKC ); -#if U_ICU_VERSION_MAJOR_NUM >= 56 - NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC_CF ); - NORMALIZER_EXPOSE_CLASS_CONST( NFKC_CF ); -#endif - - #undef NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST - #undef NORMALIZER_EXPOSE_CLASS_CONST - #undef NORMALIZER_EXPOSE_CONST -} -/* }}} */ diff --git a/ext/intl/normalizer/normalizer.h b/ext/intl/normalizer/normalizer.h index 9d8472f10cd1b..9e71f04aaed83 100644 --- a/ext/intl/normalizer/normalizer.h +++ b/ext/intl/normalizer/normalizer.h @@ -45,6 +45,4 @@ #define NORMALIZER_DEFAULT NORMALIZER_FORM_C #endif -void normalizer_register_constants( INIT_FUNC_ARGS ); - #endif // NORMALIZER_NORMALIZER_H diff --git a/ext/intl/normalizer/normalizer.stub.php b/ext/intl/normalizer/normalizer.stub.php index 75052535fc43b..d510c388b1337 100644 --- a/ext/intl/normalizer/normalizer.stub.php +++ b/ext/intl/normalizer/normalizer.stub.php @@ -4,6 +4,59 @@ class Normalizer { + /** + * @var int + * @cvalue NORMALIZER_FORM_D + */ + public const FORM_D = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_NFD + */ + public const NFD = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_FORM_KD + */ + public const FORM_KD = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_NFKD + */ + public const NFKD = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_FORM_C + */ + public const FORM_C = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_NFC + */ + public const NFC = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_FORM_KC + */ + public const FORM_KC = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_NFKC + */ + public const NFKC = UNKNOWN; +#if U_ICU_VERSION_MAJOR_NUM >= 56 + /** + * @var int + * @cvalue NORMALIZER_FORM_KC_CF + */ + public const FORM_KC_CF = UNKNOWN; + /** + * @var int + * @cvalue NORMALIZER_NFKC_CF + */ + public const NFKC_CF = UNKNOWN; +#endif + /** * @tentative-return-type * @alias normalizer_normalize diff --git a/ext/intl/normalizer/normalizer_arginfo.h b/ext/intl/normalizer/normalizer_arginfo.h index 70262b0ffc97a..1281c1c5e23f6 100644 --- a/ext/intl/normalizer/normalizer_arginfo.h +++ b/ext/intl/normalizer/normalizer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 71dd44d3b839789639c16a4b6d5b2e4f40703a74 */ + * Stub hash: 451d8875edd23e737c147fb9aab37aa8220d731d */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) @@ -42,5 +42,69 @@ static zend_class_entry *register_class_Normalizer(void) INIT_CLASS_ENTRY(ce, "Normalizer", class_Normalizer_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + zval const_FORM_D_value; + ZVAL_LONG(&const_FORM_D_value, NORMALIZER_FORM_D); + zend_string *const_FORM_D_name = zend_string_init_interned("FORM_D", sizeof("FORM_D") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FORM_D_name, &const_FORM_D_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FORM_D_name); + + zval const_NFD_value; + ZVAL_LONG(&const_NFD_value, NORMALIZER_NFD); + zend_string *const_NFD_name = zend_string_init_interned("NFD", sizeof("NFD") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NFD_name, &const_NFD_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NFD_name); + + zval const_FORM_KD_value; + ZVAL_LONG(&const_FORM_KD_value, NORMALIZER_FORM_KD); + zend_string *const_FORM_KD_name = zend_string_init_interned("FORM_KD", sizeof("FORM_KD") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FORM_KD_name, &const_FORM_KD_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FORM_KD_name); + + zval const_NFKD_value; + ZVAL_LONG(&const_NFKD_value, NORMALIZER_NFKD); + zend_string *const_NFKD_name = zend_string_init_interned("NFKD", sizeof("NFKD") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NFKD_name, &const_NFKD_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NFKD_name); + + zval const_FORM_C_value; + ZVAL_LONG(&const_FORM_C_value, NORMALIZER_FORM_C); + zend_string *const_FORM_C_name = zend_string_init_interned("FORM_C", sizeof("FORM_C") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FORM_C_name, &const_FORM_C_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FORM_C_name); + + zval const_NFC_value; + ZVAL_LONG(&const_NFC_value, NORMALIZER_NFC); + zend_string *const_NFC_name = zend_string_init_interned("NFC", sizeof("NFC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NFC_name, &const_NFC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NFC_name); + + zval const_FORM_KC_value; + ZVAL_LONG(&const_FORM_KC_value, NORMALIZER_FORM_KC); + zend_string *const_FORM_KC_name = zend_string_init_interned("FORM_KC", sizeof("FORM_KC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FORM_KC_name, &const_FORM_KC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FORM_KC_name); + + zval const_NFKC_value; + ZVAL_LONG(&const_NFKC_value, NORMALIZER_NFKC); + zend_string *const_NFKC_name = zend_string_init_interned("NFKC", sizeof("NFKC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NFKC_name, &const_NFKC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NFKC_name); +#if U_ICU_VERSION_MAJOR_NUM >= 56 + + zval const_FORM_KC_CF_value; + ZVAL_LONG(&const_FORM_KC_CF_value, NORMALIZER_FORM_KC_CF); + zend_string *const_FORM_KC_CF_name = zend_string_init_interned("FORM_KC_CF", sizeof("FORM_KC_CF") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FORM_KC_CF_name, &const_FORM_KC_CF_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FORM_KC_CF_name); +#endif +#if U_ICU_VERSION_MAJOR_NUM >= 56 + + zval const_NFKC_CF_value; + ZVAL_LONG(&const_NFKC_CF_value, NORMALIZER_NFKC_CF); + zend_string *const_NFKC_CF_name = zend_string_init_interned("NFKC_CF", sizeof("NFKC_CF") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NFKC_CF_name, &const_NFKC_CF_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NFKC_CF_name); +#endif + return class_entry; } diff --git a/ext/intl/normalizer/normalizer_class.c b/ext/intl/normalizer/normalizer_class.c index 5835aa3a98313..d9e413d5e5146 100644 --- a/ext/intl/normalizer/normalizer_class.c +++ b/ext/intl/normalizer/normalizer_class.c @@ -12,6 +12,7 @@ +----------------------------------------------------------------------+ */ +#include "normalizer.h" #include "normalizer_class.h" #include "php_intl.h" #include "normalizer_arginfo.h" diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index bdaf7760254c2..6eedfb585cb09 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -36,7 +36,6 @@ #include "msgformat/msgformat_class.h" -#include "normalizer/normalizer.h" #include "normalizer/normalizer_class.h" #include "locale/locale.h" @@ -159,9 +158,6 @@ PHP_MINIT_FUNCTION( intl ) /* Register 'Normalizer' PHP class */ normalizer_register_Normalizer_class( ); - /* Expose Normalizer constants to PHP scripts */ - normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU ); - /* Register 'Locale' PHP class */ locale_register_Locale_class( );