From 6b499cc5e2a7dd66c3131500a54abeec35383add Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Tue, 5 Oct 2021 17:50:51 +0200 Subject: [PATCH] Upgrade PHP-CS-Fixer to 3.x (#2937) --- .gitattributes | 2 +- .github/workflows/static.yml | 2 +- .gitignore | 4 ++-- .php_cs.dist => .php-cs-fixer.dist.php | 7 +++---- Makefile | 2 +- src/ClientInterface.php | 2 +- src/HandlerStack.php | 12 ++++++------ src/RetryMiddleware.php | 2 +- vendor-bin/php-cs-fixer/composer.json | 2 +- 9 files changed, 17 insertions(+), 18 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (96%) diff --git a/.gitattributes b/.gitattributes index a1ccc0af..f5c552e8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,7 @@ .gitattributes export-ignore /.github/ export-ignore .gitignore export-ignore -.php_cs.dist export-ignore +.php-cs-fixer.dist.php export-ignore /docs/ export-ignore /Dockerfile export-ignore /Makefile export-ignore diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 8f4e046d..dff5cb70 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -53,7 +53,7 @@ jobs: run: composer bin php-cs-fixer update --no-interaction --no-progress - name: Execute PHP CS Fixer - run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run + run: vendor/bin/php-cs-fixer fix --diff --dry-run psalm: name: Psalm diff --git a/.gitignore b/.gitignore index 1d692112..17a858b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -.php_cs -.php_cs.cache +.php-cs-fixer.php +.php-cs-fixer.cache .phpunit.result.cache composer.lock vendor/ diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 96% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index d966cdce..024fb0a5 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,24 +1,22 @@ setRiskyAllowed(true) ->setRules([ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], 'binary_operator_spaces' => ['operators' => ['=>' => null]], 'blank_line_after_opening_tag' => true, - 'class_attributes_separation' => ['elements' => ['method']], + 'class_attributes_separation' => ['elements' => ['method' => 'one']], 'compact_nullable_typehint' => true, 'concat_space' => ['spacing' => 'one'], 'declare_equal_normalize' => ['space' => 'none'], 'declare_strict_types' => false, 'dir_constant' => true, - 'final_static_access' => true, 'fully_qualified_strict_types' => true, 'function_to_constant' => true, 'function_typehint_space' => true, 'header_comment' => false, - 'is_null' => ['use_yoda_style' => false], 'list_syntax' => ['syntax' => 'short'], 'lowercase_cast' => true, 'magic_method_casing' => true, @@ -66,6 +64,7 @@ $config = PhpCsFixer\Config::create() 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'phpdoc_var_without_name' => true, 'return_assignment' => true, + 'self_static_accessor' => true, 'short_scalar_cast' => true, 'single_trait_insert_per_statement' => true, 'standardize_not_equals' => true, diff --git a/Makefile b/Makefile index f7ffadcf..0b52841f 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ static-phpstan-update-baseline: static-codestyle-fix: composer install composer bin php-cs-fixer update - vendor/bin/php-cs-fixer fix --diff-format udiff $(CS_PARAMS) + vendor/bin/php-cs-fixer fix --diff $(CS_PARAMS) static-codestyle-check: $(MAKE) static-codestyle-fix CS_PARAMS="--dry-run" diff --git a/src/ClientInterface.php b/src/ClientInterface.php index f257a1a3..6aaee61a 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -16,7 +16,7 @@ interface ClientInterface /** * The Guzzle major version. */ - const MAJOR_VERSION = 7; + public const MAJOR_VERSION = 7; /** * Send an HTTP request. diff --git a/src/HandlerStack.php b/src/HandlerStack.php index 406136e4..e0a1d119 100644 --- a/src/HandlerStack.php +++ b/src/HandlerStack.php @@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface; class HandlerStack { /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $handler; @@ -25,7 +25,7 @@ class HandlerStack private $stack = []; /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $cached; @@ -40,9 +40,9 @@ class HandlerStack * The returned handler stack can be passed to a client in the "handler" * option. * - * @param null|callable(RequestInterface, array): PromiseInterface $handler HTTP handler function to use with the stack. If no - * handler is provided, the best handler for your - * system will be utilized. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no + * handler is provided, the best handler for your + * system will be utilized. */ public static function create(?callable $handler = null): self { @@ -56,7 +56,7 @@ class HandlerStack } /** - * @param null|callable(RequestInterface, array): PromiseInterface $handler Underlying HTTP handler. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler. */ public function __construct(callable $handler = null) { diff --git a/src/RetryMiddleware.php b/src/RetryMiddleware.php index eb41929b..c210fc47 100644 --- a/src/RetryMiddleware.php +++ b/src/RetryMiddleware.php @@ -36,7 +36,7 @@ class RetryMiddleware * returns true if the request is to be * retried. * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke. - * @param null|callable(int): int $delay Function that accepts the number of retries + * @param (callable(int): int)|null $delay Function that accepts the number of retries * and returns the number of * milliseconds to delay. */ diff --git a/vendor-bin/php-cs-fixer/composer.json b/vendor-bin/php-cs-fixer/composer.json index 3adf5f5c..d69a683b 100644 --- a/vendor-bin/php-cs-fixer/composer.json +++ b/vendor-bin/php-cs-fixer/composer.json @@ -1,7 +1,7 @@ { "require": { "php": "^7.2.5 || ^8.0", - "friendsofphp/php-cs-fixer": "2.18.3" + "friendsofphp/php-cs-fixer": "3.2.1" }, "config": { "preferred-install": "dist"