diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index f961f5cd60..4fac824803 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -242,7 +242,7 @@ class ObjectSerializer } $deserialized = $values; } elseif ($class === 'ByteArray') { // byte array - $deserialized = unpack('C*', (string)$data); + $deserialized = (string)$data; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array({{&primitives}}))) { diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index d21301ee38..1740a38010 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -188,7 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{#bodyParams}}// body params $_tempBody = null; if (isset(${{paramName}})) { - {{^isBinary}}$_tempBody = ${{paramName}};{{/isBinary}}{{#isBinary}}$_tempBody = call_user_func_array('pack', array_merge(array('C*'), ${{paramName}}));{{/isBinary}} + $_tempBody = ${{paramName}}; }{{/bodyParams}} // for model (json/xml) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index c83eec7310..c0776fdcad 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -1036,7 +1036,7 @@ class PetApi // body params $_tempBody = null; if (isset($body)) { - $_tempBody = call_user_func_array('pack', array_merge(array('C*'), $body)); + $_tempBody = $body; } // for model (json/xml) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 7b3509b585..1dba9fb691 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -242,7 +242,7 @@ class ObjectSerializer } $deserialized = $values; } elseif ($class === 'ByteArray') { // byte array - $deserialized = unpack('C*', (string)$data); + $deserialized = (string)$data; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 44d9093636..96ceaf9801 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -279,7 +279,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase // add a new pet (model) $object_serializer = new Swagger\Client\ObjectSerializer(); $pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet)); - $add_response = $pet_api->addPetUsingByteArray(unpack('C*', $pet_json_string)); + $add_response = $pet_api->addPetUsingByteArray($pet_json_string); // return nothing (void) $this->assertSame($add_response, NULL); // verify added Pet @@ -330,9 +330,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase // test getPetByIdWithByteArray $pet_id = 10005; $bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id); - $json = json_decode(call_user_func_array('pack', array_merge(array('C*'), $bytes )), true); + $json = json_decode($bytes, true); - $this->assertInternalType("array", $bytes); + $this->assertInternalType("string", $bytes); $this->assertSame($json['id'], $pet_id); // not testing name as it's tested by addPetUsingByteArray