xref: /PHP-8.1/ext/mbstring/tests/mb_ereg1.phpt (revision 6600ad60)
1--TEST--
2mb_ereg() and invalid arguments
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php if (!function_exists("mb_ereg")) print "skip"; ?>
7--FILE--
8<?php
9
10$a = array(
11    array(1,2,3),
12    array("", "", ""),
13    array(array(), 1, ""),
14    array(1, array(), ""),
15    array(1, "", array()),
16    );
17
18foreach ($a as $args) {
19    try {
20        var_dump(mb_ereg($args[0], $args[1], $args[2]));
21    } catch (\TypeError|\ValueError $e) {
22        echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL;
23    }
24    var_dump($args);
25}
26?>
27--EXPECT--
28bool(false)
29array(3) {
30  [0]=>
31  int(1)
32  [1]=>
33  int(2)
34  [2]=>
35  array(0) {
36  }
37}
38ValueError: mb_ereg(): Argument #1 ($pattern) must not be empty
39array(3) {
40  [0]=>
41  string(0) ""
42  [1]=>
43  string(0) ""
44  [2]=>
45  string(0) ""
46}
47TypeError: mb_ereg(): Argument #1 ($pattern) must be of type string, array given
48array(3) {
49  [0]=>
50  array(0) {
51  }
52  [1]=>
53  int(1)
54  [2]=>
55  string(0) ""
56}
57TypeError: mb_ereg(): Argument #2 ($string) must be of type string, array given
58array(3) {
59  [0]=>
60  int(1)
61  [1]=>
62  array(0) {
63  }
64  [2]=>
65  string(0) ""
66}
67bool(false)
68array(3) {
69  [0]=>
70  int(1)
71  [1]=>
72  string(0) ""
73  [2]=>
74  array(0) {
75  }
76}
77