Skip to content

Declare ext/intl constants in stubs - part 14 #9387

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 22, 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
7 changes: 6 additions & 1 deletion ext/intl/grapheme/grapheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
#include <php.h>
#include <unicode/utypes.h>

void grapheme_register_constants( INIT_FUNC_ARGS );
void grapheme_close_global_iterator( void );

#define GRAPHEME_EXTRACT_TYPE_COUNT 0
#define GRAPHEME_EXTRACT_TYPE_MAXBYTES 1
#define GRAPHEME_EXTRACT_TYPE_MAXCHARS 2
#define GRAPHEME_EXTRACT_TYPE_MIN GRAPHEME_EXTRACT_TYPE_COUNT
#define GRAPHEME_EXTRACT_TYPE_MAX GRAPHEME_EXTRACT_TYPE_MAXCHARS

#endif // GRAPHEME_GRAPHEME_H
18 changes: 0 additions & 18 deletions ext/intl/grapheme/grapheme_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@

/* }}} */

#define GRAPHEME_EXTRACT_TYPE_COUNT 0
#define GRAPHEME_EXTRACT_TYPE_MAXBYTES 1
#define GRAPHEME_EXTRACT_TYPE_MAXCHARS 2
#define GRAPHEME_EXTRACT_TYPE_MIN GRAPHEME_EXTRACT_TYPE_COUNT
#define GRAPHEME_EXTRACT_TYPE_MAX GRAPHEME_EXTRACT_TYPE_MAXCHARS


/* {{{ grapheme_register_constants
* Register API constants
*/
void grapheme_register_constants( INIT_FUNC_ARGS )
{
REGISTER_LONG_CONSTANT("GRAPHEME_EXTR_COUNT", GRAPHEME_EXTRACT_TYPE_COUNT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GRAPHEME_EXTR_MAXBYTES", GRAPHEME_EXTRACT_TYPE_MAXBYTES, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GRAPHEME_EXTR_MAXCHARS", GRAPHEME_EXTRACT_TYPE_MAXCHARS, CONST_CS | CONST_PERSISTENT);
}
/* }}} */

