diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c index 784e972a96b9f..df4a886074463 100644 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.c @@ -21,51 +21,6 @@ #include "dateformat_class.h" #include "dateformat.h" -/* {{{ dateformat_register_constants - * Register constants common for the both (OO and procedural) - * APIs. - */ -void dateformat_register_constants( INIT_FUNC_ARGS ) -{ - if( IntlDateFormatter_ce_ptr == NULL) { - zend_error(E_ERROR, "DateFormat class not defined"); - return; - } - - #define DATEFORMATTER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS) - #define DATEFORMATTER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UDAT_##x ); - #define DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( name ) - 1, value ); - - #define DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST(x) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UCAL_##x ); - - /* UDateFormatStyle constants */ - DATEFORMATTER_EXPOSE_CLASS_CONST( FULL ); - DATEFORMATTER_EXPOSE_CLASS_CONST( LONG ); - DATEFORMATTER_EXPOSE_CLASS_CONST( MEDIUM ); - DATEFORMATTER_EXPOSE_CLASS_CONST( SHORT ); - DATEFORMATTER_EXPOSE_CLASS_CONST( NONE ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "RELATIVE_FULL", UDAT_FULL_RELATIVE ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "RELATIVE_LONG", UDAT_LONG_RELATIVE ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "RELATIVE_MEDIUM", UDAT_MEDIUM_RELATIVE ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "RELATIVE_SHORT", UDAT_SHORT_RELATIVE ); - -/* - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "GREGORIAN", DATEF_GREGORIAN ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "CUSTOMARY", DATEF_CUSTOMARY ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "BUDDHIST", DATEF_BUDDHIST ); - DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "JAPANESE_IMPERIAL", DATEF_JAPANESE_IMPERIAL ); -*/ - - DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST( GREGORIAN ); - DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST( TRADITIONAL ); - - #undef DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST - #undef DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST - #undef DATEFORMATTER_EXPOSE_CLASS_CONST - #undef DATEFORMATTER_EXPOSE_CONST -} -/* }}} */ - /* {{{ Get formatter's last error code. */ PHP_FUNCTION( datefmt_get_error_code ) { diff --git a/ext/intl/dateformat/dateformat.h b/ext/intl/dateformat/dateformat.h index 98da8185762a5..3e0b14cf6c0de 100644 --- a/ext/intl/dateformat/dateformat.h +++ b/ext/intl/dateformat/dateformat.h @@ -16,8 +16,6 @@ #include -void dateformat_register_constants( INIT_FUNC_ARGS ); - /* These are not necessary at this point of time #define DATEF_GREGORIAN 1 diff --git a/ext/intl/dateformat/dateformat.stub.php b/ext/intl/dateformat/dateformat.stub.php index 0ea15225f5a25..7664fa7297d8b 100644 --- a/ext/intl/dateformat/dateformat.stub.php +++ b/ext/intl/dateformat/dateformat.stub.php @@ -5,6 +5,63 @@ /** @not-serializable */ class IntlDateFormatter { + /** + * @var int + * @cvalue UDAT_FULL + */ + public const FULL = UNKNOWN; + /** + * @var int + * @cvalue UDAT_LONG + */ + public const LONG = UNKNOWN; + /** + * @var int + * @cvalue UDAT_MEDIUM + */ + public const MEDIUM = UNKNOWN; + /** + * @var int + * @cvalue UDAT_SHORT + */ + public const SHORT = UNKNOWN; + /** + * @var int + * @cvalue UDAT_NONE + */ + public const NONE = UNKNOWN; + /** + * @var int + * @cvalue UDAT_FULL_RELATIVE + */ + public const RELATIVE_FULL = UNKNOWN; + /** + * @var int + * @cvalue UDAT_LONG_RELATIVE + */ + public const RELATIVE_LONG = UNKNOWN; + /** + * @var int + * @cvalue UDAT_MEDIUM_RELATIVE + */ + public const RELATIVE_MEDIUM = UNKNOWN; + /** + * @var int + * @cvalue UDAT_SHORT_RELATIVE + */ + public const RELATIVE_SHORT = UNKNOWN; + + /** + * @var int + * @cvalue UCAL_GREGORIAN + */ + public const GREGORIAN = UNKNOWN; + /** + * @var int + * @cvalue UCAL_TRADITIONAL + */ + public const TRADITIONAL = UNKNOWN; + /** * @param IntlTimeZone|DateTimeZone|string|null $timezone * @param IntlCalendar|int|null $calendar diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h index 9cb936f530992..4a9727b7ecab3 100644 --- a/ext/intl/dateformat/dateformat_arginfo.h +++ b/ext/intl/dateformat/dateformat_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c7c0d08433ab9dbf59777072550895d85294aad4 */ + * Stub hash: 23a3a335af66ae42119678d03173ea83869d290c */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1) @@ -143,5 +143,71 @@ static zend_class_entry *register_class_IntlDateFormatter(void) class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE; + zval const_FULL_value; + ZVAL_LONG(&const_FULL_value, UDAT_FULL); + zend_string *const_FULL_name = zend_string_init_interned("FULL", sizeof("FULL") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_FULL_name, &const_FULL_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_FULL_name); + + zval const_LONG_value; + ZVAL_LONG(&const_LONG_value, UDAT_LONG); + zend_string *const_LONG_name = zend_string_init_interned("LONG", sizeof("LONG") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_LONG_name, &const_LONG_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_LONG_name); + + zval const_MEDIUM_value; + ZVAL_LONG(&const_MEDIUM_value, UDAT_MEDIUM); + zend_string *const_MEDIUM_name = zend_string_init_interned("MEDIUM", sizeof("MEDIUM") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_MEDIUM_name, &const_MEDIUM_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_MEDIUM_name); + + zval const_SHORT_value; + ZVAL_LONG(&const_SHORT_value, UDAT_SHORT); + zend_string *const_SHORT_name = zend_string_init_interned("SHORT", sizeof("SHORT") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_SHORT_name, &const_SHORT_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_SHORT_name); + + zval const_NONE_value; + ZVAL_LONG(&const_NONE_value, UDAT_NONE); + zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_NONE_name, &const_NONE_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_NONE_name); + + zval const_RELATIVE_FULL_value; + ZVAL_LONG(&const_RELATIVE_FULL_value, UDAT_FULL_RELATIVE); + zend_string *const_RELATIVE_FULL_name = zend_string_init_interned("RELATIVE_FULL", sizeof("RELATIVE_FULL") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RELATIVE_FULL_name, &const_RELATIVE_FULL_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RELATIVE_FULL_name); + + zval const_RELATIVE_LONG_value; + ZVAL_LONG(&const_RELATIVE_LONG_value, UDAT_LONG_RELATIVE); + zend_string *const_RELATIVE_LONG_name = zend_string_init_interned("RELATIVE_LONG", sizeof("RELATIVE_LONG") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RELATIVE_LONG_name, &const_RELATIVE_LONG_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RELATIVE_LONG_name); + + zval const_RELATIVE_MEDIUM_value; + ZVAL_LONG(&const_RELATIVE_MEDIUM_value, UDAT_MEDIUM_RELATIVE); + zend_string *const_RELATIVE_MEDIUM_name = zend_string_init_interned("RELATIVE_MEDIUM", sizeof("RELATIVE_MEDIUM") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RELATIVE_MEDIUM_name, &const_RELATIVE_MEDIUM_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RELATIVE_MEDIUM_name); + + zval const_RELATIVE_SHORT_value; + ZVAL_LONG(&const_RELATIVE_SHORT_value, UDAT_SHORT_RELATIVE); + zend_string *const_RELATIVE_SHORT_name = zend_string_init_interned("RELATIVE_SHORT", sizeof("RELATIVE_SHORT") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_RELATIVE_SHORT_name, &const_RELATIVE_SHORT_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_RELATIVE_SHORT_name); + + zval const_GREGORIAN_value; + ZVAL_LONG(&const_GREGORIAN_value, UCAL_GREGORIAN); + zend_string *const_GREGORIAN_name = zend_string_init_interned("GREGORIAN", sizeof("GREGORIAN") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_GREGORIAN_name, &const_GREGORIAN_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_GREGORIAN_name); + + zval const_TRADITIONAL_value; + ZVAL_LONG(&const_TRADITIONAL_value, UCAL_TRADITIONAL); + zend_string *const_TRADITIONAL_name = zend_string_init_interned("TRADITIONAL", sizeof("TRADITIONAL") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_TRADITIONAL_name, &const_TRADITIONAL_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_TRADITIONAL_name); + return class_entry; } diff --git a/ext/intl/dateformat/dateformat_create.h b/ext/intl/dateformat/dateformat_create.h index 9dc0793a79718..a15828e7794c1 100644 --- a/ext/intl/dateformat/dateformat_create.h +++ b/ext/intl/dateformat/dateformat_create.h @@ -16,6 +16,4 @@ #include -void dateformat_register_constants( INIT_FUNC_ARGS ); - #endif // DATE_FORMATTER_H diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 2fa47e46726a8..de31f0f591b73 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -176,9 +176,6 @@ PHP_MINIT_FUNCTION( intl ) /* Register 'DateFormat' PHP class */ dateformat_register_IntlDateFormatter_class( ); - /* Expose DateFormat constants to PHP scripts */ - dateformat_register_constants( INIT_FUNC_ARGS_PASSTHRU ); - /* Register 'IntlDateTimeFormatter' PHP class */ dateformat_register_IntlDatePatternGenerator_class( );