From 00b48d4a527bc604305b59ff8dc1e26ddb6b5cc3 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:13:28 +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/Module.php | 1 - src/Panel.php | 1 - src/models/UserSwitch.php | 1 - src/panels/DbPanel.php | 1 - tests/FlattenExceptionTest.php | 6 ++++ tests/LogTargetTest.php | 6 ++++ tests/ModuleTest.php | 6 ++++ tests/PanelTest.php | 6 ++++ tests/TestCase.php | 6 ++++ tests/bootstrap.php | 7 +++++ tests/router/ActionRoutesTest.php | 6 ++++ tests/router/CurrentRouteTest.php | 6 ++++ tests/router/CustomRuleStub.php | 6 ++++ tests/router/RouterRulesTest.php | 6 ++++ tests/router/controllers/BadController.php | 6 ++++ .../router/controllers/RedirectController.php | 6 ++++ tests/router/controllers/RestController.php | 6 ++++ tests/router/controllers/WebController.php | 6 ++++ tests/router/module/Module.php | 6 ++++ .../controllers/ModuleWebController.php | 6 ++++ 26 files changed, 190 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 000000000..786cb9bb1 --- /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 1c5332551..1eb83e9e9 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 bcc42bb33..4ea33013e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ coverage.xml # 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 000000000..07efa2aa7 --- /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 14e18dedb..8db1467f6 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,9 @@ "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.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" }, "autoload": { "psr-4": { @@ -64,12 +66,13 @@ ], "config": { "allow-plugins": { - "yiisoft/yii2-composer": true + "yiisoft/yii2-composer": true, + "dealerdirect/phpcodesniffer-composer-installer": true } }, "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 3da0add8f..c479d41cf 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,6 +2,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Module.php b/src/Module.php index face0a591..80b17cb79 100644 --- a/src/Module.php +++ b/src/Module.php @@ -201,7 +201,6 @@ class Module extends \yii\base\Module implements BootstrapInterface */ private static $_yiiLogo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAC7lBMVEUAAACl034Cb7HlcjGRyT/H34fyy5PxqlSfzjwQeb5PmtX71HAMdrWOxkDzmU3qcDSPx0HzhUGNxT+/2lX2olDmUy/Q1l+TyD7rgjq21k3ZRzDQ4GGFw0Ghzz6MwOkKdrTA2lTzzMVjo9mhzkCIxUPk1MLynU7qWS33vmbP1rm011Fwqsj123/r44tUltTyq1aCxEOo0EL1tFuCw0Npp9v7xGVHkM8Ddrza0pvC3FboczHmXSvE21h+wkRkpNHvjkS92FPW3avpeDT2t1zX5GefzUD6wGQReLtMltPN417oczPZ0L+62FF+tuJgqtXZUzNzrN3s4Y7n65y72FLwmk7xjESr0kYof8MQe8DY5Gc6jMnN32DoaDLbTiLulUo1hsni45vuwnIigMXC21dqq8vKzaaBt+XU4mUMd7wDdr7xlUrU4a7A2VTD0LbVx5vvpFP/0m9godp/tuTD0LVyr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o+7OYEdFpqLGcqqbMuDVaZGpqc/1OjycYerKohtpkZFl9ECG4qoihxvA9aN3ZDlXL5GDXR7Vr56BZtlYcAOwnQMdHXRPlmdd2U5kh5gffRHL0GSUXR5gKBeJ0tIiZ1UmLKlqlydygHD1s8EyYYe8PBFMjulVhbClEdy6kohLVTaJGEYW4eBr6MhsY1fi0ggoe7a3a7d84O6J5L8iNOiX3U+uoa/p8UPtoQAAAABJRU5ErkJggg=='; - /** * @var array routes of AJAX requests to skip from being displayed in toolbar * @since 2.1.14 diff --git a/src/Panel.php b/src/Panel.php index d5e2ecfe1..e95ff24c6 100644 --- a/src/Panel.php +++ b/src/Panel.php @@ -8,7 +8,6 @@ namespace yii\debug; -use Yii; use yii\base\Component; use yii\helpers\ArrayHelper; use yii\helpers\Url; diff --git a/src/models/UserSwitch.php b/src/models/UserSwitch.php index ec4cb7101..c7685676a 100644 --- a/src/models/UserSwitch.php +++ b/src/models/UserSwitch.php @@ -35,7 +35,6 @@ class UserSwitch extends Model */ private $_mainUser; - /** * @var string|User ID of the user component or a user object * @since 2.0.13 diff --git a/src/panels/DbPanel.php b/src/panels/DbPanel.php index 3b4e5d70b..6be374099 100644 --- a/src/panels/DbPanel.php +++ b/src/panels/DbPanel.php @@ -85,7 +85,6 @@ class DbPanel extends Panel */ private $_profileLogs; - /** * @var array of event names used to get profile logs. * @since 2.1.17 diff --git a/tests/FlattenExceptionTest.php b/tests/FlattenExceptionTest.php index 23afd0eab..36f4ae77a 100644 --- a/tests/FlattenExceptionTest.php +++ b/tests/FlattenExceptionTest.php @@ -1,5 +1,11 @@ Date: Thu, 24 Sep 2026 17:53:55 +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 | 41 ------------------------------------- src/Module.php | 32 ++++++++++++++--------------- 5 files changed, 20 insertions(+), 89 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 1eb83e9e9..000000000 --- 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 07efa2aa7..67d9f3534 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 8db1467f6..e3262a5d2 100644 --- a/composer.json +++ b/composer.json @@ -34,13 +34,11 @@ }, "require-dev": { "yiisoft/yii2-swiftmailer": "*", - "yiisoft/yii2-coding-standards": "~3.0", "phpunit/phpunit": "^9.6", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", "rector/rector": "^2.6", "mspirkov/yii2-rector": "^0.1", - "slevomat/coding-standard": "^8.31", "friendsofphp/php-cs-fixer": "^3.95" }, "autoload": { @@ -66,13 +64,12 @@ ], "config": { "allow-plugins": { - "yiisoft/yii2-composer": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "yiisoft/yii2-composer": true } }, "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 c479d41cf..000000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src - tests - - - /*\.php$ - - - /tests/PanelTest\.php$ - - diff --git a/src/Module.php b/src/Module.php index 80b17cb79..fdfb39168 100644 --- a/src/Module.php +++ b/src/Module.php @@ -179,22 +179,22 @@ class Module extends \yii\base\Module implements BootstrapInterface * @since 2.1.1 */ public $urlRuleClass = 'yii\web\UrlRule'; - /** - * @var string|callable Page title could be a string or a callable function - * - * ```php - * ... - * 'pageTitle' => 'Custom Debug Title', - * ... - * // OR - * 'pageTitle' => function($url) { - * $domain = getDomain($url); - * return $domain . ' debugger'; - * } - * ``` - * - * @since 2.1.1 - */ + /** + * @var string|callable Page title could be a string or a callable function + * + * ```php + * ... + * 'pageTitle' => 'Custom Debug Title', + * ... + * // OR + * 'pageTitle' => function($url) { + * $domain = getDomain($url); + * return $domain . ' debugger'; + * } + * ``` + * + * @since 2.1.1 + */ public $pageTitle; /** * @var string Yii logo URL From 090e3a99189c3992fe0c74ed72b077bc95a43a7d 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: Thu, 24 Sep 2026 18:08:11 +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 786cb9bb1..dfb84ca80 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