From c6b687ff6bfed41bb134f0ac68e738014e858920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Dobe=C5=A1?= Date: Mon, 9 Jun 2025 09:42:10 +0200 Subject: [PATCH 1/2] Make COMPOSER_NO_INTERACTION global in checks.yml --- .github/workflows/checks.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5341bc9..e40df5f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -3,15 +3,15 @@ name: checks on: - push +env: + COMPOSER_NO_INTERACTION: "1" + jobs: static_analysis: name: Static analysis runs-on: ubuntu-latest - env: - COMPOSER_NO_INTERACTION: "1" - steps: - uses: actions/checkout@v4 @@ -50,9 +50,6 @@ jobs: runs-on: ${{ matrix.os }} - env: - COMPOSER_NO_INTERACTION: "1" - steps: - uses: actions/checkout@v4 From 3130b67bb3c26e04d545f540a8dd0c8abc74e41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Dobe=C5=A1?= Date: Mon, 9 Jun 2025 09:42:56 +0200 Subject: [PATCH 2/2] Enforce code style --- .github/workflows/checks.yml | 18 ++ composer.json | 5 + composer.lock | 311 +++++++++++++++++++++++- phpcs.xml.dist | 9 + src/GraphQL/NetteDIContainerAdapter.php | 2 +- tests/CorrespondanceRuleTest.php | 2 +- 6 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e40df5f..b2ff8fc 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,6 +7,24 @@ env: COMPOSER_NO_INTERACTION: "1" jobs: + format: + name: Code style + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + coverage: none + + - run: composer install --ansi --no-progress --prefer-dist + + - name: Run PHP_Codesniffer + run: vendor/bin/phpcs + static_analysis: name: Static analysis diff --git a/composer.json b/composer.json index 14a61c5..89008a7 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,9 @@ } }, "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": false + }, "sort-packages": true }, "keywords": [ @@ -45,11 +48,13 @@ "phpunit/phpunit": "^12.1", "spaze/phpstan-disallowed-calls": "^4.5.0", "tracy/tracy": "^2.10.9", + "vojtech-dobes/php-codestyle": "~0.2.0", "vojtech-dobes/php-grammar-processing": "dev-master@dev", "vojtech-dobes/php-graphql-server": "dev-master@dev", "vojtech-dobes/phpstan-php-graphql-server": "dev-master@dev" }, "scripts": { + "fmt": "phpcbf", "lint": "parallel-lint src tests", "phpstan": "phpstan analyse --memory-limit 256M", "test": "composer dump-autoload && phpunit tests" diff --git a/composer.lock b/composer.lock index c2c5a84..f8a7f36 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d851f8354a344d4aa37ed2135b60c6f7", + "content-hash": "90c96b751792707477a1ef160fa688eb", "packages": [ { "name": "vojtech-dobes/php-graphql-server-nette-integration", @@ -64,6 +64,84 @@ } ], "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "time": "2023-01-05T11:28:13+00:00" + }, { "name": "guzzlehttp/promises", "version": "2.2.0", @@ -949,6 +1027,53 @@ }, "time": "2024-03-27T12:14:49+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.1.0" + }, + "time": "2025-02-19T13:28:12+00:00" + }, { "name": "phpstan/phpstan", "version": "2.1.17", @@ -2319,6 +2444,71 @@ ], "time": "2025-02-07T05:00:38+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "8.19.0", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "9cc50509c3912d465a9f6898069f64cf2abf4e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/9cc50509c3912d465a9f6898069f64cf2abf4e8a", + "reference": "9cc50509c3912d465a9f6898069f64cf2abf4e8a", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", + "php": "^7.4 || ^8.0", + "phpstan/phpdoc-parser": "^2.1.0", + "squizlabs/php_codesniffer": "^3.13.0" + }, + "require-dev": { + "phing/phing": "3.0.1", + "php-parallel-lint/php-parallel-lint": "1.4.0", + "phpstan/phpstan": "2.1.17", + "phpstan/phpstan-deprecation-rules": "2.0.3", + "phpstan/phpstan-phpunit": "2.0.6", + "phpstan/phpstan-strict-rules": "2.0.4", + "phpunit/phpunit": "9.6.8|10.5.45|11.4.4|11.5.21|12.1.3" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "8.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/8.19.0" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2025-06-07T15:02:20+00:00" + }, { "name": "spaze/phpstan-disallowed-calls", "version": "v4.5.0", @@ -2386,6 +2576,90 @@ ], "time": "2025-04-10T19:01:43+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.13.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "65ff2489553b83b4597e89c3b8b721487011d186" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/65ff2489553b83b4597e89c3b8b721487011d186", + "reference": "65ff2489553b83b4597e89c3b8b721487011d186", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-05-11T03:36:00+00:00" + }, { "name": "staabm/side-effects-detector", "version": "1.0.5", @@ -2563,6 +2837,41 @@ }, "time": "2025-04-28T14:35:15+00:00" }, + { + "name": "vojtech-dobes/php-codestyle", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/vojtech-dobes/php-codestyle.git", + "reference": "d59431f2d4cc36987b9eefba40b6bd8fddd4a440" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vojtech-dobes/php-codestyle/zipball/d59431f2d4cc36987b9eefba40b6bd8fddd4a440", + "reference": "d59431f2d4cc36987b9eefba40b6bd8fddd4a440", + "shasum": "" + }, + "require": { + "slevomat/coding-standard": "~8.19.0" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "code-style", + "codesniffer", + "coding-standard", + "dev", + "phpcs" + ], + "support": { + "issues": "https://github.com/vojtech-dobes/php-codestyle/issues", + "source": "https://github.com/vojtech-dobes/php-codestyle/tree/0.2.0" + }, + "time": "2025-06-09T07:30:13+00:00" + }, { "name": "vojtech-dobes/php-grammar-processing", "version": "dev-master", diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..98cb514 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,9 @@ + + + + + src + tests + + + diff --git a/src/GraphQL/NetteDIContainerAdapter.php b/src/GraphQL/NetteDIContainerAdapter.php index 70fe43d..df05309 100644 --- a/src/GraphQL/NetteDIContainerAdapter.php +++ b/src/GraphQL/NetteDIContainerAdapter.php @@ -29,7 +29,7 @@ public function __construct( $this->extensionMap = array_combine( array_map( static fn ($key) => realpath($key), - array_keys($extensionMap) + array_keys($extensionMap), ), $extensionMap, ); diff --git a/tests/CorrespondanceRuleTest.php b/tests/CorrespondanceRuleTest.php index 9dbfa90..6fe0e03 100644 --- a/tests/CorrespondanceRuleTest.php +++ b/tests/CorrespondanceRuleTest.php @@ -1,4 +1,4 @@ -