From 2c0159de95eef568bdfa359619938a8059d2f568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Sun, 20 Sep 2026 16:23:02 +0400 Subject: [PATCH 1/3] Check the code style fully on CI --- .github/workflows/php-cs-fixer.yml | 29 +++++++++++++++++++++ .github/workflows/{linter.yml => phpcs.yml} | 2 +- .gitignore | 4 +++ .php-cs-fixer.dist.php | 29 +++++++++++++++++++++ composer.json | 11 +++++--- phpcs.xml.dist | 23 ++++++++++++++++ src/CurlFormatter.php | 1 - src/Message.php | 2 -- tests/ClientTest.php | 6 +++++ tests/CurlFormatterTest.php | 6 +++++ tests/CurlTransportTest.php | 6 +++++ tests/JsonFormatterTest.php | 6 +++++ tests/JsonParserTest.php | 6 +++++ tests/MessageTest.php | 6 +++++ tests/MockTransportTest.php | 7 ++++- tests/RequestTest.php | 6 +++++ tests/ResponseTest.php | 6 +++++ tests/StreamTransportTest.php | 6 +++++ tests/TestCase.php | 6 +++++ tests/TransportTestCase.php | 6 +++++ tests/UrlEncodedFormatterTest.php | 6 +++++ tests/UrlEncodedParserTest.php | 6 +++++ tests/XmlFormatterTest.php | 6 +++++ tests/XmlParserTest.php | 6 +++++ tests/bootstrap.php | 7 +++++ 25 files changed, 196 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/php-cs-fixer.yml rename .github/workflows/{linter.yml => phpcs.yml} (97%) create mode 100644 .php-cs-fixer.dist.php diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..786cb9b --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,29 @@ +name: php-cs-fixer + +permissions: + contents: read + +on: + pull_request: &ignore-paths + paths-ignore: + - 'docs/**' + - '.github/CONTRIBUTING.md' + - '.github/FUNDING.yml' + - '.github/SECURITY.md' + - 'README.md' + - 'CHANGELOG.md' + - 'LICENSE.md' + - '.gitignore' + - '.gitattributes' + - '.editorconfig' + - 'docker-compose.yml' + - 'Makefile' + + push: *ignore-paths + +jobs: + php-cs-fixer: + uses: yiisoft/yii2-actions/.github/workflows/php-cs-fixer.yml@9bfbe47bd91bc31a6ff9f0ea77ba3724d7816c3d # master + with: + configuration: .php-cs-fixer.dist.php + php-version: '["7.4"]' diff --git a/.github/workflows/linter.yml b/.github/workflows/phpcs.yml similarity index 97% rename from .github/workflows/linter.yml rename to .github/workflows/phpcs.yml index 1c53325..1eb83e9 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/phpcs.yml @@ -1,4 +1,4 @@ -name: linter +name: phpcs permissions: contents: read diff --git a/.gitignore b/.gitignore index 4c3b916..674dac2 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ phpunit.phar # local tests configuration /tests/data/config.local.php /tests/runtime + +# PHP CS Fixer +.php-cs-fixer.php +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..07efa2a --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,29 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->notPath([ + '#(^|/)views/#', + ]); + +return (new Config()) + ->setFinder($finder) + ->setRules([ + 'no_unused_imports' => true, + 'phpdoc_scalar' => true, + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => $header, + 'location' => 'after_open', + ], + ]); diff --git a/composer.json b/composer.json index a0ea612..7cab0bf 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,9 @@ "yiisoft/yii2-debug": "^2.1", "yiisoft/yii2-coding-standards": "^3.0", "rector/rector": "^2.6", - "mspirkov/yii2-rector": "^0.1" + "mspirkov/yii2-rector": "^0.1", + "slevomat/coding-standard": "^8.31", + "friendsofphp/php-cs-fixer": "^3.95" }, "repositories": [ { @@ -39,7 +41,8 @@ ], "config": { "allow-plugins": { - "yiisoft/yii2-composer": true + "yiisoft/yii2-composer": true, + "dealerdirect/phpcodesniffer-composer-installer": true } }, "autoload": { @@ -53,8 +56,8 @@ } }, "scripts": { - "cs": "./vendor/bin/phpcs", - "cs-fix": "./vendor/bin/phpcbf", + "cs": "./vendor/bin/phpcs && ./vendor/bin/php-cs-fixer check", + "cs-fix": "./vendor/bin/phpcbf && ./vendor/bin/php-cs-fixer fix", "static": "./vendor/bin/phpstan --memory-limit=-1", "tests": "./vendor/bin/phpunit", "rector": "./vendor/bin/rector" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 6530e7b..9f49576 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,6 +2,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CurlFormatter.php b/src/CurlFormatter.php index 4ced136..994a586 100644 --- a/src/CurlFormatter.php +++ b/src/CurlFormatter.php @@ -8,7 +8,6 @@ namespace yii\httpclient; -use Yii; use yii\base\BaseObject; /** diff --git a/src/Message.php b/src/Message.php index 8175cf1..2e598a9 100644 --- a/src/Message.php +++ b/src/Message.php @@ -13,7 +13,6 @@ use yii\web\Cookie; use yii\web\CookieCollection; use yii\web\HeaderCollection; -use Yii; /** * Message represents a base HTTP message. @@ -246,7 +245,6 @@ public function hasContent($key) } - /** * Sets the data fields, which composes message content. * @param mixed $data content data fields. diff --git a/tests/ClientTest.php b/tests/ClientTest.php index ad8e8eb..186b1a3 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -1,5 +1,11 @@ Date: Thu, 24 Sep 2026 17:54:30 +0400 Subject: [PATCH 2/3] Remove PHP_Consniffer and add PSR2 ruleset --- .github/workflows/phpcs.yml | 26 ---------------------- .php-cs-fixer.dist.php | 1 + composer.json | 9 +++----- phpcs.xml.dist | 43 ------------------------------------- tests/JsonParserTest.php | 3 ++- 5 files changed, 6 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/phpcs.yml delete mode 100644 phpcs.xml.dist diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml deleted file mode 100644 index 1eb83e9..0000000 --- a/.github/workflows/phpcs.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: phpcs - -permissions: - contents: read - -on: - pull_request: &ignore-paths - paths-ignore: - - 'docs/**' - - '.github/CONTRIBUTING.md' - - '.github/FUNDING.yml' - - '.github/SECURITY.md' - - 'README.md' - - 'CHANGELOG.md' - - 'LICENSE.md' - - '.gitignore' - - '.gitattributes' - - '.editorconfig' - - 'docker-compose.yml' - - 'Makefile' - - push: *ignore-paths - -jobs: - phpcs: - uses: yiisoft/yii2-actions/.github/workflows/linter.yml@master diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 07efa2a..67d9f35 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -19,6 +19,7 @@ return (new Config()) ->setFinder($finder) ->setRules([ + '@PSR2' => true, 'no_unused_imports' => true, 'phpdoc_scalar' => true, 'header_comment' => [ diff --git a/composer.json b/composer.json index 7cab0bf..a8bd0c2 100644 --- a/composer.json +++ b/composer.json @@ -27,10 +27,8 @@ "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", "yiisoft/yii2-debug": "^2.1", - "yiisoft/yii2-coding-standards": "^3.0", "rector/rector": "^2.6", "mspirkov/yii2-rector": "^0.1", - "slevomat/coding-standard": "^8.31", "friendsofphp/php-cs-fixer": "^3.95" }, "repositories": [ @@ -41,8 +39,7 @@ ], "config": { "allow-plugins": { - "yiisoft/yii2-composer": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "yiisoft/yii2-composer": true } }, "autoload": { @@ -56,8 +53,8 @@ } }, "scripts": { - "cs": "./vendor/bin/phpcs && ./vendor/bin/php-cs-fixer check", - "cs-fix": "./vendor/bin/phpcbf && ./vendor/bin/php-cs-fixer fix", + "cs": "./vendor/bin/php-cs-fixer check", + "cs-fix": "./vendor/bin/php-cs-fixer fix", "static": "./vendor/bin/phpstan --memory-limit=-1", "tests": "./vendor/bin/phpunit", "rector": "./vendor/bin/rector" diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index 9f49576..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src - tests - - - /Request\.php$ - /MockTransport\.php$ - /tests/MockTransportTest\.php$ - - - /tests/XmlFormatterTest\.php$ - - diff --git a/tests/JsonParserTest.php b/tests/JsonParserTest.php index cc9657c..7e06c77 100644 --- a/tests/JsonParserTest.php +++ b/tests/JsonParserTest.php @@ -59,7 +59,8 @@ public function testParse2(): void ], 'errors' => null, ]; - $document->setContent(<<setContent( + << Date: Thu, 24 Sep 2026 18:08:25 +0400 Subject: [PATCH 3/3] Update the workflow name for code style check --- .github/workflows/{php-cs-fixer.yml => code-style.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{php-cs-fixer.yml => code-style.yml} (97%) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/code-style.yml similarity index 97% rename from .github/workflows/php-cs-fixer.yml rename to .github/workflows/code-style.yml index 786cb9b..dfb84ca 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/code-style.yml @@ -1,4 +1,4 @@ -name: php-cs-fixer +name: code style permissions: contents: read