Skip to content

Declare ext/intl constants in stubs - part 4 #9234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions ext/intl/dateformat/dateformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
2 changes: 0 additions & 2 deletions ext/intl/dateformat/dateformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include <php.h>

void dateformat_register_constants( INIT_FUNC_ARGS );

/*
These are not necessary at this point of time
#define DATEF_GREGORIAN 1
Expand Down
57 changes: 57 additions & 0 deletions ext/intl/dateformat/dateformat.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 67 additions & 1 deletion ext/intl/dateformat/dateformat_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions ext/intl/dateformat/dateformat_create.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@

#include <php.h>

void dateformat_register_constants( INIT_FUNC_ARGS );

#endif // DATE_FORMATTER_H
3 changes: 0 additions & 3 deletions ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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( );

Expand Down