8000 [php-symfony] Set required PHP version ^7.1.3 (#6181) · OpenAPITools/openapi-generator@83bad10 · GitHub
[go: up one dir, main page]

Skip to content

Commit 83bad10

Browse files
authored
[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: symfony/symfony#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
1 parent 30caeed commit 83bad10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+201
-119
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ public void processOpts() {
300300
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
301301
additionalProperties.put("controllerPackage", controllerPackage);
302302
additionalProperties.put("servicePackage", servicePackage);
303+
additionalProperties.put("testsPackage", testsPackage);
303304
additionalProperties.put("apiTestsPackage", apiTestsPackage);
304305
additionalProperties.put("modelTestsPackage", modelTestsPackage);
305306
additionalProperties.put("controllerTestsPackage", controllerTestsPackage);
@@ -349,7 +350,7 @@ public void processOpts() {
349350
// Testing components
350351
supportingFiles.add(new SupportingFile("testing/phpunit.xml.mustache", "", "phpunit.xml.dist"));
351352
supportingFiles.add(new SupportingFile("testing/pom.xml", "", "pom.xml"));
352-
supportingFiles.add(new SupportingFile("testing/AppKernel.php", toSrcPath(testsPackage, srcBasePath), "AppKernel.php"));
353+
supportingFiles.add(new SupportingFile("testing/AppKernel.mustache", toSrcPath(testsPackage, srcBasePath), "AppKernel.php"));
353354
supportingFiles.add(new SupportingFile("testing/ControllerTest.mustache", toSrcPath(controllerTestsPackage, srcBasePath), "ControllerTest.php"));
354355
supportingFiles.add(new SupportingFile("testing/test_config.yml", toSrcPath(testsPackage, srcBasePath), "test_config.yml"));
355356

@@ -360,7 +361,8 @@ public void processOpts() {
360361
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
361362

362363
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
363-
supportingFiles.add(new SupportingFile(".php_cs", "", ".php_cs"));
364+
supportingFiles.add(new SupportingFile(".php_cs.dist", "", ".php_cs.dist"));
365+
supportingFiles.add(new SupportingFile(".coveralls.yml", "", ".coveralls.yml"));
364366
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
365367

366368
// Type-hintable primitive types
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
service_name: travis-ci # travis-ci or travis-pro
2+
3+
# for php-coveralls
4+
coverage_clover: report/logs/clover.xml
5+
json_path: report/logs/coveralls-upload.json

modules/openapi-generator/src/main/resources/php-symfony/.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
!bin/symfony_requirements
3030
/vendor/
3131

32+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
33+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
34+
composer.lock
35+
3236
# Assets and user uploads
3337
/web/bundles/
3438
/web/uploads/
@@ -51,4 +55,14 @@
5155

5256
# From root gitignore
5357
/Tests/cache/
54-
/Tests/logs/
58+
/Tests/logs/
59+
60+
# PHP Coding Standards Fixer
61+
# https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#config-file
62+
# From now you can create new configuration file: .php_cs.dist.
63+
# This file is used if no .php_cs file was found.
64+
# 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.
65+
/.php_cs
66+
67+
# No reason to commit PHP CS Fixer cache files
68+
/.php_cs.cache

modules/openapi-generator/src/main/resources/php-symfony/.php_cs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__)
5+
;
6+
7+
return PhpCsFixer\Config::create()
8+
->setUsingCache(true)
9+
->setRules([
10+
'@PSR2' => true,
11+
'ordered_imports' => [
12+
'sort_algorithm' => 'alpha'
13+
],
14+
'phpdoc_order' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'strict_comparison' => true,
17+
'strict_param' => true
18+
])
19+
->setFinder($finder)
20+
;
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
language: php
2-
sudo: false
2+
dist: trusty
33
php:
4-
- 5.4
5-
- 5.5
6-
- 5.6
7-
- 7.0
8-
- hhvm
9-
before_install: "composer install"
10-
script: "vendor/bin/phpunit"
4+
- 7.1.3
5+
- 7.2
6+
7+
install:
8+
- composer install --dev --no-interaction
9+
script:
10+
- mkdir -p report/logs
11+
- php vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=report/logs/clover.xml
12+
- php vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no
13+
14+
before_script:
15+
- composer require --dev php-coveralls/php-coveralls --no-interaction
16+
17+
after_success:
18+
- travis_retry php vendor/bin/php-coveralls
19+
# or enable logging
20+
- travis_retry php vendor/bin/php-coveralls -v

modules/openapi-generator/src/main/resources/php-symfony/ApiPass.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* {{bundleName}}ApiPass
44
*
5-
* PHP version 5
5+
* PHP version 7.1.3
66
*
77
* @category Class
88
* @package {{invokerPackage}}\DependencyInjection\Compiler

modules/openapi-generator/src/main/resources/php-symfony/ApiServer.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* ApiServer
44
*
5-
* PHP version 5
5+
* PHP version 7.1.3
66
*
77
* @category Class
88
* @package {{apiPackage}}

modules/openapi-generator/src/main/resources/php-symfony/Bundle.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* {{bundleClassName}}
44
*
5-
* PHP version 5
5+
* PHP version 7.1.3
66
*
77
* @category Class
88
* @package {{invokerPackage}}

modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Controller
44
*
5-
* PHP version 5
5+
* PHP version 7.1.3
66
*
77
* @category Class
88
* @package {{controllerPackage}}

0 commit comments

Comments
 (0)
0