summaryrefslogtreecommitdiff
path: root/ext/pcre
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcre')
-rw-r--r--ext/pcre/config.w321
-rw-r--r--ext/pcre/config0.m41
-rw-r--r--ext/pcre/php_pcre.c97
-rw-r--r--ext/pcre/php_pcre.h2
-rw-r--r--ext/pcre/php_pcre.stub.php52
-rw-r--r--ext/pcre/php_pcre_arginfo.h59
-rw-r--r--ext/pcre/tests/002.phpt18
-rw-r--r--ext/pcre/tests/bug21732.phpt10
-rw-r--r--ext/pcre/tests/bug44925.phpt4
-rw-r--r--ext/pcre/tests/grep2.phpt10
-rw-r--r--ext/pcre/tests/pcre_extra.phpt5
-rw-r--r--ext/pcre/tests/preg_grep_error1.phpt23
-rw-r--r--ext/pcre/tests/preg_match_all_error1.phpt23
-rw-r--r--ext/pcre/tests/preg_match_all_error2.phpt20
-rw-r--r--ext/pcre/tests/preg_match_error1.phpt23
-rw-r--r--ext/pcre/tests/preg_match_error2.phpt23
-rw-r--r--ext/pcre/tests/preg_replace2.phpt6
-rw-r--r--ext/pcre/tests/preg_replace_callback2.phpt2
-rw-r--r--ext/pcre/tests/preg_replace_callback3.phpt22
-rw-r--r--ext/pcre/tests/preg_replace_callback_array2.phpt33
-rw-r--r--ext/pcre/tests/preg_replace_callback_error1.phpt9
-rw-r--r--ext/pcre/tests/preg_replace_error1.phpt3
-rw-r--r--ext/pcre/tests/preg_replace_error2.phpt13
-rw-r--r--ext/pcre/tests/preg_split_error1.phpt23
-rw-r--r--ext/pcre/tests/split.phpt6
-rw-r--r--ext/pcre/tests/split2.phpt4
26 files changed, 219 insertions, 273 deletions
diff --git a/ext/pcre/config.w32 b/ext/pcre/config.w32
index 86298bbe1b..cbc8cf4517 100644
--- a/ext/pcre/config.w32
+++ b/ext/pcre/config.w32
@@ -6,7 +6,6 @@ ADD_SOURCES("ext/pcre/pcre2lib", "pcre2_auto_possess.c pcre2_chartables.c pcre2_
ADD_DEF_FILE("ext\\pcre\\php_pcre.def");
AC_DEFINE('HAVE_BUNDLED_PCRE', 1, 'Using bundled PCRE library');
-AC_DEFINE('HAVE_PCRE', 1, 'Have PCRE library');
AC_DEFINE('PCRE2_CODE_UNIT_WIDTH', 8, 'Have PCRE library');
AC_DEFINE("PCRE2_STATIC", 1, "");
PHP_PCRE="yes";
diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4
index 714a8d57e8..36f896ad2a 100644
--- a/ext/pcre/config0.m4
+++ b/ext/pcre/config0.m4
@@ -19,7 +19,6 @@ if test "$PHP_EXTERNAL_PCRE" != "no"; then
PHP_EVAL_INCLINE($PCRE2_CFLAGS)
PHP_EVAL_LIBLINE($PCRE2_LIBS)
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
- AC_DEFINE(HAVE_PCRE, 1, [ ])
if test "$PHP_PCRE_JIT" != "no"; then
AC_CACHE_CHECK([for JIT support in PCRE2], ac_cv_have_pcre2_jit, [
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 34c8389ebb..ad852f7c4b 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -20,6 +18,7 @@
#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"
@@ -50,7 +49,6 @@ struct _pcre_cache_entry {
uint32_t capture_count;
uint32_t name_count;
uint32_t compile_options;
- uint32_t extra_compile_options;
uint32_t refcount;
};
@@ -167,7 +165,6 @@ static void php_pcre_free(void *block, void *data)
pefree(block, 1);
}/*}}}*/
-#define PHP_PCRE_DEFAULT_EXTRA_COPTIONS PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL
#define PHP_PCRE_PREALLOC_MDATA_SIZE 32
static void php_pcre_init_pcre2(uint8_t jit)
@@ -188,12 +185,6 @@ static void php_pcre_init_pcre2(uint8_t jit)
}
}
- /* XXX The 'X' modifier is the default behavior in PCRE2. This option is
- called dangerous in the manual, as typos in patterns can cause
- unexpected results. We might want to to switch to the default PCRE2
- behavior, too, thus causing a certain BC break. */
- pcre2_set_compile_extra_options(cctx, PHP_PCRE_DEFAULT_EXTRA_COPTIONS);
-
if (!mctx) {
mctx = pcre2_match_context_create(gctx);
if (!mctx) {
@@ -569,7 +560,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
{
pcre2_code *re = NULL;
uint32_t coptions = 0;
- uint32_t extra_coptions = PHP_PCRE_DEFAULT_EXTRA_COPTIONS;
PCRE2_UCHAR error[128];
PCRE2_SIZE erroffset;
int errnumber;
@@ -703,8 +693,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
case 'A': coptions |= PCRE2_ANCHORED; break;
case 'D': coptions |= PCRE2_DOLLAR_ENDONLY;break;
case 'S': /* Pass. */ break;
+ case 'X': /* Pass. */ break;
case 'U': coptions |= PCRE2_UNGREEDY; break;
- case 'X': extra_coptions &= ~PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL; break;
case 'u': coptions |= PCRE2_UTF;
/* In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII
characters, even in UTF-8 mode. However, this can be changed by setting
@@ -768,19 +758,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
pcre2_set_character_tables(cctx, tables);
}
- /* Set extra options for the compile context. */
- if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
- pcre2_set_compile_extra_options(cctx, extra_coptions);
- }
-
/* Compile pattern and display a warning if compilation failed. */
re = pcre2_compile((PCRE2_SPTR)pattern, pattern_len, coptions, &errnumber, &erroffset, cctx);
- /* Reset the compile context extra options to default. */
- if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
- pcre2_set_compile_extra_options(cctx, PHP_PCRE_DEFAULT_EXTRA_COPTIONS);
- }
-
if (re == NULL) {
if (key != regex) {
zend_string_release_ex(key, 0);
@@ -830,7 +810,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
new_entry.re = re;
new_entry.preg_options = poptions;
new_entry.compile_options = coptions;
- new_entry.extra_compile_options = extra_coptions;
new_entry.refcount = 0;
rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);
@@ -1106,7 +1085,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
Z_PARAM_ZVAL(subpats)
Z_PARAM_LONG(flags)
Z_PARAM_LONG(start_offset)
- ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+ ZEND_PARSE_PARAMETERS_END();
/* Compile regex or get it from cache. */
if ((pce = pcre_get_compiled_regex_cache(regex)) == NULL) {
@@ -2265,8 +2244,8 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter)
}
} else {
if (Z_TYPE_P(regex) != IS_ARRAY) {
- php_error_docref(NULL, E_WARNING, "Parameter mismatch, pattern is a string while replacement is an array");
- RETURN_FALSE;
+ zend_type_error("Parameter mismatch, pattern is a string while replacement is an array");
+ return;
}
}
@@ -2467,7 +2446,7 @@ static PHP_FUNCTION(preg_split)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(limit_val)
Z_PARAM_LONG(flags)
- ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+ ZEND_PARSE_PARAMETERS_END();
/* Compile regex or get it from cache. */
if ((pce = pcre_get_compiled_regex_cache(regex)) == NULL) {
@@ -2937,70 +2916,6 @@ static PHP_FUNCTION(preg_last_error)
/* {{{ module definition structures */
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match, 0, 0, 2)
- ZEND_ARG_INFO(0, pattern)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(1, subpatterns) /* array */
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match_all, 0, 0, 2)
- ZEND_ARG_INFO(0, pattern)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(1, subpatterns) /* array */
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace, 0, 0, 3)
- ZEND_ARG_INFO(0, regex)
- ZEND_ARG_INFO(0, replace)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(0, limit)
- ZEND_ARG_INFO(1, count)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace_callback, 0, 0, 3)
- ZEND_ARG_INFO(0, regex)
- ZEND_ARG_INFO(0, callback)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(0, limit)
- ZEND_ARG_INFO(1, count)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace_callback_array, 0, 0, 2)
- ZEND_ARG_INFO(0, pattern)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(0, limit)
- ZEND_ARG_INFO(1, count)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_split, 0, 0, 2)
- ZEND_ARG_INFO(0, pattern)
- ZEND_ARG_INFO(0, subject)
- ZEND_ARG_INFO(0, limit)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_quote, 0, 0, 1)
- ZEND_ARG_INFO(0, str)
- ZEND_ARG_INFO(0, delim_char)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_grep, 0, 0, 2)
- ZEND_ARG_INFO(0, regex)
- ZEND_ARG_INFO(0, input) /* array */
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_preg_last_error, 0)
-ZEND_END_ARG_INFO()
-/* }}} */
-
static const zend_function_entry pcre_functions[] = {
PHP_FE(preg_match, arginfo_preg_match)
PHP_FE(preg_match_all, arginfo_preg_match_all)
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 1a28d1733a..576c7a2fa4 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/pcre/php_pcre.stub.php b/ext/pcre/php_pcre.stub.php
new file mode 100644
index 0000000000..8a97cb4516
--- /dev/null
+++ b/ext/pcre/php_pcre.stub.php
@@ -0,0 +1,52 @@
+<?php
+
+/** @return int|false */
+function preg_match(string $pattern, string $subject, &$subpatterns = null, int $flags = 0, int $offset = 0) {}
+
+/** @return int|false */
+function preg_match_all(string $pattern, string $subject, &$subpatterns = null, int $flags = 0, int $offset = 0) {}
+
+/**
+ * @param string|array $regex
+ * @param string|array $replace
+ * @param string|array $subject
+ * @return string|array|null
+ */
+function preg_replace($regex, $replace, $subject, int $limit = -1, &$count = null) {}
+
+/**
+ * @param string|array $regex
+ * @param string|array $replace
+ * @param string|array $subject
+ * @return string|array|null
+ */
+function preg_filter($regex, $replace, $subject, int $limit = -1, &$count = null) {}
+
+/**
+ * @param string|array $regex
+ * @param string|array $subject
+ * @return string|array|null
+ *
+ * TODO: $callback should be `callable`
+ */
+function preg_replace_callback($regex, $callback, $subject, int $limit = -1, &$count = null, int $flags = 0) {}
+
+/**
+ * @param string|array $subject
+ * @return string|array|null
+ */
+function preg_replace_callback_array(array $pattern, $subject, int $limit = -1, &$count = null, int $flags = 0) {}
+
+/**
+ * @return array|false
+ */
+function preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0) {}
+
+
+function preg_quote(string $str, ?string $delim_char = null): string {}
+
+/** @return array|false */
+function preg_grep(string $regex, array $input, int $flags = 0) {}
+
+
+function preg_last_error(): int {}
diff --git a/ext/pcre/php_pcre_arginfo.h b/ext/pcre/php_pcre_arginfo.h
new file mode 100644
index 0000000000..aff71e652a
--- /dev/null
+++ b/ext/pcre/php_pcre_arginfo.h
@@ -0,0 +1,59 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_match, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
+ ZEND_ARG_INFO(1, subpatterns)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_preg_match_all arginfo_preg_match
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace, 0, 0, 3)
+ ZEND_ARG_INFO(0, regex)
+ ZEND_ARG_INFO(0, replace)
+ ZEND_ARG_INFO(0, subject)
+ ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ ZEND_ARG_INFO(1, count)
+ZEND_END_ARG_INFO()
+
+#define arginfo_preg_filter arginfo_preg_replace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace_callback, 0, 0, 3)
+ ZEND_ARG_INFO(0, regex)
+ ZEND_ARG_INFO(0, callback)
+ ZEND_ARG_INFO(0, subject)
+ ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ ZEND_ARG_INFO(1, count)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_replace_callback_array, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, pattern, IS_ARRAY, 0)
+ ZEND_ARG_INFO(0, subject)
+ ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ ZEND_ARG_INFO(1, count)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_split, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_preg_quote, 0, 1, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, delim_char, IS_STRING, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_preg_grep, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, regex, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, input, IS_ARRAY, 0)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_preg_last_error, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt
index d4780447bc..073a7a8d56 100644
--- a/ext/pcre/tests/002.phpt
+++ b/ext/pcre/tests/002.phpt
@@ -3,11 +3,8 @@ preg_* with bogus vals
--FILE--
<?php
-var_dump(preg_match());
-var_dump(preg_match_all());
var_dump(preg_match_all('//', '', $dummy, 0xdead));
-var_dump(preg_quote());
var_dump(preg_quote(''));
var_dump(preg_replace('/(.)/', '${1}${1', 'abc'));
@@ -16,22 +13,13 @@ var_dump(preg_replace('/(.)/e', 'for ($', 'abc'));
?>
--EXPECTF--
-Warning: preg_match() expects at least 2 parameters, 0 given in %s002.php on line 3
-bool(false)
-
-Warning: preg_match_all() expects at least 2 parameters, 0 given in %s002.php on line 4
-bool(false)
-
-Warning: preg_match_all(): Invalid flags specified in %s002.php on line 5
-NULL
-
-Warning: preg_quote() expects at least 1 parameter, 0 given in %s002.php on line 7
+Warning: preg_match_all(): Invalid flags specified in %s002.php on line %d
NULL
string(0) ""
string(12) "a${1b${1c${1"
-Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line 11
+Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line %d
NULL
-Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in %s on line 12
+Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in %s on line %d
NULL
diff --git a/ext/pcre/tests/bug21732.phpt b/ext/pcre/tests/bug21732.phpt
index 3dfc41e19f..629e015a06 100644
--- a/ext/pcre/tests/bug21732.phpt
+++ b/ext/pcre/tests/bug21732.phpt
@@ -1,7 +1,5 @@
--TEST--
Bug #21732 (preg_replace() segfaults with invalid parameters)
---INI--
-error_reporting=0
--FILE--
<?php
class foo {
@@ -11,11 +9,15 @@ class foo {
}
}
-var_dump(preg_replace('', array(), ''));
+try {
+ var_dump(preg_replace('', array(), ''));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
var_dump(preg_replace_callback("/(ab)(cd)(e)/", array(new foo(), "cb"), 'abcde'));
?>
--EXPECT--
-bool(false)
+Parameter mismatch, pattern is a string while replacement is an array
array(4) {
[0]=>
string(5) "abcde"
diff --git a/ext/pcre/tests/bug44925.phpt b/ext/pcre/tests/bug44925.phpt
index f6e0db4253..c495331b4b 100644
--- a/ext/pcre/tests/bug44925.phpt
+++ b/ext/pcre/tests/bug44925.phpt
@@ -45,11 +45,11 @@ array(9) {
&string(1) "b"
}
-Notice: Array to string conversion in %sbug44925.php on line 9
+Warning: Array to string conversion in %s on line %d
array(0) {
}
-Notice: Array to string conversion in %sbug44925.php on line 11
+Warning: Array to string conversion in %s on line %d
array(7) {
[0]=>
string(1) "1"
diff --git a/ext/pcre/tests/grep2.phpt b/ext/pcre/tests/grep2.phpt
index 4c6f9b155f..9721dfbd9e 100644
--- a/ext/pcre/tests/grep2.phpt
+++ b/ext/pcre/tests/grep2.phpt
@@ -7,8 +7,6 @@ pcre.jit=1
--FILE--
<?php
-var_dump(preg_grep(1,array(),3,4));
-var_dump(preg_grep(1, 2));
var_dump(preg_grep('/+/', array()));
$array = array(5=>'a', 'x' => '1', 'xyz'=>'q6', 'h20');
@@ -23,13 +21,7 @@ var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
?>
--EXPECTF--
-Warning: preg_grep() expects at most 3 parameters, 4 given in %sgrep2.php on line 3
-NULL
-
-Warning: preg_grep() expects parameter 2 to be array, int given in %sgrep2.php on line 4
-NULL
-
-Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %sgrep2.php on line 5
+Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %sgrep2.php on line %d
bool(false)
array(3) {
[5]=>
diff --git a/ext/pcre/tests/pcre_extra.phpt b/ext/pcre/tests/pcre_extra.phpt
index 4c5930f975..730c729939 100644
--- a/ext/pcre/tests/pcre_extra.phpt
+++ b/ext/pcre/tests/pcre_extra.phpt
@@ -1,5 +1,5 @@
--TEST--
-X (PCRE_EXTRA) modifier
+X (PCRE_EXTRA) modifier is ignored (no error, no change)
--FILE--
<?php
@@ -8,7 +8,8 @@ var_dump(preg_match('/\y/X', '\y'));
?>
--EXPECTF--
-int(1)
+Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 3
+bool(false)
Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 4
bool(false)
diff --git a/ext/pcre/tests/preg_grep_error1.phpt b/ext/pcre/tests/preg_grep_error1.phpt
index fcc36e7d91..1bf23bb640 100644
--- a/ext/pcre/tests/preg_grep_error1.phpt
+++ b/ext/pcre/tests/preg_grep_error1.phpt
@@ -6,7 +6,6 @@ Test preg_grep() function : error conditions - bad regular expressions
* proto array preg_grep(string regex, array input [, int flags])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_grep reacts to being passed bad regexes
*/
@@ -19,11 +18,19 @@ $values = array('abcdef', //Regex without delimiter
);
$array = array(123, 'abc', 'test');
foreach($values as $value) {
- print "\nArg value is $value\n";
- var_dump(preg_grep($value, $array));
+ @print "\nArg value is $value\n";
+ try {
+ var_dump(preg_grep($value, $array));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
}
$value = new stdclass(); //Object
-var_dump(preg_grep($value, $array));
+try {
+ var_dump(preg_grep($value, $array));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "Done"
?>
--EXPECTF--
@@ -50,9 +57,7 @@ Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d
bool(false)
Arg value is Array
-
-Warning: preg_grep() expects parameter 1 to be string, array given in %spreg_grep_error1.php on line %d
-NULL
+preg_grep() expects parameter 1 to be string, array given
Arg value is /[a-zA-Z]/
array(2) {
@@ -61,7 +66,5 @@ array(2) {
[2]=>
string(4) "test"
}
-
-Warning: preg_grep() expects parameter 1 to be string, object given in %spreg_grep_error1.php on line %d
-NULL
+preg_grep() expects parameter 1 to be string, object given
Done
diff --git a/ext/pcre/tests/preg_match_all_error1.phpt b/ext/pcre/tests/preg_match_all_error1.phpt
index 95ab905d7d..6a5a0055a9 100644
--- a/ext/pcre/tests/preg_match_all_error1.phpt
+++ b/ext/pcre/tests/preg_match_all_error1.phpt
@@ -6,7 +6,6 @@ Test preg_match_all() function : error conditions - bad regular expressions
* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_match_all reacts to being passed the wrong type of regex argument
*/
@@ -19,12 +18,20 @@ $regex_array = array('abcdef', //Regex without delimiter
);
$subject = 'test';
foreach($regex_array as $regex_value) {
- print "\nArg value is $regex_value\n";
- var_dump(preg_match_all($regex_value, $subject, $matches1));
+ @print "\nArg value is $regex_value\n";
+ try {
+ var_dump(preg_match_all($regex_value, $subject, $matches1));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
var_dump($matches1);
}
$regex_value = new stdclass(); //Object
-var_dump(preg_match_all($regex_value, $subject, $matches));
+try {
+ var_dump(preg_match_all($regex_value, $subject, $matches));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
var_dump($matches);
?>
--EXPECTF--
@@ -55,9 +62,7 @@ bool(false)
NULL
Arg value is Array
-
-Warning: preg_match_all() expects parameter 1 to be string, array given in %spreg_match_all_error1.php on line %d
-bool(false)
+preg_match_all() expects parameter 1 to be string, array given
NULL
Arg value is /[a-zA-Z]/
@@ -75,7 +80,5 @@ array(1) {
string(1) "t"
}
}
-
-Warning: preg_match_all() expects parameter 1 to be string, object given in %spreg_match_all_error1.php on line %d
-bool(false)
+preg_match_all() expects parameter 1 to be string, object given
NULL
diff --git a/ext/pcre/tests/preg_match_all_error2.phpt b/ext/pcre/tests/preg_match_all_error2.phpt
index 1c55cce64e..29762739c4 100644
--- a/ext/pcre/tests/preg_match_all_error2.phpt
+++ b/ext/pcre/tests/preg_match_all_error2.phpt
@@ -6,19 +6,19 @@ Test preg_match_all() function : error conditions - wrong arg types
* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_match_all reacts to being passed the wrong type of input argument
*/
echo "*** Testing preg_match_all() : error conditions ***\n";
$regex = '/[a-zA-Z]/';
-$value = new stdclass(); //Object
-var_dump(preg_match_all($regex, $value, $matches));
-var_dump($matches);
$input = array(array('this is', 'a subarray'), 'test',);
foreach($input as $value) {
- print "\nArg value is: $value\n";
- var_dump(preg_match_all($regex, $value, $matches));
+ @print "\nArg value is: $value\n";
+ try {
+ var_dump(preg_match_all($regex, $value, $matches));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
var_dump($matches);
}
echo "Done";
@@ -26,14 +26,8 @@ echo "Done";
--EXPECTF--
*** Testing preg_match_all() : error conditions ***
-Warning: preg_match_all() expects parameter 2 to be string, object given in %spreg_match_all_error2.php on line %d
-bool(false)
-NULL
-
Arg value is: Array
-
-Warning: preg_match_all() expects parameter 2 to be string, array given in %spreg_match_all_error2.php on line %d
-bool(false)
+preg_match_all() expects parameter 2 to be string, array given
NULL
Arg value is: test
diff --git a/ext/pcre/tests/preg_match_error1.phpt b/ext/pcre/tests/preg_match_error1.phpt
index 42bb5abd27..2f1b39d67f 100644
--- a/ext/pcre/tests/preg_match_error1.phpt
+++ b/ext/pcre/tests/preg_match_error1.phpt
@@ -6,7 +6,6 @@ Test preg_match() function : error conditions - bad regular expressions
* proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_match reacts to being passed the wrong type of regex argument
*/
@@ -19,11 +18,19 @@ $regex_array = array('abcdef', //Regex without delimiter
);
$subject = 'this is a test';
foreach($regex_array as $regex_value) {
- print "\nArg value is $regex_value\n";
- var_dump(preg_match($regex_value, $subject));
+ @print "\nArg value is $regex_value\n";
+ try {
+ var_dump(preg_match($regex_value, $subject));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
}
$regex_value = new stdclass(); //Object
-var_dump(preg_match($regex_value, $subject));
+try {
+ var_dump(preg_match($regex_value, $subject));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
*** Testing preg_match() : error conditions ***
@@ -49,12 +56,8 @@ Warning: preg_match(): Unknown modifier 'F' in %spreg_match_error1.php on line %
bool(false)
Arg value is Array
-
-Warning: preg_match() expects parameter 1 to be string, array given in %spreg_match_error1.php on line %d
-bool(false)
+preg_match() expects parameter 1 to be string, array given
Arg value is /[a-zA-Z]/
int(1)
-
-Warning: preg_match() expects parameter 1 to be string, object given in %spreg_match_error1.php on line %d
-bool(false)
+preg_match() expects parameter 1 to be string, object given
diff --git a/ext/pcre/tests/preg_match_error2.phpt b/ext/pcre/tests/preg_match_error2.phpt
index cb0917a228..18a42c6445 100644
--- a/ext/pcre/tests/preg_match_error2.phpt
+++ b/ext/pcre/tests/preg_match_error2.phpt
@@ -6,7 +6,6 @@ Test preg_match() function : error conditions - wrong arg types
* proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_match reacts to being passed the wrong type of subject argument
*/
@@ -14,11 +13,19 @@ echo "*** Testing preg_match() : error conditions ***\n";
$regex = '/[a-zA-Z]/';
$input = array('this is a string', array('this is', 'a subarray'),);
foreach($input as $value) {
- print "\nArg value is: $value\n";
- var_dump(preg_match($regex, $value));
+ @print "\nArg value is: $value\n";
+ try {
+ var_dump(preg_match($regex, $value));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
}
$value = new stdclass(); //Object
-var_dump(preg_match($regex, $value));
+try {
+ var_dump(preg_match($regex, $value));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "Done";
?>
--EXPECTF--
@@ -28,10 +35,6 @@ Arg value is: this is a string
int(1)
Arg value is: Array
-
-Warning: preg_match() expects parameter 2 to be string, array given in %spreg_match_error2.php on line %d
-bool(false)
-
-Warning: preg_match() expects parameter 2 to be string, object given in %spreg_match_error2.php on line %d
-bool(false)
+preg_match() expects parameter 2 to be string, array given
+preg_match() expects parameter 2 to be string, object given
Done
diff --git a/ext/pcre/tests/preg_replace2.phpt b/ext/pcre/tests/preg_replace2.phpt
index 4a191f3331..13696827fb 100644
--- a/ext/pcre/tests/preg_replace2.phpt
+++ b/ext/pcre/tests/preg_replace2.phpt
@@ -9,8 +9,6 @@ if (@preg_match('/./u', '') === false) {
--FILE--
<?php
-var_dump(preg_replace('', array(), ''));
-
var_dump(preg_replace(array('/\da(.)/ui', '@..@'), '$1', '12Abc'));
var_dump(preg_replace(array('/\da(.)/ui', '@(.)@'), '$1', array('x','a2aA', '1av2Ab')));
@@ -21,9 +19,7 @@ var_dump(preg_replace(array('/\s+/', '~[b-d]~'), array('$'), array('x y', 'bd bc
echo "==done==\n";
?>
---EXPECTF--
-Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace2.php on line 3
-bool(false)
+--EXPECT--
string(1) "c"
array(3) {
[0]=>
diff --git a/ext/pcre/tests/preg_replace_callback2.phpt b/ext/pcre/tests/preg_replace_callback2.phpt
index 1fe78d59ee..6dab1a0cf2 100644
--- a/ext/pcre/tests/preg_replace_callback2.phpt
+++ b/ext/pcre/tests/preg_replace_callback2.phpt
@@ -31,7 +31,7 @@ array(3) {
string(9) "'aa' 'bb'"
}
-Notice: Array to string conversion in %spreg_replace_callback2.php on line 17
+Warning: Array to string conversion in %s on line %d
array(1) {
[0]=>
string(7) "'A'rray"
diff --git a/ext/pcre/tests/preg_replace_callback3.phpt b/ext/pcre/tests/preg_replace_callback3.phpt
index f5c87176f9..842dfacb39 100644
--- a/ext/pcre/tests/preg_replace_callback3.phpt
+++ b/ext/pcre/tests/preg_replace_callback3.phpt
@@ -3,30 +3,14 @@ preg_replace_callback() 3
--FILE--
<?php
-var_dump(preg_replace_callback());
-var_dump(preg_replace_callback(1));
-var_dump(preg_replace_callback(1,2));
var_dump(preg_replace_callback(1,2,3));
var_dump(preg_replace_callback(1,2,3,4));
$a = 5;
var_dump(preg_replace_callback(1,2,3,4,$a));
-$a = "";
-var_dump(preg_replace_callback("","","","",$a));
-$a = array();
-var_dump(preg_replace_callback($a,$a,$a,$a,$a));
echo "Done\n";
?>
--EXPECTF--
-Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
-NULL
-
-Warning: preg_replace_callback() expects at least 3 parameters, 1 given in %s on line %d
-NULL
-
-Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
-NULL
-
Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
string(1) "3"
@@ -35,10 +19,4 @@ string(1) "3"
Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
string(1) "3"
-
-Warning: preg_replace_callback() expects parameter 4 to be int, string given in %s on line %d
-NULL
-
-Warning: preg_replace_callback() expects parameter 4 to be int, array given in %s on line %d
-NULL
Done
diff --git a/ext/pcre/tests/preg_replace_callback_array2.phpt b/ext/pcre/tests/preg_replace_callback_array2.phpt
index f2f20ef645..03d7a60eee 100644
--- a/ext/pcre/tests/preg_replace_callback_array2.phpt
+++ b/ext/pcre/tests/preg_replace_callback_array2.phpt
@@ -3,19 +3,8 @@ preg_replace_callback_array() errors
--FILE--
<?php
-var_dump(preg_replace_callback_array());
-var_dump(preg_replace_callback_array(1));
-var_dump(preg_replace_callback_array(1,2));
-var_dump(preg_replace_callback_array(1,2,3));
-$a = 5;
-var_dump(preg_replace_callback_array(1,2,3,$a));
-$a = "";
-var_dump(preg_replace_callback_array(array("" => ""),"","",$a));
$a = array();
$b = "";
-var_dump(preg_replace_callback($a, $a, $a, $a, $b));
-var_dump($b);
-$b = "";
var_dump(preg_replace_callback_array(array("xx" => "s"), $a, -1, $b));
var_dump($b);
function f() {
@@ -34,28 +23,6 @@ try {
echo "Done\n";
?>
--EXPECTF--
-Warning: preg_replace_callback_array() expects at least 2 parameters, 0 given in %s on line %d
-NULL
-
-Warning: preg_replace_callback_array() expects at least 2 parameters, 1 given in %s on line %d
-NULL
-
-Warning: preg_replace_callback_array() expects parameter 1 to be array, int given in %s on line %d
-NULL
-
-Warning: preg_replace_callback_array() expects parameter 1 to be array, int given in %s on line %d
-NULL
-
-Warning: preg_replace_callback_array() expects parameter 1 to be array, int given in %s on line %d
-NULL
-
-Warning: preg_replace_callback_array() expects parameter 3 to be int, string given in %s on line %d
-NULL
-
-Warning: preg_replace_callback() expects parameter 4 to be int, array given in %s on line %d
-NULL
-string(0) ""
-
Warning: preg_replace_callback_array(): 's' is not a valid callback in %spreg_replace_callback_array2.php on line %d
array(0) {
}
diff --git a/ext/pcre/tests/preg_replace_callback_error1.phpt b/ext/pcre/tests/preg_replace_callback_error1.phpt
index 313064eab8..cf069692e8 100644
--- a/ext/pcre/tests/preg_replace_callback_error1.phpt
+++ b/ext/pcre/tests/preg_replace_callback_error1.phpt
@@ -6,7 +6,6 @@ Test preg_replace_callback() function : error
* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_replace_callback reacts to being passed the wrong type of regex argument
*/
@@ -15,7 +14,7 @@ $regex_array = array('abcdef', //Regex without delimiters
'/[a-zA-Z]', //Regex without closing delimiter
'[a-zA-Z]/', //Regex without opening delimiter
'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
-'[A-Z]', '[0-9]'), '/[a-zA-Z]/'); //Regex string
+'[A-Z]', '[0-9]'), '/[0-9]/'); //Regex string
$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
function integer_word($matches) {
global $replacement;
@@ -23,7 +22,7 @@ function integer_word($matches) {
}
$subject = 'number 1.';
foreach($regex_array as $regex_value) {
- print "\nArg value is $regex_value\n";
+ @print "\nArg value is $regex_value\n";
var_dump(preg_replace_callback($regex_value, 'integer_word', $subject));
}
?>
@@ -54,6 +53,6 @@ NULL
Arg value is Array
string(9) "number 1."
-Arg value is /[a-zA-Z]/
-string(3) " 1."
+Arg value is /[0-9]/
+string(11) "number one."
===Done===
diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt
index 780556956a..669a5c6c4e 100644
--- a/ext/pcre/tests/preg_replace_error1.phpt
+++ b/ext/pcre/tests/preg_replace_error1.phpt
@@ -6,7 +6,6 @@ Test preg_replace() function : error - bad regular expressions
* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_replace reacts to being passed the wrong type of regex argument
*/
@@ -20,7 +19,7 @@ $regex_array = array('abcdef', //Regex without delimiter
$replace = 1;
$subject = 'a';
foreach($regex_array as $regex_value) {
- print "\nArg value is $regex_value\n";
+ @print "\nArg value is $regex_value\n";
var_dump(preg_replace($regex_value, $replace, $subject));
}
$regex_value = new stdclass(); //Object
diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt
index a334b2fefd..eeff2fae54 100644
--- a/ext/pcre/tests/preg_replace_error2.phpt
+++ b/ext/pcre/tests/preg_replace_error2.phpt
@@ -6,7 +6,6 @@ Test preg_replace() function : error conditions - wrong arg types
* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_replace reacts to being passed the wrong type of replacement argument
*/
@@ -15,8 +14,12 @@ $regex = '/[a-zA-Z]/';
$replace = array('this is a string', array('this is', 'a subarray'),);
$subject = 'test';
foreach($replace as $value) {
- print "\nArg value is: $value\n";
- var_dump(preg_replace($regex, $value, $subject));
+ @print "\nArg value is: $value\n";
+ try {
+ var_dump(preg_replace($regex, $value, $subject));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
}
$value = new stdclass(); //Object
try {
@@ -33,8 +36,6 @@ Arg value is: this is a string
string(64) "this is a stringthis is a stringthis is a stringthis is a string"
Arg value is: Array
-
-Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d
-bool(false)
+Parameter mismatch, pattern is a string while replacement is an array
Object of class stdClass could not be converted to string
Done
diff --git a/ext/pcre/tests/preg_split_error1.phpt b/ext/pcre/tests/preg_split_error1.phpt
index 79942a9480..b69caf1aed 100644
--- a/ext/pcre/tests/preg_split_error1.phpt
+++ b/ext/pcre/tests/preg_split_error1.phpt
@@ -6,7 +6,6 @@ Test preg_split() function : error conditions - bad regular expressions
* proto array preg_split(string pattern, string subject [, int limit [, int flags]])
* Function is implemented in ext/pcre/php_pcre.c
*/
-error_reporting(E_ALL&~E_NOTICE);
/*
* Testing how preg_split reacts to being passed the wrong type of regex argument
*/
@@ -19,11 +18,19 @@ $regex_array = array('abcdef', //Regex without delimiter
);
$subject = '1 2 a 3 4 b 5 6';
foreach($regex_array as $regex_value) {
- print "\nArg value is $regex_value\n";
- var_dump(preg_split($regex_value, $subject));
+ @print "\nArg value is $regex_value\n";
+ try {
+ var_dump(preg_split($regex_value, $subject));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
}
$regex_value = new stdclass(); //Object
-var_dump(preg_split($regex_value, $subject));
+try {
+ var_dump(preg_split($regex_value, $subject));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
*** Testing preg_split() : error conditions ***
@@ -49,9 +56,7 @@ Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %
bool(false)
Arg value is Array
-
-Warning: preg_split() expects parameter 1 to be string, array given in %spreg_split_error1.php on line %d
-bool(false)
+preg_split() expects parameter 1 to be string, array given
Arg value is /[a-zA-Z]/
array(3) {
@@ -62,6 +67,4 @@ array(3) {
[2]=>
string(4) " 5 6"
}
-
-Warning: preg_split() expects parameter 1 to be string, object given in %spreg_split_error1.php on line %d
-bool(false)
+preg_split() expects parameter 1 to be string, object given
diff --git a/ext/pcre/tests/split.phpt b/ext/pcre/tests/split.phpt
index c87d1b03a9..df4b9af92f 100644
--- a/ext/pcre/tests/split.phpt
+++ b/ext/pcre/tests/split.phpt
@@ -3,7 +3,6 @@ preg_split()
--FILE--
<?php
-var_dump(preg_split());
var_dump(preg_split('/*/', 'x'));
var_dump(preg_split('/[\s, ]+/', 'x yy,zzz'));
@@ -17,10 +16,7 @@ var_dump(preg_split('/\d*/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY));
?>
--EXPECTF--
-Warning: preg_split() expects at least 2 parameters, 0 given in %ssplit.php on line 3
-bool(false)
-
-Warning: preg_split(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %ssplit.php on line 4
+Warning: preg_split(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %ssplit.php on line %d
bool(false)
array(3) {
[0]=>
diff --git a/ext/pcre/tests/split2.phpt b/ext/pcre/tests/split2.phpt
index 5c77c6d1bc..5fafee3b87 100644
--- a/ext/pcre/tests/split2.phpt
+++ b/ext/pcre/tests/split2.phpt
@@ -13,7 +13,6 @@ var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPL
var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
-var_dump(preg_last_error(1));
ini_set('pcre.recursion_limit', 1);
var_dump(preg_last_error() == PREG_NO_ERROR);
var_dump(preg_split('/(\d*)/', 'ab2c3u'));
@@ -306,9 +305,6 @@ array(6) {
int(5)
}
}
-
-Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
bool(true)
bool(false)
bool(true)