Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !12302

[php] Add PSR-12 rule set

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/ybelenko/4726_phpclient into master 3 years ago
  • Overview 0
  • Commits 7
  • Pipelines 0
  • Changes 25

Created by: ybelenko

I've added PSR-12 rule set to Php-CS-Fixer config since it's officially supported now. The config file has been renamed to .php-cs-fixer.dist.php to be able to overwrite it with local config file without dist part.

I don't know why we have so many rules since we agreed to follow PSR-12 only at the first place. New config:

/**
 * @generated
 * @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
 */
$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
    ->exclude('vendor')
    ->exclude('test')
    ->exclude('tests')
;

$config = new PhpCsFixer\Config();
return $config->setRules([
        '@PSR12' => true,
        'phpdoc_order' => true,
        'array_syntax' => [ 'syntax' => 'short' ],
        'strict_comparison' => true,
        'strict_param' => true,
        'no_trailing_whitespace' => false,
        'no_trailing_whitespace_in_comment' => false,
        'braces' => false,
        'single_blank_line_at_eof' => false,
        'blank_line_after_namespace' => false,
        'no_leading_import_slash' => false,
    ])
    ->setFinder($finder)
;

If somebody knows why we have disabled:

        'braces' => false,
        'single_blank_line_at_eof' => false,
        'blank_line_after_namespace' => false,

Also added rule no_leading_import_slash => false because there are model classes with leadings slashes in imports. No clue why, but still.

Fixer run output:

vendor/bin/php-cs-fixer fix --allow-risky=yes -vv
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.0.16
Loaded config default from "/Users/ybelenko/Sites/openapi-generator/samples/client/petstore/php/OpenAPIClient-php/.php-cs-fixer.dist.php".
............................................................                                                                                    60 / 60 (100%)
Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error

Fixed all files in 2.246 seconds, 28.000 MB memory used

I would remove the old .php_cs file from samples right in current PR, but the CI workflow will be failed instantly...

Related #4726

cc @jebentier @dkarlovi @mandrean @jfastnacht @renepardon

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Compare
  • master (base)

and
  • latest version
    a384bd41
    7 commits, 2 years ago

25 files
+ 105
- 49

    Preferences

    File browser
    Compare changes
modules/openapi-g‎enerator/src/main‎
java/org/openapitoo‎ls/codegen/languages‎
PhpClientC‎odegen.java‎ +1 -1
resour‎ces/php‎
.php-cs-fix‎er.dist.php‎ +29 -0
ApiExcepti‎on.mustache‎ +0 -1
HeaderSelec‎tor.mustache‎ +0 -1
composer‎.mustache‎ +1 -1
giti‎gnore‎ +1 -0
model_enu‎m.mustache‎ +1 -1
model_gener‎ic.mustache‎ +1 -1
samples/client/…/ph‎p/OpenAPIClient-php‎
.openapi-‎generator‎
FI‎LES‎ +1 -1
l‎ib‎
Mo‎del‎
EnumArr‎ays.php‎ +4 -4
EnumCl‎ass.php‎ +3 -3
EnumTe‎st.php‎ +10 -10
MapTe‎st.php‎ +2 -2
Orde‎r.php‎ +3 -3
OuterE‎num.php‎ +3 -3
OuterEnumDef‎aultValue.php‎ +3 -3
OuterEnumI‎nteger.php‎ +3 -3
OuterEnumInteger‎DefaultValue.php‎ +3 -3
Pet‎.php‎ +3 -3
SingleRe‎fType.php‎ +2 -2
ApiExcep‎tion.php‎ +0 -1
HeaderSel‎ector.php‎ +0 -1
.giti‎gnore‎ +1 -0
.php-cs-fix‎er.dist.php‎ +29 -0
compos‎er.json‎ +1 -1
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpClientCodegen.java
+ 1
- 1
  • View file @ a384bd41

  • Edit in single-file editor

  • Open in Web IDE


@@ -108,7 +108,7 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
supportingFiles.add(new SupportingFile(".php_cs", "", ".php_cs"));
supportingFiles.add(new SupportingFile(".php-cs-fixer.dist.php", "", ".php-cs-fixer.dist.php"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
}
}
modules/openapi-generator/src/main/resources/php/.php_cs → modules/openapi-generator/src/main/resources/php/.php-cs-fixer.dist.php
+ 29
- 0
  • View file @ a384bd41

  • Edit in single-file editor

  • Open in Web IDE


<?php
return PhpCsFixer\Config::create()
->setUsingCache(true)
->setRules([
'@PSR2' => true,
'ordered_imports' => true,
/**
* @generated
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
*/
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('vendor')
->exclude('test')
->exclude('tests')
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'phpdoc_order' => true,
'array_syntax' => [ 'syntax' => 'short' ],
'strict_comparison' => true,
@@ -14,10 +23,7 @@ return PhpCsFixer\Config::create()
'braces' => false,
'single_blank_line_at_eof' => false,
'blank_line_after_namespace' => false,
'no_leading_import_slash' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('test')
->exclude('tests')
->in(__DIR__)
);
->setFinder($finder)
;
modules/openapi-generator/src/main/resources/php/ApiException.mustache
+ 0
- 1
  • View file @ a384bd41

  • Edit in single-file editor

  • Open in Web IDE


@@ -30,7 +30,6 @@ use \Exception;
*/
class ApiException extends Exception
{
/**
* The HTTP body of the server response either as Json or string.
*
modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache
+ 0
- 1
  • View file @ a384bd41

  • Edit in single-file editor

  • Open in Web IDE


@@ -30,7 +30,6 @@ use \Exception;
*/
class HeaderSelector
{
/**
* @param string[] $accept
* @param string[] $contentTypes
modules/openapi-generator/src/main/resources/php/composer.mustache
+ 1
- 1
  • View file @ a384bd41

  • Edit in single-file editor

  • Open in Web IDE


@@ -33,7 +33,7 @@
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^2.12"
"friendsofphp/php-cs-fixer": "^3.5"
},
"autoload": {
"psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" }
0 Assignees
None
Assign to
0 Reviewers
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
Lock merge request
Unlocked
participants
Reference:
Source branch: github/fork/ybelenko/4726_phpclient

Menu

Explore Projects Groups Snippets