mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Declare ext/pcre constants in stubs (#9077)
This commit is contained in:
parent
8487d8fa91
commit
28944b8fbe
3 changed files with 134 additions and 30 deletions
|
@ -18,7 +18,6 @@
|
|||
#include "php_ini.h"
|
||||
#include "php_globals.h"
|
||||
#include "php_pcre.h"
|
||||
#include "php_pcre_arginfo.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/basic_functions.h"
|
||||
#include "zend_smart_str.h"
|
||||
|
@ -43,6 +42,16 @@
|
|||
|
||||
#define PCRE_CACHE_SIZE 4096
|
||||
|
||||
#ifdef HAVE_PCRE_JIT_SUPPORT
|
||||
#define PHP_PCRE_JIT_SUPPORT 1
|
||||
#else
|
||||
#define PHP_PCRE_JIT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
char *php_pcre_version;
|
||||
|
||||
#include "php_pcre_arginfo.h"
|
||||
|
||||
struct _pcre_cache_entry {
|
||||
pcre2_code *re;
|
||||
uint32_t preg_options;
|
||||
|
@ -422,8 +431,6 @@ static PHP_MINFO_FUNCTION(pcre)
|
|||
/* {{{ PHP_MINIT_FUNCTION(pcre) */
|
||||
static PHP_MINIT_FUNCTION(pcre)
|
||||
{
|
||||
char *version;
|
||||
|
||||
#ifdef HAVE_PCRE_JIT_SUPPORT
|
||||
if (UNEXPECTED(!pcre2_init_ok)) {
|
||||
/* Retry. */
|
||||
|
@ -436,33 +443,9 @@ static PHP_MINIT_FUNCTION(pcre)
|
|||
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
REGISTER_LONG_CONSTANT("PREG_PATTERN_ORDER", PREG_PATTERN_ORDER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SET_ORDER", PREG_SET_ORDER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_OFFSET_CAPTURE", PREG_OFFSET_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_UNMATCHED_AS_NULL", PREG_UNMATCHED_AS_NULL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_NO_EMPTY", PREG_SPLIT_NO_EMPTY, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_DELIM_CAPTURE", PREG_SPLIT_DELIM_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_OFFSET_CAPTURE", PREG_SPLIT_OFFSET_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_GREP_INVERT", PREG_GREP_INVERT, CONST_CS | CONST_PERSISTENT);
|
||||
php_pcre_version = _pcre2_config_str(PCRE2_CONFIG_VERSION);
|
||||
|
||||
REGISTER_LONG_CONSTANT("PREG_NO_ERROR", PHP_PCRE_NO_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_INTERNAL_ERROR", PHP_PCRE_INTERNAL_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BACKTRACK_LIMIT_ERROR", PHP_PCRE_BACKTRACK_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_RECURSION_LIMIT_ERROR", PHP_PCRE_RECURSION_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_ERROR", PHP_PCRE_BAD_UTF8_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_OFFSET_ERROR", PHP_PCRE_BAD_UTF8_OFFSET_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_JIT_STACKLIMIT_ERROR", PHP_PCRE_JIT_STACKLIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
version = _pcre2_config_str(PCRE2_CONFIG_VERSION);
|
||||
REGISTER_STRING_CONSTANT("PCRE_VERSION", version, CONST_CS | CONST_PERSISTENT);
|
||||
free(version);
|
||||
REGISTER_LONG_CONSTANT("PCRE_VERSION_MAJOR", PCRE2_MAJOR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PCRE_VERSION_MINOR", PCRE2_MINOR, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
#ifdef HAVE_PCRE_JIT_SUPPORT
|
||||
REGISTER_BOOL_CONSTANT("PCRE_JIT_SUPPORT", 1, CONST_CS | CONST_PERSISTENT);
|
||||
#else
|
||||
REGISTER_BOOL_CONSTANT("PCRE_JIT_SUPPORT", 0, CONST_CS | CONST_PERSISTENT);
|
||||
#endif
|
||||
register_php_pcre_symbols(module_number);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -473,6 +456,8 @@ static PHP_MSHUTDOWN_FUNCTION(pcre)
|
|||
{
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
|
||||
free(php_pcre_version);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -2,6 +2,102 @@
|
|||
|
||||
/** @generate-class-entries */
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_PATTERN_ORDER
|
||||
*/
|
||||
const PREG_PATTERN_ORDER = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_SET_ORDER
|
||||
*/
|
||||
const PREG_SET_ORDER = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_OFFSET_CAPTURE
|
||||
*/
|
||||
const PREG_OFFSET_CAPTURE = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_UNMATCHED_AS_NULL
|
||||
*/
|
||||
const PREG_UNMATCHED_AS_NULL = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_SPLIT_NO_EMPTY
|
||||
*/
|
||||
const PREG_SPLIT_NO_EMPTY = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_SPLIT_DELIM_CAPTURE
|
||||
*/
|
||||
const PREG_SPLIT_DELIM_CAPTURE = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_SPLIT_OFFSET_CAPTURE
|
||||
*/
|
||||
const PREG_SPLIT_OFFSET_CAPTURE = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PREG_GREP_INVERT
|
||||
*/
|
||||
const PREG_GREP_INVERT = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_NO_ERROR
|
||||
*/
|
||||
const PREG_NO_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_INTERNAL_ERROR
|
||||
*/
|
||||
const PREG_INTERNAL_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_BACKTRACK_LIMIT_ERROR
|
||||
*/
|
||||
const PREG_BACKTRACK_LIMIT_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_RECURSION_LIMIT_ERROR
|
||||
*/
|
||||
const PREG_RECURSION_LIMIT_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_BAD_UTF8_ERROR
|
||||
*/
|
||||
const PREG_BAD_UTF8_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_BAD_UTF8_OFFSET_ERROR
|
||||
*/
|
||||
const PREG_BAD_UTF8_OFFSET_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PHP_PCRE_JIT_STACKLIMIT_ERROR
|
||||
*/
|
||||
const PREG_JIT_STACKLIMIT_ERROR = UNKNOWN;
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue php_pcre_version
|
||||
*/
|
||||
const PCRE_VERSION = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PCRE2_MAJOR
|
||||
*/
|
||||
const PCRE_VERSION_MAJOR = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue PCRE2_MINOR
|
||||
*/
|
||||
const PCRE_VERSION_MINOR = UNKNOWN;
|
||||
/**
|
||||
* @var bool
|
||||
* @cvalue PHP_PCRE_JIT_SUPPORT
|
||||
*/
|
||||
const PCRE_JIT_SUPPORT = UNKNOWN;
|
||||
|
||||
/** @param array $matches */
|
||||
function preg_match(string $pattern, string $subject, &$matches = null, int $flags = 0, int $offset = 0): int|false {}
|
||||
|
||||
|
|
25
ext/pcre/php_pcre_arginfo.h
generated
25
ext/pcre/php_pcre_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 39a19378fb1f1aca34bfdd483f5d3095558f0e09 */
|
||||
* Stub hash: 7f27807e45df9c9b5011aa20263c9789896acfbc */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
|
||||
|
@ -90,3 +90,26 @@ static const zend_function_entry ext_functions[] = {
|
|||
ZEND_FE(preg_last_error_msg, arginfo_preg_last_error_msg)
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
static void register_php_pcre_symbols(int module_number)
|
||||
{
|
||||
REGISTER_LONG_CONSTANT("PREG_PATTERN_ORDER", PREG_PATTERN_ORDER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SET_ORDER", PREG_SET_ORDER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_OFFSET_CAPTURE", PREG_OFFSET_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_UNMATCHED_AS_NULL", PREG_UNMATCHED_AS_NULL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_NO_EMPTY", PREG_SPLIT_NO_EMPTY, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_DELIM_CAPTURE", PREG_SPLIT_DELIM_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_SPLIT_OFFSET_CAPTURE", PREG_SPLIT_OFFSET_CAPTURE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_GREP_INVERT", PREG_GREP_INVERT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_NO_ERROR", PHP_PCRE_NO_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_INTERNAL_ERROR", PHP_PCRE_INTERNAL_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BACKTRACK_LIMIT_ERROR", PHP_PCRE_BACKTRACK_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_RECURSION_LIMIT_ERROR", PHP_PCRE_RECURSION_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_ERROR", PHP_PCRE_BAD_UTF8_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_OFFSET_ERROR", PHP_PCRE_BAD_UTF8_OFFSET_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PREG_JIT_STACKLIMIT_ERROR", PHP_PCRE_JIT_STACKLIMIT_ERROR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_STRING_CONSTANT("PCRE_VERSION", php_pcre_version, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PCRE_VERSION_MAJOR", PCRE2_MAJOR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PCRE_VERSION_MINOR", PCRE2_MINOR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_BOOL_CONSTANT("PCRE_JIT_SUPPORT", PHP_PCRE_JIT_SUPPORT, CONST_CS | CONST_PERSISTENT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue