From e7559b62651cfe08baa08149ebc1be6267b4ec3b Mon Sep 17 00:00:00 2001 From: Steve Grunwell <233836+stevegrunwell@users.noreply.github.com> Date: Sun, 3 Dec 2023 17:02:26 -0500 Subject: [PATCH] Add PHP_CodeSniffer for checking coding standards --- .github/workflows/coding-standards.yml | 23 +++++++++++++++++++++++ .phpcs.xml.dist | 24 ++++++++++++++++++++++++ composer.json | 12 +++++++++++- src/MarkupAssertionsTrait.php | 1 + tests/MarkupAssertionsTraitTest.php | 3 ++- 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .phpcs.xml.dist diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..68d77bc --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,23 @@ +name: Coding Standards + +on: [pull_request] + +jobs: + phpcs: + name: PHP_CodeSniffer + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 + + - name: Run test suite + run: composer coding-standards diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist new file mode 100644 index 0000000..57b3de6 --- /dev/null +++ b/.phpcs.xml.dist @@ -0,0 +1,24 @@ + + + Coding standards for PHPUnit Markup Assertions + + + + + + + . + */vendor/* + + + + + + + tests/* + + + + + + diff --git a/composer.json b/composer.json index c704177..5ce1209 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,9 @@ "symfony/dom-crawler": "^3.4|^4.4|^5.4|^6.0" }, "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "phpcompatibility/php-compatibility": "^9.3", + "phpcsstandards/php_codesniffer": "^3.7", "symfony/phpunit-bridge": "^5.2 || ^6.2" }, "autoload": { @@ -33,6 +36,9 @@ } }, "scripts": { + "coding-standards": [ + "phpcs" + ], "test": [ "simple-phpunit --testdox" ], @@ -41,12 +47,16 @@ ] }, "scripts-descriptions": { + "coding-standards": "Check coding standards.", "test": "Run all test suites.", "test-coverage": "Generate code coverage reports in tests/coverage." }, "config": { "preferred-install": "dist", - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "archive": { "exclude": [ diff --git a/src/MarkupAssertionsTrait.php b/src/MarkupAssertionsTrait.php index 14b4906..59bb6fa 100644 --- a/src/MarkupAssertionsTrait.php +++ b/src/MarkupAssertionsTrait.php @@ -1,4 +1,5 @@ setAccessible(true);