Merge pull request #604 from wing328/php_fix_warning

Fixed PHP5.3 warning
This commit is contained in:
Tony Tam 2015-04-08 05:01:54 -06:00
commit eb2ec92b66
7 changed files with 201 additions and 103 deletions

View File

@ -25,6 +25,16 @@ class APIClient {
public static $PUT = "PUT";
public static $DELETE = "DELETE";
/*
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
*/
protected $curl_timeout = 0;
/*
* @var string user agent of the HTTP request, set to "PHP-Swagger" by default
*/
protected $user_agent = "PHP-Swagger";
/**
* @param string $host the address of the API server
* @param string $headerName a header to pass on requests
@ -54,7 +64,7 @@ class APIClient {
if (!is_numeric($seconds)) {
throw new Exception('Timeout variable must be numeric.');
}
$this->curl_timout = $seconds;
$this->curl_timeout = $seconds;
}
/**
@ -84,15 +94,16 @@ class APIClient {
$headers[] = $this->headerName . ": " . $this->headerValue;
}
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) {
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath;
$curl = curl_init();
if ($this->curl_timout) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@ -120,11 +131,7 @@ class APIClient {
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent
if ($this->user_agent) {
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
} else { // use PHP-Swagger as the default user agent
curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
}
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// Make the request
$response = curl_exec($curl);

View File

@ -44,6 +44,7 @@ class {{classname}} {
$resourcePath = "{{path}}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "{{httpMethod}}";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -77,16 +78,19 @@ class {{classname}} {
$body = ${{paramName}};
}{{/bodyParams}}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
{{#returnType}}if(! $response) {

View File

@ -25,6 +25,16 @@ class APIClient {
public static $PUT = "PUT";
public static $DELETE = "DELETE";
/*
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
*/
protected $curl_timeout = 0;
/*
* @var string user agent of the HTTP request, set to "PHP-Swagger" by default
*/
protected $user_agent = "PHP-Swagger";
/**
* @param string $host the address of the API server
* @param string $headerName a header to pass on requests
@ -54,7 +64,7 @@ class APIClient {
if (!is_numeric($seconds)) {
throw new Exception('Timeout variable must be numeric.');
}
$this->curl_timout = $seconds;
$this->curl_timeout = $seconds;
}
/**
@ -84,15 +94,16 @@ class APIClient {
$headers[] = $this->headerName . ": " . $this->headerValue;
}
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) {
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath;
$curl = curl_init();
if ($this->curl_timout) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@ -120,11 +131,7 @@ class APIClient {
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent
if ($this->user_agent) {
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
} else { // use PHP-Swagger as the default user agent
curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
}
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// Make the request
$response = curl_exec($curl);

View File

@ -43,6 +43,7 @@ class PetApi {
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -63,16 +64,19 @@ class PetApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -92,6 +96,7 @@ class PetApi {
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -112,16 +117,19 @@ class PetApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -141,6 +149,7 @@ class PetApi {
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -160,16 +169,19 @@ class PetApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -195,6 +207,7 @@ class PetApi {
$resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -214,16 +227,19 @@ class PetApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -249,6 +265,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -269,16 +286,19 @@ class PetApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -306,6 +326,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -332,16 +353,19 @@ class PetApi {
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -362,6 +386,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -385,16 +410,19 @@ class PetApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -416,6 +444,7 @@ class PetApi {
$resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -442,16 +471,19 @@ class PetApi {
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);

View File

@ -42,6 +42,7 @@ class StoreApi {
$resourcePath = "/store/inventory";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -58,16 +59,19 @@ class StoreApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -93,6 +97,7 @@ class StoreApi {
$resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -113,16 +118,19 @@ class StoreApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -148,6 +156,7 @@ class StoreApi {
$resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -168,16 +177,19 @@ class StoreApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -203,6 +215,7 @@ class StoreApi {
$resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -223,16 +236,19 @@ class StoreApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);

View File

@ -43,6 +43,7 @@ class UserApi {
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -63,16 +64,19 @@ class UserApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -92,6 +96,7 @@ class UserApi {
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -112,16 +117,19 @@ class UserApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -141,6 +149,7 @@ class UserApi {
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -161,16 +170,19 @@ class UserApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -191,6 +203,7 @@ class UserApi {
$resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -213,16 +226,19 @@ class UserApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -247,6 +263,7 @@ class UserApi {
$resourcePath = "/user/logout";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -263,16 +280,19 @@ class UserApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -292,6 +312,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -312,16 +333,19 @@ class UserApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
if(! $response) {
@ -348,6 +372,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -372,16 +397,19 @@ class UserApi {
$body = $body;
}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
@ -401,6 +429,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@ -421,16 +450,19 @@ class UserApi {
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);

View File

@ -16,7 +16,7 @@
*/
/**
* testing category description
*
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*