Skip to content

Fixing incorrect error message when passing null to join/implode's array parameter #12683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Making tests PSR-12 compliant
  • Loading branch information
CViniciusSDias committed Nov 22, 2023
commit 95b8db9262c19858c49fe1a0a83e8f033baf0e74
8 changes: 4 additions & 4 deletions ext/standard/tests/strings/implode_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ Test implode() function: error conditions
<?php
/* only glue */
try {
var_dump( implode("glue") );
var_dump(implode("glue"));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}

/* NULL as pieces */
try {
var_dump( implode("glue", NULL) );
var_dump(implode("glue", NULL));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}

/* integer as glue */
try {
var_dump( implode(12, "pieces") );
var_dump(implode(12, "pieces"));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
--EXPECT--
implode(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given
implode(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given
implode(): Argument #2 ($array) must be of type ?array, string given
14 changes: 7 additions & 7 deletions ext/standard/tests/strings/implode_variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test implode() function
--FILE--
<?php
echo "*** Testing implode() for basic operations ***\n";
$arrays = array (
$arrays = array(
array(1,2),
array(1.1,2.2),
array(array(2),array(1)),
Expand All @@ -14,13 +14,13 @@ $arrays = array (
);
/* loop to output string with ', ' as $glue, using implode() */
foreach ($arrays as $array) {
var_dump( implode(', ', $array) );
var_dump(implode(', ', $array));
var_dump($array);
}

echo "\n*** Testing implode() with variations of glue ***\n";
/* checking possible variations */
$pieces = array (
$pieces = array(
2,
0,
-639,
Expand All @@ -31,7 +31,7 @@ $pieces = array (
" ",
"string\x00with\x00...\0"
);
$glues = array (
$glues = array(
"TRUE",
true,
false,
Expand Down Expand Up @@ -73,7 +73,7 @@ try {
echo $exception->getMessage() . "\n";
}
try {
var_dump( implode(2, $sub_array) );
var_dump(implode(2, $sub_array));
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
}
Expand All @@ -91,7 +91,7 @@ $obj = new foo(); //creating new object
$arr = array();
$arr[0] = &$obj;
$arr[1] = &$obj;
var_dump( implode(",", $arr) );
var_dump(implode(",", $arr));
var_dump($arr);

/* Checking on resource types */
Expand All @@ -105,7 +105,7 @@ $dir_handle = opendir( __DIR__ );
/* store resources in array for comparison */
$resources = array($file_handle, $dir_handle);

var_dump( implode("::", $resources) );
var_dump(implode("::", $resources));

/* closing resource handles */
fclose($file_handle);
Expand Down
3 changes: 1 addition & 2 deletions ext/standard/tests/strings/join_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class test

// array with different values
$values = array (

// integer values
0,
1,
Expand Down Expand Up @@ -84,7 +83,7 @@ for($index = 0; $index < count($values); $index ++) {
$pieces = $values [$index];

try {
var_dump( join($glue, $pieces) );
var_dump(join($glue, $pieces));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
Expand Down