Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Bump minimum required version to PHP7.1 #1491

Merged
merged 14 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ before_install:
- sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
- sudo apt-get update
- sudo apt-get install dart
# switch to php7
- phpenv global 7.1
- php -v
# install perl module
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
#- cpanm Test::Exception Test::More Log::Any LWP::UserAgent JSON URI:Query Module::Runtime DateTime Module::Find Moose::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace {{invokerPackage}};
use \{{invokerPackage}}\Configuration;
use \{{invokerPackage}}\ApiException;
use \{{invokerPackage}}\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* {{classname}}Test Class Doc Comment
Expand All @@ -30,7 +31,7 @@ use \{{invokerPackage}}\ObjectSerializer;
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
{{#operations}}class {{classname}}Test extends \PHPUnit_Framework_TestCase
{{#operations}}class {{classname}}Test extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^7.4",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~2.12"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace {{invokerPackage}};

use PHPUnit\Framework\TestCase;

/**
* {{classname}}Test Class Doc Comment
*
Expand All @@ -30,7 +32,7 @@ namespace {{invokerPackage}};
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class {{classname}}Test extends \PHPUnit_Framework_TestCase
class {{classname}}Test extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite>
<testsuite name="tests">
<directory>{{apiTestPath}}</directory>
<directory>{{modelTestPath}}</directory>
</testsuite>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0-SNAPSHOT
3.3.4-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^7.4",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~2.12"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down Expand Up @@ -253,10 +253,10 @@ protected function testCodeInjectEndRnNRRequest($unknown_base_type = null)
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
$httpBody = $_tempBody;
// \stdClass has no __toString(), so we should encode it manually
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($httpBody);
if ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody));
} else {
$httpBody = $_tempBody;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: [email protected] *_/ ' \" =end -- \\r\\n \\n \\r
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 3.3.0-SNAPSHOT
* OpenAPI Generator version: 3.3.4-SNAPSHOT
*/

/**
Expand All @@ -29,6 +29,8 @@

namespace OpenAPI\Client;

use OpenAPI\Client\Model\ModelInterface;

/**
* ObjectSerializer Class Doc Comment
*
Expand Down Expand Up @@ -61,19 +63,25 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
return $data;
} elseif (is_object($data)) {
$values = [];
$formats = $data::openAPIFormats();
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if ($value !== null
&& !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)
&& method_exists($openAPIType, 'getAllowableEnumValues')
&& !in_array($value, $openAPIType::getAllowableEnumValues(), true)) {
$imploded = implode("', '", $openAPIType::getAllowableEnumValues());
throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'");
if ($data instanceof ModelInterface) {
$formats = $data::openAPIFormats();
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if ($value !== null
&& !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)
&& method_exists($openAPIType, 'getAllowableEnumValues')
&& !in_array($value, $openAPIType::getAllowableEnumValues(), true)) {
$imploded = implode("', '", $openAPIType::getAllowableEnumValues());
throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'");
}
if ($value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}
}
if ($value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
} else {
foreach($data as $property => $value) {
$values[$property] = self::sanitizeForSerialization($value);
}
}
return (object)$values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite>
<testsuite name="tests">
<directory>./test/Api</directory>
<directory>./test/Model</directory>
</testsuite>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/php/OpenAPIClient-php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^7.4",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~2.12"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite>
<testsuite name="tests">
<directory>./test/Api</directory>
<directory>./test/Model</directory>
</testsuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* AnotherFakeApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AnotherFakeApiTest extends \PHPUnit_Framework_TestCase
class AnotherFakeApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* FakeApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class FakeApiTest extends \PHPUnit_Framework_TestCase
class FakeApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* FakeClassnameTags123ApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class FakeClassnameTags123ApiTest extends \PHPUnit_Framework_TestCase
class FakeClassnameTags123ApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* PetApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class PetApiTest extends \PHPUnit_Framework_TestCase
class PetApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* StoreApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class StoreApiTest extends \PHPUnit_Framework_TestCase
class StoreApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use \OpenAPI\Client\Configuration;
use \OpenAPI\Client\ApiException;
use \OpenAPI\Client\ObjectSerializer;
use PHPUnit\Framework\TestCase;

/**
* UserApiTest Class Doc Comment
Expand All @@ -40,7 +41,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class UserApiTest extends \PHPUnit_Framework_TestCase
class UserApiTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

namespace OpenAPI\Client;

use PHPUnit\Framework\TestCase;

/**
* AdditionalPropertiesClassTest Class Doc Comment
*
Expand All @@ -38,7 +40,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AdditionalPropertiesClassTest extends \PHPUnit_Framework_TestCase
class AdditionalPropertiesClassTest extends TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

namespace OpenAPI\Client;

use PHPUnit\Framework\TestCase;

/**
* AnimalFarmTest Class Doc Comment
*
Expand All @@ -38,7 +40,7 @@
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AnimalFarmTest extends \PHPUnit_Framework_TestCase
class AnimalFarmTest extends TestCase
{

/**
Expand Down
Loading