Skip to content

Declare ext/intl constants in stubs - part 1 #9205

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
Jul 30, 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
35 changes: 0 additions & 35 deletions ext/intl/locale/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,3 @@
#include <unicode/utypes.h>
#include <unicode/uloc.h>
#include <unicode/ustring.h>

/* {{{ locale_register_constants
* Register constants common for the both (OO and procedural)
* APIs.
*/
void locale_register_constants( INIT_FUNC_ARGS )
{
if( !Locale_ce_ptr )
{
zend_error( E_ERROR, "Locale class not defined" );
return;
}

#define LOCALE_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
#define LOCALE_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Locale_ce_ptr, ZEND_STRS( #x ) - 1, ULOC_##x );
#define LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR(name, value) zend_declare_class_constant_string( Locale_ce_ptr, ZEND_STRS( name ) - 1, value );

LOCALE_EXPOSE_CLASS_CONST( ACTUAL_LOCALE );
LOCALE_EXPOSE_CLASS_CONST( VALID_LOCALE );

zend_declare_class_constant_null(Locale_ce_ptr, ZEND_STRS("DEFAULT_LOCALE") - 1);

LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "LANG_TAG", LOC_LANG_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "EXTLANG_TAG", LOC_EXTLANG_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "SCRIPT_TAG", LOC_SCRIPT_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "REGION_TAG", LOC_REGION_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "VARIANT_TAG",LOC_VARIANT_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "GRANDFATHERED_LANG_TAG",LOC_GRANDFATHERED_LANG_TAG);
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "PRIVATE_TAG",LOC_PRIVATE_TAG);

#undef LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR
#undef LOCALE_EXPOSE_CLASS_CONST
#undef LOCALE_EXPOSE_CONST
}
/* }}} */
2 changes: 0 additions & 2 deletions ext/intl/locale/locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#include <php.h>

void locale_register_constants( INIT_FUNC_ARGS );

#define OPTION_DEFAULT NULL
#define LOC_LANG_TAG "language"
#define LOC_SCRIPT_TAG "script"
Expand Down
48 changes: 48 additions & 0 deletions ext/intl/locale/locale.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@

class Locale
{
/**
* @var int
* @cvalue ULOC_ACTUAL_LOCALE
*/
public const ACTUAL_LOCALE = UNKNOWN;
/**
* @var int
* @cvalue ULOC_VALID_LOCALE
*/
public const VALID_LOCALE = UNKNOWN;
/** @var null */
public const DEFAULT_LOCALE = null;
/**
* @var string
* @cvalue LOC_LANG_TAG
*/
public const LANG_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_EXTLANG_TAG
*/
public const EXTLANG_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_SCRIPT_TAG
*/
public const SCRIPT_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_REGION_TAG
*/
public const REGION_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_VARIANT_TAG
*/
public const VARIANT_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_GRANDFATHERED_LANG_TAG
*/
public const GRANDFATHERED_LANG_TAG = UNKNOWN;
/**
* @var string
* @cvalue LOC_PRIVATE_TAG
*/
public const PRIVATE_TAG = UNKNOWN;

/**
* @tentative-return-type
* @alias locale_get_default
Expand Down
69 changes: 68 additions & 1 deletion ext/intl/locale/locale_arginfo.h

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

3 changes: 0 additions & 3 deletions ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ PHP_MINIT_FUNCTION( intl )
/* Register 'Locale' PHP class */
locale_register_Locale_class( );

/* Expose Locale constants to PHP scripts */
locale_register_constants( INIT_FUNC_ARGS_PASSTHRU );

msgformat_register_class();

grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );
Expand Down