forked from loafle/openapi-generator-original
[php] Add PSR-12 rule set (#12302)
* Upgrade PHPCS-Fixer to 3.5 version This version requires PHP 7.4 or 8.0 which perfectly meets our supported PHP right now. * Rename config file to .php-cs-fixer.dist.php This way it can be overwritten with local file(same name without "dist" part). Also it's recommended filename from the package doc. * Add PSR12 rule set to config I've changed config file a bit to look like example from the doc. Ref: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst * Ignore new cache format * Remove blank line after class opening * Set constants in models public * Refresh samples
This commit is contained in:
parent
8d4c9e2472
commit
e639dad66a
@ -108,7 +108,7 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
|
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
|
||||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
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"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
;
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return PhpCsFixer\Config::create()
|
|
||||||
->setUsingCache(true)
|
|
||||||
->setRules([
|
|
||||||
'@PSR2' => true,
|
|
||||||
'ordered_imports' => 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,
|
|
||||||
])
|
|
||||||
->setFinder(
|
|
||||||
PhpCsFixer\Finder::create()
|
|
||||||
->exclude('test')
|
|
||||||
->exclude('tests')
|
|
||||||
->in(__DIR__)
|
|
||||||
);
|
|
@ -30,7 +30,6 @@ use \Exception;
|
|||||||
*/
|
*/
|
||||||
class ApiException extends Exception
|
class ApiException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTTP body of the server response either as Json or string.
|
* The HTTP body of the server response either as Json or string.
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,6 @@ use \Exception;
|
|||||||
*/
|
*/
|
||||||
class HeaderSelector
|
class HeaderSelector
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $accept
|
* @param string[] $accept
|
||||||
* @param string[] $contentTypes
|
* @param string[] $contentTypes
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.0 || ^9.0",
|
"phpunit/phpunit": "^8.0 || ^9.0",
|
||||||
"friendsofphp/php-cs-fixer": "^2.12"
|
"friendsofphp/php-cs-fixer": "^3.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" }
|
"psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" }
|
||||||
|
@ -9,6 +9,7 @@ composer.phar
|
|||||||
|
|
||||||
# php-cs-fixer cache
|
# php-cs-fixer cache
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
|
.php-cs-fixer.cache
|
||||||
|
|
||||||
# PHPUnit cache
|
# PHPUnit cache
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
@ -5,7 +5,7 @@ class {{classname}}
|
|||||||
*/
|
*/
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
const {{^isString}}NUMBER_{{/isString}}{{{name}}} = {{{value}}};
|
public const {{^isString}}NUMBER_{{/isString}}{{{name}}} = {{{value}}};
|
||||||
|
|
||||||
{{/enumVars}}
|
{{/enumVars}}
|
||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
|
@ -127,7 +127,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
|
|||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
const {{enumName}}_{{{name}}} = {{{value}}};
|
public const {{enumName}}_{{{name}}} = {{{value}}};
|
||||||
{{/enumVars}}
|
{{/enumVars}}
|
||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
|
@ -9,6 +9,7 @@ composer.phar
|
|||||||
|
|
||||||
# php-cs-fixer cache
|
# php-cs-fixer cache
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
|
.php-cs-fixer.cache
|
||||||
|
|
||||||
# PHPUnit cache
|
# PHPUnit cache
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.gitignore
|
.gitignore
|
||||||
.php_cs
|
.php-cs-fixer.dist.php
|
||||||
.travis.yml
|
.travis.yml
|
||||||
README.md
|
README.md
|
||||||
composer.json
|
composer.json
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
;
|
@ -27,7 +27,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.0 || ^9.0",
|
"phpunit/phpunit": "^8.0 || ^9.0",
|
||||||
"friendsofphp/php-cs-fixer": "^2.12"
|
"friendsofphp/php-cs-fixer": "^3.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "OpenAPI\\Client\\" : "lib/" }
|
"psr-4": { "OpenAPI\\Client\\" : "lib/" }
|
||||||
|
@ -39,7 +39,6 @@ use \Exception;
|
|||||||
*/
|
*/
|
||||||
class ApiException extends Exception
|
class ApiException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTTP body of the server response either as Json or string.
|
* The HTTP body of the server response either as Json or string.
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,6 @@ use \Exception;
|
|||||||
*/
|
*/
|
||||||
class HeaderSelector
|
class HeaderSelector
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $accept
|
* @param string[] $accept
|
||||||
* @param string[] $contentTypes
|
* @param string[] $contentTypes
|
||||||
|
@ -167,10 +167,10 @@ class EnumArrays implements ModelInterface, ArrayAccess, \JsonSerializable
|
|||||||
return self::$openAPIModelName;
|
return self::$openAPIModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>=';
|
public const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>=';
|
||||||
const JUST_SYMBOL_DOLLAR = '$';
|
public const JUST_SYMBOL_DOLLAR = '$';
|
||||||
const ARRAY_ENUM_FISH = 'fish';
|
public const ARRAY_ENUM_FISH = 'fish';
|
||||||
const ARRAY_ENUM_CRAB = 'crab';
|
public const ARRAY_ENUM_CRAB = 'crab';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,11 +42,11 @@ class EnumClass
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const ABC = '_abc';
|
public const ABC = '_abc';
|
||||||
|
|
||||||
const EFG = '-efg';
|
public const EFG = '-efg';
|
||||||
|
|
||||||
const XYZ = '(xyz)';
|
public const XYZ = '(xyz)';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -197,16 +197,16 @@ class EnumTest implements ModelInterface, ArrayAccess, \JsonSerializable
|
|||||||
return self::$openAPIModelName;
|
return self::$openAPIModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ENUM_STRING_UPPER = 'UPPER';
|
public const ENUM_STRING_UPPER = 'UPPER';
|
||||||
const ENUM_STRING_LOWER = 'lower';
|
public const ENUM_STRING_LOWER = 'lower';
|
||||||
const ENUM_STRING_EMPTY = '';
|
public const ENUM_STRING_EMPTY = '';
|
||||||
const ENUM_STRING_REQUIRED_UPPER = 'UPPER';
|
public const ENUM_STRING_REQUIRED_UPPER = 'UPPER';
|
||||||
const ENUM_STRING_REQUIRED_LOWER = 'lower';
|
public const ENUM_STRING_REQUIRED_LOWER = 'lower';
|
||||||
const ENUM_STRING_REQUIRED_EMPTY = '';
|
public const ENUM_STRING_REQUIRED_EMPTY = '';
|
||||||
const ENUM_INTEGER_1 = 1;
|
public const ENUM_INTEGER_1 = 1;
|
||||||
const ENUM_INTEGER_MINUS_1 = -1;
|
public const ENUM_INTEGER_MINUS_1 = -1;
|
||||||
const ENUM_NUMBER_1_DOT_1 = 1.1;
|
public const ENUM_NUMBER_1_DOT_1 = 1.1;
|
||||||
const ENUM_NUMBER_MINUS_1_DOT_2 = -1.2;
|
public const ENUM_NUMBER_MINUS_1_DOT_2 = -1.2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -177,8 +177,8 @@ class MapTest implements ModelInterface, ArrayAccess, \JsonSerializable
|
|||||||
return self::$openAPIModelName;
|
return self::$openAPIModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAP_OF_ENUM_STRING_UPPER = 'UPPER';
|
public const MAP_OF_ENUM_STRING_UPPER = 'UPPER';
|
||||||
const MAP_OF_ENUM_STRING_LOWER = 'lower';
|
public const MAP_OF_ENUM_STRING_LOWER = 'lower';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -187,9 +187,9 @@ class Order implements ModelInterface, ArrayAccess, \JsonSerializable
|
|||||||
return self::$openAPIModelName;
|
return self::$openAPIModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUS_PLACED = 'placed';
|
public const STATUS_PLACED = 'placed';
|
||||||
const STATUS_APPROVED = 'approved';
|
public const STATUS_APPROVED = 'approved';
|
||||||
const STATUS_DELIVERED = 'delivered';
|
public const STATUS_DELIVERED = 'delivered';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,11 +42,11 @@ class OuterEnum
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const PLACED = 'placed';
|
public const PLACED = 'placed';
|
||||||
|
|
||||||
const APPROVED = 'approved';
|
public const APPROVED = 'approved';
|
||||||
|
|
||||||
const DELIVERED = 'delivered';
|
public const DELIVERED = 'delivered';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,11 +42,11 @@ class OuterEnumDefaultValue
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const PLACED = 'placed';
|
public const PLACED = 'placed';
|
||||||
|
|
||||||
const APPROVED = 'approved';
|
public const APPROVED = 'approved';
|
||||||
|
|
||||||
const DELIVERED = 'delivered';
|
public const DELIVERED = 'delivered';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,11 +42,11 @@ class OuterEnumInteger
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const NUMBER_0 = 0;
|
public const NUMBER_0 = 0;
|
||||||
|
|
||||||
const NUMBER_1 = 1;
|
public const NUMBER_1 = 1;
|
||||||
|
|
||||||
const NUMBER_2 = 2;
|
public const NUMBER_2 = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,11 +42,11 @@ class OuterEnumIntegerDefaultValue
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const NUMBER_0 = 0;
|
public const NUMBER_0 = 0;
|
||||||
|
|
||||||
const NUMBER_1 = 1;
|
public const NUMBER_1 = 1;
|
||||||
|
|
||||||
const NUMBER_2 = 2;
|
public const NUMBER_2 = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -187,9 +187,9 @@ class Pet implements ModelInterface, ArrayAccess, \JsonSerializable
|
|||||||
return self::$openAPIModelName;
|
return self::$openAPIModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUS_AVAILABLE = 'available';
|
public const STATUS_AVAILABLE = 'available';
|
||||||
const STATUS_PENDING = 'pending';
|
public const STATUS_PENDING = 'pending';
|
||||||
const STATUS_SOLD = 'sold';
|
public const STATUS_SOLD = 'sold';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
@ -42,9 +42,9 @@ class SingleRefType
|
|||||||
/**
|
/**
|
||||||
* Possible values of this enum
|
* Possible values of this enum
|
||||||
*/
|
*/
|
||||||
const ADMIN = 'admin';
|
public const ADMIN = 'admin';
|
||||||
|
|
||||||
const USER = 'user';
|
public const USER = 'user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets allowable values of the enum
|
* Gets allowable values of the enum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user