/* {{{ Get number of graphemes in a string */
PHP_FUNCTION(grapheme_strlen)
{
Expand Down
60 changes: 1 addition & 59 deletions ext/intl/idn/idn.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,69 +26,11 @@
#include <unicode/ustring.h>
#include "ext/standard/php_string.h"

#include "idn.h"
#include "intl_error.h"
#include "intl_convert.h"
/* }}} */

enum {
INTL_IDN_VARIANT_UTS46 = 1
};

/* {{{ grapheme_register_constants
* Register API constants
*/
void idn_register_constants( INIT_FUNC_ARGS )
{
/* OPTIONS */

/* Option to prohibit processing of unassigned codepoints in the input and
do not check if the input conforms to STD-3 ASCII rules. */
REGISTER_LONG_CONSTANT("IDNA_DEFAULT", UIDNA_DEFAULT, CONST_CS | CONST_PERSISTENT);

/* Option to allow processing of unassigned codepoints in the input */
REGISTER_LONG_CONSTANT("IDNA_ALLOW_UNASSIGNED", UIDNA_ALLOW_UNASSIGNED, CONST_CS | CONST_PERSISTENT);

/* Option to check if input conforms to STD-3 ASCII rules */
REGISTER_LONG_CONSTANT("IDNA_USE_STD3_RULES", UIDNA_USE_STD3_RULES, CONST_CS | CONST_PERSISTENT);

/* Option to check for whether the input conforms to the BiDi rules.
* Ignored by the IDNA2003 implementation. (IDNA2003 always performs a BiDi check.) */
REGISTER_LONG_CONSTANT("IDNA_CHECK_BIDI", UIDNA_CHECK_BIDI, CONST_CS | CONST_PERSISTENT);

/* Option to check for whether the input conforms to the CONTEXTJ rules.
* Ignored by the IDNA2003 implementation. (The CONTEXTJ check is new in IDNA2008.) */
REGISTER_LONG_CONSTANT("IDNA_CHECK_CONTEXTJ", UIDNA_CHECK_CONTEXTJ, CONST_CS | CONST_PERSISTENT);

/* Option for nontransitional processing in ToASCII().
* By default, ToASCII() uses transitional processing.
* Ignored by the IDNA2003 implementation. */
REGISTER_LONG_CONSTANT("IDNA_NONTRANSITIONAL_TO_ASCII", UIDNA_NONTRANSITIONAL_TO_ASCII, CONST_CS | CONST_PERSISTENT);

/* Option for nontransitional processing in ToUnicode().
* By default, ToUnicode() uses transitional processing.
* Ignored by the IDNA2003 implementation. */
REGISTER_LONG_CONSTANT("IDNA_NONTRANSITIONAL_TO_UNICODE", UIDNA_NONTRANSITIONAL_TO_UNICODE, CONST_CS | CONST_PERSISTENT);

/* VARIANTS */
REGISTER_LONG_CONSTANT("INTL_IDNA_VARIANT_UTS46", INTL_IDN_VARIANT_UTS46, CONST_CS | CONST_PERSISTENT);

/* PINFO ERROR CODES */
REGISTER_LONG_CONSTANT("IDNA_ERROR_EMPTY_LABEL", UIDNA_ERROR_EMPTY_LABEL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_LABEL_TOO_LONG", UIDNA_ERROR_LABEL_TOO_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_DOMAIN_NAME_TOO_LONG", UIDNA_ERROR_DOMAIN_NAME_TOO_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_LEADING_HYPHEN", UIDNA_ERROR_LEADING_HYPHEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_TRAILING_HYPHEN", UIDNA_ERROR_TRAILING_HYPHEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_HYPHEN_3_4", UIDNA_ERROR_HYPHEN_3_4, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_LEADING_COMBINING_MARK", UIDNA_ERROR_LEADING_COMBINING_MARK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_DISALLOWED", UIDNA_ERROR_DISALLOWED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_PUNYCODE", UIDNA_ERROR_PUNYCODE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_LABEL_HAS_DOT", UIDNA_ERROR_LABEL_HAS_DOT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_INVALID_ACE_LABEL", UIDNA_ERROR_INVALID_ACE_LABEL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_BIDI", UIDNA_ERROR_BIDI, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IDNA_ERROR_CONTEXTJ", UIDNA_ERROR_CONTEXTJ, CONST_CS | CONST_PERSISTENT);
}
/* }}} */

enum {
INTL_IDN_TO_ASCII = 0,
INTL_IDN_TO_UTF8
Expand Down
4 changes: 3 additions & 1 deletion ext/intl/idn/idn.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <php.h>

void idn_register_constants(INIT_FUNC_ARGS);
enum {
INTL_IDN_VARIANT_UTS46 = 1
};

#endif /* IDN_IDN_H */
6 changes: 1 addition & 5 deletions ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "breakiterator/breakiterator_class.h"
#include "breakiterator/breakiterator_iterators.h"

#include <unicode/uidna.h>
#include "idn/idn.h"
#include "uchar/uchar.h"

Expand Down Expand Up @@ -161,8 +162,6 @@ PHP_MINIT_FUNCTION( intl )

msgformat_register_class();

grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );

/* Register 'DateFormat' PHP class */
dateformat_register_IntlDateFormatter_class( );

Expand All @@ -181,9 +180,6 @@ PHP_MINIT_FUNCTION( intl )
/* Register 'IntlCalendar' PHP class */
calendar_register_IntlCalendar_class( );

/* Expose IDN constants to PHP scripts. */
idn_register_constants(INIT_FUNC_ARGS_PASSTHRU);

/* Register 'Spoofchecker' PHP class */
spoofchecker_register_Spoofchecker_class( );

Expand Down
147 changes: 147 additions & 0 deletions ext/intl/php_intl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,153 @@
const INTL_ICU_DATA_VERSION = UNKNOWN;
#endif

/**
* @var int
* @cvalue GRAPHEME_EXTRACT_TYPE_COUNT
*/
const GRAPHEME_EXTR_COUNT = UNKNOWN;
/**
* @var int
* @cvalue GRAPHEME_EXTRACT_TYPE_MAXBYTES
*/
const GRAPHEME_EXTR_MAXBYTES = UNKNOWN;
/**
* @var int
* @cvalue GRAPHEME_EXTRACT_TYPE_MAXCHARS
*/
const GRAPHEME_EXTR_MAXCHARS = UNKNOWN;

/**
* Option to prohibit processing of unassigned codepoints in the input and
* do not check if the input conforms to STD-3 ASCII rules.
* @var int
* @cvalue UIDNA_DEFAULT
*/
const IDNA_DEFAULT = UNKNOWN;

/**
* Option to allow processing of unassigned codepoints in the input
* @var int
* @cvalue UIDNA_ALLOW_UNASSIGNED
*/
const IDNA_ALLOW_UNASSIGNED = UNKNOWN;

/**
* Option to check if input conforms to STD-3 ASCII rules
* @var int
* @cvalue UIDNA_USE_STD3_RULES
*/
const IDNA_USE_STD3_RULES = UNKNOWN;

/**
* Option to check for whether the input conforms to the BiDi rules.
* Ignored by the IDNA2003 implementation. (IDNA2003 always performs a BiDi check.)
* @var int
* @cvalue UIDNA_CHECK_BIDI
*/
const IDNA_CHECK_BIDI = UNKNOWN;

/**
* Option to check for whether the input conforms to the CONTEXTJ rules.
* Ignored by the IDNA2003 implementation. (The CONTEXTJ check is new in IDNA2008.)
* @var int
* @cvalue UIDNA_CHECK_CONTEXTJ
*/
const IDNA_CHECK_CONTEXTJ = UNKNOWN;

/**
* Option for nontransitional processing in ToASCII().
* By default, ToASCII() uses transitional processing.
* Ignored by the IDNA2003 implementation.
* @var int
* @cvalue UIDNA_NONTRANSITIONAL_TO_ASCII
*/
const IDNA_NONTRANSITIONAL_TO_ASCII = UNKNOWN;

/**
* Option for nontransitional processing in ToUnicode().
* By default, ToUnicode() uses transitional processing.
* Ignored by the IDNA2003 implementation.
* @var int
* @cvalue UIDNA_NONTRANSITIONAL_TO_UNICODE
*/
const IDNA_NONTRANSITIONAL_TO_UNICODE = UNKNOWN;

/* VARIANTS */

/**
* @var int
* @cvalue INTL_IDN_VARIANT_UTS46
*/
const INTL_IDNA_VARIANT_UTS46 = UNKNOWN;

/* PINFO ERROR CODES */
/**
* @var int
* @cvalue UIDNA_ERROR_EMPTY_LABEL
*/
const IDNA_ERROR_EMPTY_LABEL = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_LABEL_TOO_LONG
*/
const IDNA_ERROR_LABEL_TOO_LONG = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
*/
const IDNA_ERROR_DOMAIN_NAME_TOO_LONG = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_LEADING_HYPHEN
*/
const IDNA_ERROR_LEADING_HYPHEN = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_TRAILING_HYPHEN
*/
const IDNA_ERROR_TRAILING_HYPHEN = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_HYPHEN_3_4
*/
const IDNA_ERROR_HYPHEN_3_4 = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_LEADING_COMBINING_MARK
*/
const IDNA_ERROR_LEADING_COMBINING_MARK = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_DISALLOWED
*/
const IDNA_ERROR_DISALLOWED = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_PUNYCODE
*/
const IDNA_ERROR_PUNYCODE = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_LABEL_HAS_DOT
*/
const IDNA_ERROR_LABEL_HAS_DOT = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_INVALID_ACE_LABEL
*/
const IDNA_ERROR_INVALID_ACE_LABEL = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_BIDI
*/
const IDNA_ERROR_BIDI = UNKNOWN;
/**
* @var int
* @cvalue UIDNA_ERROR_CONTEXTJ
*/
const IDNA_ERROR_CONTEXTJ = UNKNOWN;

class IntlException extends Exception
{
}
Expand Down
26 changes: 25 additions & 1 deletion ext/intl/php_intl_arginfo.h

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