[php-symfony] Set required PHP version ^7.1.3 (#6181)

* Set PHP 7.1.3 required version

I've tried to specify ^7.0 version at first, but main package which is
symfony/framework-bundle@v4.4.8 requires PHP ^7.1.3.

* Bump Symfony FrameworkBundle to ^4.4.8

Current Symfony Framework stable version is v5.0.8, but I guess it
requires significant codebase upgrade, so I've sticked with 4.4.8 which
shouldn't cause any breaking changes. Old requirement was ^3.3|^4.1
which compatible with 4.4.8.

* Bump PHPUnit version to ^7.0

PHPUnit 8.x version required PHP ^7.2, so I'm setting 7.x version to
support PHP 7.1.
There is new way to specify Kernel class, related PR:
https://github.com/symfony/symfony/pull/22668

* Bump PHP CS Fixer version to ^2.16.3

Configuration and all renamed rules fixed.
Config file renamed to .php_cs.dist as recommended in migration guide.
Migration guide from 1.x to 2.x:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#config-file

* Remove PHP_CodeSniffer package

Second linter doesn't make sense. I think Symfony user would prefer
PHP CS Fixer over PHP_CodeSniffer because first one maintained by Symfony
members.

* Remove satooshi/php-coveralls package from Composer

This package is abandoned and Coveralls recommends to install it directly
in Travis-CI task script.

* Update Travic-CI config

I've changed test versions to PHP 7.1.3 and 7.2. PHPUnit generates
coverage report in report/logs/clover.xml file. Then PHP CS Fixer runs
with --dry-run option to not override anything just to show coding style
errors.

* Add basic Coveralls config

This is basic recommended config for a PHP based project.

* Add symfony/yaml package

This package was part of satooshi/php-coveralls, now it should be
defined as dev dependency.

* Do not commit composer.lock

I think committed composer.lock can cause CI errors while tests on fresh
installs are better.

* Remove confusing Ruby comment
This commit is contained in:
Yuriy Belenko 2020-05-29 13:35:11 +03:00 committed by GitHub
parent 30caeedb98
commit 83bad102ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 201 additions and 119 deletions

View File

@ -300,6 +300,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
additionalProperties.put("controllerPackage", controllerPackage);
additionalProperties.put("servicePackage", servicePackage);
additionalProperties.put("testsPackage", testsPackage);
additionalProperties.put("apiTestsPackage", apiTestsPackage);
additionalProperties.put("modelTestsPackage", modelTestsPackage);
additionalProperties.put("controllerTestsPackage", controllerTestsPackage);
@ -349,7 +350,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// Testing components
supportingFiles.add(new SupportingFile("testing/phpunit.xml.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile("testing/pom.xml", "", "pom.xml"));
supportingFiles.add(new SupportingFile("testing/AppKernel.php", toSrcPath(testsPackage, srcBasePath), "AppKernel.php"));
supportingFiles.add(new SupportingFile("testing/AppKernel.mustache", toSrcPath(testsPackage, srcBasePath), "AppKernel.php"));
supportingFiles.add(new SupportingFile("testing/ControllerTest.mustache", toSrcPath(controllerTestsPackage, srcBasePath), "ControllerTest.php"));
supportingFiles.add(new SupportingFile("testing/test_config.yml", toSrcPath(testsPackage, srcBasePath), "test_config.yml"));
@ -360,7 +361,8 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
supportingFiles.add(new SupportingFile(".php_cs", "", ".php_cs"));
supportingFiles.add(new SupportingFile(".php_cs.dist", "", ".php_cs.dist"));
supportingFiles.add(new SupportingFile(".coveralls.yml", "", ".coveralls.yml"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
// Type-hintable primitive types

View File

@ -0,0 +1,5 @@
service_name: travis-ci # travis-ci or travis-pro
# for php-coveralls
coverage_clover: report/logs/clover.xml
json_path: report/logs/coveralls-upload.json

View File

@ -29,6 +29,10 @@
!bin/symfony_requirements
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
# Assets and user uploads
/web/bundles/
/web/uploads/
@ -51,4 +55,14 @@
# From root gitignore
/Tests/cache/
/Tests/logs/
/Tests/logs/
# PHP Coding Standards Fixer
# https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#config-file
# From now you can create new configuration file: .php_cs.dist.
# This file is used if no .php_cs file was found.
# It is recommended to create .php_cs.dist file attached in your repository and add .php_cs file to .gitignore for allowing your contributors to have theirs own configuration file.
/.php_cs
# No reason to commit PHP CS Fixer cache files
/.php_cs.cache

View File

@ -1,18 +0,0 @@
<?php
return Symfony\CS\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->setUsingCache(true)
->fixers(
[
'ordered_use',
'phpdoc_order',
'short_array_syntax',
'strict',
'strict_param'
]
)
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
);

View File

@ -0,0 +1,20 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
return PhpCsFixer\Config::create()
->setUsingCache(true)
->setRules([
'@PSR2' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha'
],
'phpdoc_order' => true,
'array_syntax' => ['syntax' => 'short'],
'strict_comparison' => true,
'strict_param' => true
])
->setFinder($finder)
;

View File

@ -1,10 +1,20 @@
language: php
sudo: false
dist: trusty
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
before_install: "composer install"
script: "vendor/bin/phpunit"
- 7.1.3
- 7.2
install:
- composer install --dev --no-interaction
script:
- mkdir -p report/logs
- php vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=report/logs/clover.xml
- php vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no
before_script:
- composer require --dev php-coveralls/php-coveralls --no-interaction
after_success:
- travis_retry php vendor/bin/php-coveralls
# or enable logging
- travis_retry php vendor/bin/php-coveralls -v

View File

@ -2,7 +2,7 @@
/**
* {{bundleName}}ApiPass
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{invokerPackage}}\DependencyInjection\Compiler

View File

@ -2,7 +2,7 @@
/**
* ApiServer
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{apiPackage}}

View File

@ -2,7 +2,7 @@
/**
* {{bundleClassName}}
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{invokerPackage}}

View File

@ -2,7 +2,7 @@
/**
* Controller
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{controllerPackage}}

View File

@ -2,7 +2,7 @@
/**
* {{bundleExtensionName}}
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{invokerPackage}}\DependencyInjection

View File

@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requirements
PHP 5.4.0 and later
PHP 7.1.3 and later
## Installation & Usage

View File

@ -1,7 +1,7 @@
<?php
/**
* {{classname}}
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{invokerPackage}}

View File

@ -2,7 +2,7 @@
{{#operations}}/**
* {{controllerName}}
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{controllerPackage}}

View File

@ -19,20 +19,19 @@
}
],
"require": {
"php": ">=5.4",
"php": "^7.1.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"symfony/validator": "*",
"jms/serializer-bundle": "^2.0",
"symfony/framework-bundle": "^3.3|^4.1"
"symfony/framework-bundle": "^4.4.8"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~1.0",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~1.12",
"phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer": "^2.16.3",
"symfony/browser-kit": "*",
"symfony/yaml": "^4.4.8",
"hoa/regex": "~1.0"
},
"autoload": {

View File

@ -4,7 +4,7 @@
/**
* {{classname}}
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{modelPackage}}

View File

@ -1,5 +1,8 @@
<?php
namespace {{testsPackage}};
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
@ -8,7 +11,7 @@ class AppKernel extends Kernel
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle()
new FrameworkBundle()
);
return $bundles;

View File

@ -1,7 +1,7 @@
<?php
/**
* ControllerTest
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{controllerTestsPackage}}

View File

@ -1,7 +1,7 @@
<?php
/**
* {{classname}}Test
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{apiTestsPackage}}

View File

@ -4,7 +4,7 @@
/**
* {{classname}}Test
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package {{modelTestsPackage}}
@ -21,6 +21,8 @@
namespace {{modelPackage}};
use PHPUnit\Framework\TestCase;
/**
* {{classname}}Test Class Doc Comment
*
@ -31,7 +33,7 @@ namespace {{modelPackage}};
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class {{classname}}Test extends \PHPUnit_Framework_TestCase
class {{classname}}Test extends TestCase
{
/**

View File

@ -21,6 +21,6 @@
</filter>
<php>
<ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_DIR" value="Tests/" />
<server name="KERNEL_CLASS" value="{{testsPackage}}\AppKernel" />
</php>
</phpunit>

View File

@ -0,0 +1,5 @@
service_name: travis-ci # travis-ci or travis-pro
# for php-coveralls
coverage_clover: report/logs/clover.xml
json_path: report/logs/coveralls-upload.json

View File

@ -29,6 +29,10 @@
!bin/symfony_requirements
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
# Assets and user uploads
/web/bundles/
/web/uploads/
@ -51,4 +55,14 @@
# From root gitignore
/Tests/cache/
/Tests/logs/
/Tests/logs/
# PHP Coding Standards Fixer
# https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#config-file
# From now you can create new configuration file: .php_cs.dist.
# This file is used if no .php_cs file was found.
# It is recommended to create .php_cs.dist file attached in your repository and add .php_cs file to .gitignore for allowing your contributors to have theirs own configuration file.
/.php_cs
# No reason to commit PHP CS Fixer cache files
/.php_cs.cache

View File

@ -1,18 +0,0 @@
<?php
return Symfony\CS\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->setUsingCache(true)
->fixers(
[
'ordered_use',
'phpdoc_order',
'short_array_syntax',
'strict',
'strict_param'
]
)
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
);

View File

@ -0,0 +1,20 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
return PhpCsFixer\Config::create()
->setUsingCache(true)
->setRules([
'@PSR2' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha'
],
'phpdoc_order' => true,
'array_syntax' => ['syntax' => 'short'],
'strict_comparison' => true,
'strict_param' => true
])
->setFinder($finder)
;

View File

@ -1,10 +1,20 @@
language: php
sudo: false
dist: trusty
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
before_install: "composer install"
script: "vendor/bin/phpunit"
- 7.1.3
- 7.2
install:
- composer install --dev --no-interaction
script:
- mkdir -p report/logs
- php vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=report/logs/clover.xml
- php vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no
before_script:
- composer require --dev php-coveralls/php-coveralls --no-interaction
after_success:
- travis_retry php vendor/bin/php-coveralls
# or enable logging
- travis_retry php vendor/bin/php-coveralls -v

View File

@ -2,7 +2,7 @@
/**
* ApiServer
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Api

View File

@ -1,7 +1,7 @@
<?php
/**
* PetApiInterface
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server

View File

@ -1,7 +1,7 @@
<?php
/**
* StoreApiInterface
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server

View File

@ -1,7 +1,7 @@
<?php
/**
* UserApiInterface
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server

View File

@ -2,7 +2,7 @@
/**
* Controller
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Controller

View File

@ -2,7 +2,7 @@
/**
* PetController
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Controller

View File

@ -2,7 +2,7 @@
/**
* StoreController
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Controller

View File

@ -2,7 +2,7 @@
/**
* UserController
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Controller

View File

@ -2,7 +2,7 @@
/**
* OpenAPIServerApiPass
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\DependencyInjection\Compiler

View File

@ -2,7 +2,7 @@
/**
* OpenAPIServerExtension
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\DependencyInjection

View File

@ -2,7 +2,7 @@
/**
* ApiResponse
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* Category
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* Order
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* Pet
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* Tag
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* User
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model

View File

@ -2,7 +2,7 @@
/**
* OpenAPIServerBundle
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server

View File

@ -8,7 +8,7 @@ This [Symfony](https://symfony.com/) bundle is automatically generated by the [O
## Requirements
PHP 5.4.0 and later
PHP 7.1.3 and later
## Installation & Usage

View File

@ -1,7 +1,7 @@
<?php
/**
* PetApiInterfaceTest
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Api

View File

@ -1,7 +1,7 @@
<?php
/**
* StoreApiInterfaceTest
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Api

View File

@ -1,7 +1,7 @@
<?php
/**
* UserApiInterfaceTest
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Api

View File

@ -1,5 +1,8 @@
<?php
namespace OpenAPI\Server\Tests;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
@ -8,7 +11,7 @@ class AppKernel extends Kernel
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle()
new FrameworkBundle()
);
return $bundles;

View File

@ -1,7 +1,7 @@
<?php
/**
* ControllerTest
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Controller

View File

@ -2,7 +2,7 @@
/**
* ApiResponseTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* ApiResponseTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class ApiResponseTest extends \PHPUnit_Framework_TestCase
class ApiResponseTest extends TestCase
{
/**

View File

@ -2,7 +2,7 @@
/**
* CategoryTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* CategoryTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class CategoryTest extends \PHPUnit_Framework_TestCase
class CategoryTest extends TestCase
{
/**

View File

@ -2,7 +2,7 @@
/**
* OrderTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* OrderTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class OrderTest extends \PHPUnit_Framework_TestCase
class OrderTest extends TestCase
{
/**

View File

@ -2,7 +2,7 @@
/**
* PetTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* PetTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class PetTest extends \PHPUnit_Framework_TestCase
class PetTest extends TestCase
{
/**

View File

@ -2,7 +2,7 @@
/**
* TagTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* TagTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class TagTest extends \PHPUnit_Framework_TestCase
class TagTest extends TestCase
{
/**

View File

@ -2,7 +2,7 @@
/**
* UserTest
*
* PHP version 5
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
@ -29,6 +29,8 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* UserTest Class Doc Comment
*
@ -39,7 +41,7 @@ namespace OpenAPI\Server\Model;
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class UserTest extends \PHPUnit_Framework_TestCase
class UserTest extends TestCase
{
/**

View File

@ -16,20 +16,19 @@
}
],
"require": {
"php": ">=5.4",
"php": "^7.1.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"symfony/validator": "*",
"jms/serializer-bundle": "^2.0",
"symfony/framework-bundle": "^3.3|^4.1"
"symfony/framework-bundle": "^4.4.8"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~1.0",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~1.12",
"phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer": "^2.16.3",
"symfony/browser-kit": "*",
"symfony/yaml": "^4.4.8",
"hoa/regex": "~1.0"
},
"autoload": {

View File

@ -21,6 +21,6 @@
</filter>
<php>
<ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_DIR" value="Tests/" />
<server name="KERNEL_CLASS" value="OpenAPI\Server\Tests\AppKernel" />
</php>
</phpunit>