From 09c1026b82128d5596512585c11e3da6dbcdc58f Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 14:38:54 +0200 Subject: [PATCH 1/7] add phpcs workflow --- .github/workflows/phpcs.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/phpcs.yml diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..f13ce47 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,25 @@ +name: PHP CodeSniffer +on: + pull_request: + paths: + - "**.php" + - "phpcs.xml" + - ".github/workflows/phpcs.yml" + +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install PHP_CodeSniffer + run: | + curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar + php phpcs.phar --version + + - uses: tinovyatkin/action-php-codesniffer@v1 + with: + files: "**.php" + phpcs_path: php phpcs.phar + standard: phpcs.xml From 00f76b8cd99a7fbf43aa91d809991acc9fa5a8b7 Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 14:43:11 +0200 Subject: [PATCH 2/7] test run phpcs --- src/Test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Test.php diff --git a/src/Test.php b/src/Test.php new file mode 100644 index 0000000..6140018 --- /dev/null +++ b/src/Test.php @@ -0,0 +1,16 @@ + Date: Fri, 16 Apr 2021 14:45:14 +0200 Subject: [PATCH 3/7] add phpcs.xml --- phpcs.xml | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..c9dfc72 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,154 @@ + + + The coding standard for PHP_CodeSniffer itself. + + autoload.php + bin + scripts + src + tests + + */src/Standards/*/Tests/*\.(inc|css|js)$ + */tests/Core/*/*\.(inc|css|js)$ + + + + + + + + + error + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + error + + + + + error + + + + + tests/bootstrap\.php + + + + + tests/Core/Tokenizer/StableCommentWhitespaceWinTest\.php + + + From ce4360d1993d53ba30023119e1f370ef5eab4b16 Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 14:56:42 +0200 Subject: [PATCH 4/7] test --- .github/workflows/phpcs.yml | 17 +++++++---------- src/Test.php | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index f13ce47..25e27cd 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,4 +1,5 @@ name: PHP CodeSniffer + on: pull_request: paths: @@ -13,13 +14,9 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Install PHP_CodeSniffer - run: | - curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar - php phpcs.phar --version - - - uses: tinovyatkin/action-php-codesniffer@v1 - with: - files: "**.php" - phpcs_path: php phpcs.phar - standard: phpcs.xml + - name: Install PHP CodeSniffer + run: curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar + - name: Modified Files + run: git ls-files -om --exclude-standard + - name: Run PHPCS + run: php phpcs.phar ./phpcs.xml $(git ls-files -om --exclude-standard) diff --git a/src/Test.php b/src/Test.php index 6140018..eebcb08 100644 --- a/src/Test.php +++ b/src/Test.php @@ -9,6 +9,7 @@ public function _foo ($bar) { echo "a" . 1 ; + } } From 82b0d13cf0f5cee2b6839c6ee3eb1b61bbde1f7d Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 15:08:12 +0200 Subject: [PATCH 5/7] test --- src/Test.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Test.php b/src/Test.php index eebcb08..098d026 100644 --- a/src/Test.php +++ b/src/Test.php @@ -8,6 +8,14 @@ public function _foo ($bar) { + echo "a" . 1 ; + + } + + public function test ($bar) { + + + echo "a" . 1 ; } From 4f39dd9574d54e5da59a34b79c2ee870f4a17dde Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 15:11:17 +0200 Subject: [PATCH 6/7] test --- .github/workflows/phpcs.yml | 2 +- src/Test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 25e27cd..2a67c22 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 + fetch-depth: 2 - name: Install PHP CodeSniffer run: curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar - name: Modified Files diff --git a/src/Test.php b/src/Test.php index 098d026..2c69660 100644 --- a/src/Test.php +++ b/src/Test.php @@ -7,7 +7,7 @@ class Test { public function _foo ($bar) { - + echo "a" . 1 ; } From 9ebb29c59436fdb69dd2452ca8daacc0d8de918d Mon Sep 17 00:00:00 2001 From: Mohamed Zahran Date: Fri, 16 Apr 2021 15:16:30 +0200 Subject: [PATCH 7/7] test --- .github/workflows/phpcs.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 2a67c22..4d1176b 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,4 +1,4 @@ -name: PHP CodeSniffer +name: "CI" on: pull_request: @@ -13,10 +13,17 @@ jobs: steps: - uses: actions/checkout@v2 with: - fetch-depth: 2 - - name: Install PHP CodeSniffer - run: curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar - - name: Modified Files - run: git ls-files -om --exclude-standard - - name: Run PHPCS - run: php phpcs.phar ./phpcs.xml $(git ls-files -om --exclude-standard) + fetch-depth: 0 # important! + + # we may use whatever way to install phpcs, just specify the path on the next step + # however, curl seems to be the fastest + - name: Install PHP_CodeSniffer + run: | + curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar + php phpcs.phar --version + + - uses: tinovyatkin/action-php-codesniffer@v1 + with: + files: "**.php" # you may customize glob as needed + phpcs_path: php phpcs.phar + standard: phpcs.xml