File tree Expand file tree Collapse file tree 7 files changed +94
-5
lines changed
Expand file tree Collapse file tree 7 files changed +94
-5
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ PHP NEWS
9999- Standard:
100100 . E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
101101 . Make array_pad's $length warning less confusing. (nielsdos)
102+ . E_WARNING emitted by strtok in the caase both arguments are not provided when
103+ starting tokenisation. (David Carlier)
102104
103105- Streams:
104106 . Fixed bug #51056: blocking fread() will block even if data is available.
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ PHP 8.3 UPGRADE NOTES
6868 . array_pad() is now only limited by the maximum number of elements an array
6969 can have. Before, it was only possible to add at most 1048576 elements at a
7070 time.
71+ . strtok() raises a warninin the case token is not provided when starting tokenization.
7172
7273========================================
73746. New Functions
Original file line number Diff line number Diff line change @@ -1080,7 +1080,7 @@ PHP_FUNCTION(strtok)
10801080
10811081 if (!BG (strtok_string )) {
10821082 /* String to tokenize not set. */
1083- // TODO: Should this warn?
1083+ php_error_docref ( NULL , E_WARNING , "Both arguments must be provided when starting tokenization" );
10841084 RETURN_FALSE ;
10851085 }
10861086
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ foreach($heredoc_strings as $string) {
6262
6363echo "Done \n" ;
6464?>
65- --EXPECT --
65+ --EXPECTF --
6666*** Testing strtok() : with heredoc strings ***
6767
6868--- Iteration 1 ---
@@ -80,15 +80,35 @@ bool(false)
8080
8181--- Iteration 2 ---
8282bool(false)
83+
84+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8385bool(false)
86+
87+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8488bool(false)
89+
90+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8591bool(false)
92+
93+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8694bool(false)
95+
96+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8797bool(false)
98+
99+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
88100bool(false)
101+
102+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
89103bool(false)
104+
105+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
90106bool(false)
107+
108+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
91109bool(false)
110+
111+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
92112bool(false)
93113
94114--- Iteration 3 ---
@@ -137,9 +157,19 @@ string(3) "rld"
137157string(4) "hell"
138158string(4) "hell"
139159bool(false)
160+
161+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
140162bool(false)
163+
164+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
141165bool(false)
166+
167+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
142168bool(false)
169+
170+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
143171bool(false)
172+
173+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
144174bool(false)
145175Done
Original file line number Diff line number Diff line change @@ -36,15 +36,25 @@ foreach( $strings_with_nulls as $string ) {
3636
3737echo "Done \n" ;
3838?>
39- --EXPECT --
39+ --EXPECTF --
4040*** Testing strtok() : with embedded nulls in the strings ***
4141
4242--- Iteration 1 ---
4343bool(false)
44+
45+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
4446bool(false)
47+
48+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
4549bool(false)
50+
51+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
4652bool(false)
53+
54+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
4755bool(false)
56+
57+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
4858bool(false)
4959
5060--- Iteration 2 ---
@@ -82,9 +92,17 @@ bool(false)
8292--- Iteration 6 ---
8393string(11) "hello world"
8494bool(false)
95+
96+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
8597bool(false)
98+
99+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
86100bool(false)
101+
102+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
87103bool(false)
104+
105+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
88106bool(false)
89107
90108--- Iteration 7 ---
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ foreach( $string_array as $string ) {
5252
5353echo "Done \n" ;
5454?>
55- --EXPECT --
55+ --EXPECTF --
5656*** Testing strtok() : with miscellaneous inputs ***
5757
5858--- Iteration 1 ---
@@ -65,10 +65,20 @@ bool(false)
6565
6666--- Iteration 2 ---
6767bool(false)
68+
69+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
6870bool(false)
71+
72+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
6973bool(false)
74+
75+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
7076bool(false)
77+
78+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
7179bool(false)
80+
81+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
7282bool(false)
7383
7484--- Iteration 3 ---
@@ -113,18 +123,38 @@ bool(false)
113123
114124--- Iteration 8 ---
115125bool(false)
126+
127+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
116128bool(false)
129+
130+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
117131bool(false)
132+
133+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
118134bool(false)
135+
136+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
119137bool(false)
138+
139+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
120140bool(false)
121141
122142--- Iteration 9 ---
123143bool(false)
144+
145+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
124146bool(false)
147+
148+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
125149bool(false)
150+
151+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
126152bool(false)
153+
154+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
127155bool(false)
156+
157+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
128158bool(false)
129159
130160--- Iteration 10 ---
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ foreach( $string_array as $string ) {
4242
4343echo "Done \n" ;
4444?>
45- --EXPECT --
45+ --EXPECTF --
4646*** Testing strtok() : with invalid escape sequences in token ***
4747
4848--- Iteration 1 ---
@@ -69,6 +69,8 @@ bool(false)
6969string(1) " "
7070string(1) "r"
7171bool(false)
72+
73+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
7274bool(false)
7375
7476
@@ -91,11 +93,15 @@ bool(false)
9193string(5) "hello"
9294string(6) " world"
9395bool(false)
96+
97+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
9498bool(false)
9599
96100string(1) " "
97101string(1) "r"
98102bool(false)
103+
104+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
99105bool(false)
100106
101107
@@ -113,6 +119,8 @@ bool(false)
113119string(6) "hello\"
114120string(6) " world"
115121bool(false)
122+
123+ Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
116124bool(false)
117125
118126string(1) "/"
You can’t perform that action at this time.
0 commit comments