mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Merge pull request #776 from wing328/php53_fix_warning
[PHP] Fix warning/error related to PHP5.3
This commit is contained in:
commit
74dc05bbf5
@ -41,7 +41,7 @@ class APIClient {
|
|||||||
* @param string $host Base url of the API server (optional)
|
* @param string $host Base url of the API server (optional)
|
||||||
*/
|
*/
|
||||||
function __construct($host = null) {
|
function __construct($host = null) {
|
||||||
if ($host == null) {
|
if ($host === null) {
|
||||||
$this->host = '{{basePath}}';
|
$this->host = '{{basePath}}';
|
||||||
} else {
|
} else {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
@ -107,10 +107,12 @@ class APIClient {
|
|||||||
* @return string API key with the prefix
|
* @return string API key with the prefix
|
||||||
*/
|
*/
|
||||||
public function getApiKeyWithPrefix($apiKey) {
|
public function getApiKeyWithPrefix($apiKey) {
|
||||||
if (Configuration::$apiKeyPrefix[$apiKey]) {
|
if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
|
||||||
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
||||||
} else {
|
} else if (isset(Configuration::$apiKey[$apiKey])) {
|
||||||
return Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKey[$apiKey];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +370,7 @@ class APIClient {
|
|||||||
$instance = new $class();
|
$instance = new $class();
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class APIClient {
|
|||||||
* @param string $host Base url of the API server (optional)
|
* @param string $host Base url of the API server (optional)
|
||||||
*/
|
*/
|
||||||
function __construct($host = null) {
|
function __construct($host = null) {
|
||||||
if ($host == null) {
|
if ($host === null) {
|
||||||
$this->host = 'http://petstore.swagger.io/v2';
|
$this->host = 'http://petstore.swagger.io/v2';
|
||||||
} else {
|
} else {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
@ -107,10 +107,12 @@ class APIClient {
|
|||||||
* @return string API key with the prefix
|
* @return string API key with the prefix
|
||||||
*/
|
*/
|
||||||
public function getApiKeyWithPrefix($apiKey) {
|
public function getApiKeyWithPrefix($apiKey) {
|
||||||
if (Configuration::$apiKeyPrefix[$apiKey]) {
|
if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
|
||||||
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
||||||
} else {
|
} else if (isset(Configuration::$apiKey[$apiKey])) {
|
||||||
return Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKey[$apiKey];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +375,7 @@ class APIClient {
|
|||||||
$instance = new $class();
|
$instance = new $class();
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
$category->id = $new_pet_id; // use the same id as pet
|
$category->id = $new_pet_id; // use the same id as pet
|
||||||
$category->name = "test php category";
|
$category->name = "test php category";
|
||||||
|
|
||||||
$new_pet->tags = [$tag];
|
$new_pet->tags = array($tag);
|
||||||
$new_pet->category = $category;
|
$new_pet->category = $category;
|
||||||
|
|
||||||
$pet_api = new SwaggerClient\PetAPI($api_client);
|
$pet_api = new SwaggerClient\PetAPI($api_client);
|
||||||
@ -47,12 +47,14 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
# test addDefaultHeader and getDefaultHeader
|
# test addDefaultHeader and getDefaultHeader
|
||||||
SwaggerClient\APIClient::addDefaultHeader('test1', 'value1');
|
SwaggerClient\APIClient::addDefaultHeader('test1', 'value1');
|
||||||
SwaggerClient\APIClient::addDefaultHeader('test2', 200);
|
SwaggerClient\APIClient::addDefaultHeader('test2', 200);
|
||||||
$this->assertSame('value1', SwaggerClient\APIClient::getDefaultHeader()['test1']);
|
$defaultHeader = SwaggerClient\APIClient::getDefaultHeader();
|
||||||
$this->assertSame(200, SwaggerClient\APIClient::getDefaultHeader()['test2']);
|
$this->assertSame('value1', $defaultHeader['test1']);
|
||||||
|
$this->assertSame(200, $defaultHeader['test2']);
|
||||||
|
|
||||||
# test deleteDefaultHeader
|
# test deleteDefaultHeader
|
||||||
SwaggerClient\APIClient::deleteDefaultHeader('test2');
|
SwaggerClient\APIClient::deleteDefaultHeader('test2');
|
||||||
$this->assertFalse(isset(SwaggerClient\APIClient::getDefaultHeader()['test2']));
|
$defaultHeader = SwaggerClient\APIClient::getDefaultHeader();
|
||||||
|
$this->assertFalse(isset($defaultHeader['test2']));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user