Skip to content

Commit 0c225a2

Browse files
authored
Declare ext/intl constants in stubs - part 1 (#9205)
1 parent ac31e2e commit 0c225a2

File tree

5 files changed

+116
-41
lines changed

5 files changed

+116
-41
lines changed

ext/intl/locale/locale.c

-35
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,3 @@
2222
#include <unicode/utypes.h>
2323
#include <unicode/uloc.h>
2424
#include <unicode/ustring.h>
25-
26-
/* {{{ locale_register_constants
27-
* Register constants common for the both (OO and procedural)
28-
* APIs.
29-
*/
30-
void locale_register_constants( INIT_FUNC_ARGS )
31-
{
32-
if( !Locale_ce_ptr )
33-
{
34-
zend_error( E_ERROR, "Locale class not defined" );
35-
return;
36-
}
37-
38-
#define LOCALE_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
39-
#define LOCALE_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Locale_ce_ptr, ZEND_STRS( #x ) - 1, ULOC_##x );
40-
#define LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR(name, value) zend_declare_class_constant_string( Locale_ce_ptr, ZEND_STRS( name ) - 1, value );
41-
42-
LOCALE_EXPOSE_CLASS_CONST( ACTUAL_LOCALE );
43-
LOCALE_EXPOSE_CLASS_CONST( VALID_LOCALE );
44-
45-
zend_declare_class_constant_null(Locale_ce_ptr, ZEND_STRS("DEFAULT_LOCALE") - 1);
46-
47-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "LANG_TAG", LOC_LANG_TAG);
48-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "EXTLANG_TAG", LOC_EXTLANG_TAG);
49-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "SCRIPT_TAG", LOC_SCRIPT_TAG);
50-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "REGION_TAG", LOC_REGION_TAG);
51-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "VARIANT_TAG",LOC_VARIANT_TAG);
52-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "GRANDFATHERED_LANG_TAG",LOC_GRANDFATHERED_LANG_TAG);
53-
LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "PRIVATE_TAG",LOC_PRIVATE_TAG);
54-
55-
#undef LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR
56-
#undef LOCALE_EXPOSE_CLASS_CONST
57-
#undef LOCALE_EXPOSE_CONST
58-
}
59-
/* }}} */

ext/intl/locale/locale.h

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
#include <php.h>
1919

20-
void locale_register_constants( INIT_FUNC_ARGS );
21-
2220
#define OPTION_DEFAULT NULL
2321
#define LOC_LANG_TAG "language"
2422
#define LOC_SCRIPT_TAG "script"

ext/intl/locale/locale.stub.php

+48
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,54 @@
44

55
class Locale
66
{
7+
/**
8+
* @var int
9+
* @cvalue ULOC_ACTUAL_LOCALE
10+
*/
11+
public const ACTUAL_LOCALE = UNKNOWN;
12+
/**
13+
* @var int
14+
* @cvalue ULOC_VALID_LOCALE
15+
*/
16+
public const VALID_LOCALE = UNKNOWN;
17+
/** @var null */
18+
public const DEFAULT_LOCALE = null;
19+
/**
20+
* @var string
21+
* @cvalue LOC_LANG_TAG
22+
*/
23+
public const LANG_TAG = UNKNOWN;
24+
/**
25+
* @var string
26+
* @cvalue LOC_EXTLANG_TAG
27+
*/
28+
public const EXTLANG_TAG = UNKNOWN;
29+
/**
30+
* @var string
31+
* @cvalue LOC_SCRIPT_TAG
32+
*/
33+
public const SCRIPT_TAG = UNKNOWN;
34+
/**
35+
* @var string
36+
* @cvalue LOC_REGION_TAG
37+
*/
38+
public const REGION_TAG = UNKNOWN;
39+
/**
40+
* @var string
41+
* @cvalue LOC_VARIANT_TAG
42+
*/
43+
public const VARIANT_TAG = UNKNOWN;
44+
/**
45+
* @var string
46+
* @cvalue LOC_GRANDFATHERED_LANG_TAG
47+
*/
48+
public const GRANDFATHERED_LANG_TAG = UNKNOWN;
49+
/**
50+
* @var string
51+
* @cvalue LOC_PRIVATE_TAG
52+
*/
53+
public const PRIVATE_TAG = UNKNOWN;
54+
755
/**
856
* @tentative-return-type
957
* @alias locale_get_default

ext/intl/locale/locale_arginfo.h

+68-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/php_intl.c

-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ PHP_MINIT_FUNCTION( intl )
175175
/* Register 'Locale' PHP class */
176176
locale_register_Locale_class( );
177177

178-
/* Expose Locale constants to PHP scripts */
179-
locale_register_constants( INIT_FUNC_ARGS_PASSTHRU );
180-
181178
msgformat_register_class();
182179

183180
grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );

0 commit comments

Comments
 (0)