Bug #75425 [Fbk]: mb_convert_variables converts integers to strings

From: Date: Tue, 24 Oct 2017 12:01:34 +0000
Subject: Bug #75425 [Fbk]: mb_convert_variables converts integers to strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212273@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75425&edit=1

 ID:                 75425
 Updated by:         nikic@php.net
 Reported by:        info at its-mieger dot de
 Summary:            mb_convert_variables converts integers to strings
 Status:             Feedback
 Type:               Bug
 Package:            mbstring related
 Operating System:   debian
 PHP Version:        7.1.10
 Block user comment: N
 Private report:     N

 New Comment:

I can't reproduce this behavior with the provided test script: https://3v4l.org/fZH3m


Previous Comments:
------------------------------------------------------------------------
[2017-10-24 11:59:34] requinix@php.net

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?

------------------------------------------------------------------------
[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)

« previous php.bugs (#212273) next »