Bug #75425 [Opn->Fbk]: mb_convert_variables converts integers to strings
Edit report at https://bugs.php.net/bug.php?id=75425&edit=1
ID: 75425
Updated by: requinix@php.net
Reported by: info at its-mieger dot de
Summary: mb_convert_variables converts integers to strings
-Status: Open
+Status: Feedback
Type: Bug
Package: mbstring related
Operating System: debian
PHP Version: 7.1.10
Block user comment: N
Private report: N
New Comment:
Well yeah: it's as if you wrote
$x["a"] = mb_convert_encoding($x["a"], "UTF-8",
"ISO-8859-15");
I would expect mb_convert_variables() to work on strings (or recursively on arrays and objects) and
not to silently pass through values of a non-conforming type. It's like how
substr("123", 0, 1)
is the string "1" and not the integer 1 (let alone 123). Type casting like that is
standard behavior for PHP.
Does that make sense?
Previous Comments:
------------------------------------------------------------------------
[2017-10-24 11:42:40] info at its-mieger dot de
Description:
------------
Integer values are converted to strings by mb_convert_variables. But variable types should be kept
Test script:
---------------
$x = ["a" => 1];
mb_convert_variables("UTF-8", "ISO-8859-15", $x);
var_dump($x);
Expected result:
----------------
array(1) {
["a"]=>
int(1)
}
Actual result:
--------------
array(1) {
["a"]=>
string(1) "1"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75425&edit=1
Thread (5 messages)