From 16e2b614f1ac0eaaa5f4dbb8b0add24467249332 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 27 Nov 2024 04:24:49 +0545 Subject: [PATCH] Add linter for sniffs (#790) --- .github/workflows/php-lint.yml | 29 +++++++++++++++++++ .../Sniffs/CodeAnalysis/LocalhostSniff.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php-lint.yml b/.github/workflows/php-lint.yml index 924378b15..4087b95cd 100644 --- a/.github/workflows/php-lint.yml +++ b/.github/workflows/php-lint.yml @@ -61,3 +61,32 @@ jobs: - name: PHPMD run: composer phpmd + + php-lint-sniffs: + name: PHP (Sniffs) + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + + - name: Validate Composer configuration + working-directory: "phpcs-sniffs" + run: composer validate + + - name: Install PHP dependencies + uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a + with: + composer-options: '--prefer-dist' + working-directory: "phpcs-sniffs" + + - name: PHP Lint + working-directory: "phpcs-sniffs" + run: composer lint + + - name: PHP Lint PHPCS + working-directory: "phpcs-sniffs" + run: composer check-cs diff --git a/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/LocalhostSniff.php b/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/LocalhostSniff.php index fb28251f9..63d54d11f 100644 --- a/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/LocalhostSniff.php +++ b/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/LocalhostSniff.php @@ -55,7 +55,7 @@ public function process_token( $stackPtr ) { 'Do not use Localhost/127.0.0.1 in your code. Found: %s', $this->find_token_in_multiline_string( $stackPtr, $content, $match[1] ), 'Found', - [ $match[0] ] + array( $match[0] ) ); } }