build: Added GitHub Actions workflow to run phpcs.

This commit is contained in:
Koji Tanaka 2022-12-29 12:50:41 +09:00 committed by Kamil Wylegala
parent 30826e5902
commit aac44b074b
3 changed files with 75 additions and 1 deletions

54
.github/workflows/phpcs.yml vendored Normal file
View file

@ -0,0 +1,54 @@
name: PHP Coding Standard
on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'
permissions:
contents: read
jobs:
phpcs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- '7.4'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
tools: composer
- name: Composer get cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-composer-
- name: Install Composer Packages
run: composer install --no-ansi --no-interaction --no-progress --ignore-platform-req=php
- name: Install CodeSniffer Rule
run: vendors/bin/phpcs --config-set installed_paths vendors/cakephp/cakephp-codesniffer
- name: Check CodeSniffer
run: vendors/bin/phpcs -p --extensions=php --standard=ruleset.xml ./lib/Cake

View file

@ -32,7 +32,6 @@ class MailTransport extends AbstractTransport {
* @throws SocketException When mail cannot be sent.
*/
public function send(CakeEmail $email) {
// https://github.com/cakephp/cakephp/issues/2209
// https://bugs.php.net/bug.php?id=47983
$eol = "\r\n";

21
ruleset.xml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<ruleset name="CakePHP2PHP8">
<!-- Include CakePHP 2 Coding standard rules -->
<rule ref="CakePHP" />
<!-- Defined public method with underscore: __tostring(). -->
<rule ref="CakePHP.NamingConventions.ValidFunctionName.PublicWithUnderscore">
<exclude-pattern>lib/Cake/Network/Http/HttpSocketResponse.php</exclude-pattern>
</rule>
<rule ref="Generic.PHP.DeprecatedFunctions.Deprecated">
<!-- Using the deprecated get_magic_quotes_gpc function. -->
<exclude-pattern>lib/Cake/View/Helper.php</exclude-pattern>
<!-- Using the deprecated mcrypt_* functions. -->
<exclude-pattern>lib/Cake/Utility/Security.php</exclude-pattern>
</rule>
<rule ref="CakePHP.Commenting.FunctionComment.Missing">
<exclude-pattern>lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php</exclude-pattern>
</rule>
</ruleset>