Skip to content

Commit 46b9824

Browse files
committed
Deprecate implode() with swapped parameter order
1 parent cd2f2cd commit 46b9824

File tree

7 files changed

+17
-2
lines changed

7 files changed

+17
-2
lines changed

Zend/tests/unexpected_ref_bug.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ $my_var=array(1,2,3);
1515
$data = call_user_func_array("implode",array(&$my_var, new Test()));
1616
echo "Done.\n";
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
19+
Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
1920
Done.

ext/standard/string.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,8 @@ PHP_FUNCTION(implode)
12921292
if (Z_TYPE_P(arg1) == IS_ARRAY) {
12931293
glue = zval_get_tmp_string(arg2, &tmp_glue);
12941294
pieces = arg1;
1295+
php_error_docref(NULL, E_DEPRECATED,
1296+
"Passing glue string after array is deprecated. Swap the parameters");
12951297
} else if (Z_TYPE_P(arg2) == IS_ARRAY) {
12961298
glue = zval_get_tmp_string(arg1, &tmp_glue);
12971299
pieces = arg2;

ext/standard/tests/strings/explode_variation7.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edgarsandi - <[email protected]>
1111
* Source code: ext/standard/string.c
1212
*/
1313

14-
var_dump(count(explode('|', implode(range(1,65),'|'), -1)));
14+
var_dump(count(explode('|', implode('|', range(1,65)), -1)));
1515

1616
?>
1717
--EXPECT--
216 Bytes
Binary file not shown.

ext/standard/tests/strings/join_variation1.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,32 @@ string(19) "element10.5element2"
123123
-- Iteration 10 --
124124

125125
Notice: Array to string conversion in %s on line %d
126+
127+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
126128
string(0) ""
127129
-- Iteration 11 --
128130

129131
Notice: Array to string conversion in %s on line %d
132+
133+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
130134
string(1) "0"
131135
-- Iteration 12 --
132136

133137
Notice: Array to string conversion in %s on line %d
138+
139+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
134140
string(1) "1"
135141
-- Iteration 13 --
136142

137143
Notice: Array to string conversion in %s on line %d
144+
145+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
138146
string(7) "1Array2"
139147
-- Iteration 14 --
140148

141149
Notice: Array to string conversion in %s on line %d
150+
151+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
142152
string(11) "redArraypen"
143153
-- Iteration 15 --
144154
string(17) "element11element2"
105 Bytes
Binary file not shown.

ext/standard/tests/strings/join_variation5.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Notice: Array to string conversion in %s on line %d
3939
string(27) "ArrayTESTArrayTESTPHPTEST50"
4040

4141
Notice: Array to string conversion in %s on line %d
42+
43+
Deprecated: join(): Passing glue string after array is deprecated. Swap the parameters in %s on line %d
4244
string(19) "1Array2Array3Array4"
4345

4446
Notice: Array to string conversion in %s on line %d

0 commit comments

Comments
 (0)