Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPCS (+ fixer) and set coding style to PSR12 #181

Merged
merged 7 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*.md]
charset = utf-8
end_of_line = lf

[{*.neon, *.xml}]
indent_style = tab
indent_size = 4

[*.json]
indent_style = space
indent_size = 4

# PHP PSR-12 Coding Standards
# http://www.php-fig.org/psr/psr-12/
[*.php]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,30 @@ jobs:
run: |
vendor/bin/php-coveralls --coverage_clover="./clover.xml" --json_path="./coveralls-upload.json" -v

php-compatibility:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-req php

- name: Run PHP Code Sniffer using the PHPCompatibility standard
run: vendor/bin/phpcs

php-static-analysis:
runs-on: ubuntu-latest

Expand Down
107 changes: 58 additions & 49 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,59 @@
{
"name": "10up/wp_mock",
"description": "A mocking library to take the pain out of unit testing for WordPress",
"license": "GPL-2.0-or-later",
"version": "0.5.0",
"require": {
"php": ">=7.3 < 9.0",
"phpunit/phpunit": "^9.5.24",
"mockery/mockery": "^1.5",
"antecedent/patchwork": "^2.1"
},
"require-dev": {
"behat/behat": "^v3.11.0",
"sebastian/comparator": "^4.0.8",
"php-coveralls/php-coveralls": "^v2.5.3",
"sempro/phpunit-pretty-print": "^1.4",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-phpunit": "^1.2",
"phpstan/phpstan-mockery": "^1.1"
},
"autoload": {
"psr-4": {
"WP_Mock\\": "./php/WP_Mock"
},
"classmap": [
"php/WP_Mock.php"
]
},
"config": {
"platform": {
"php" : "7.3"
}
},
"autoload-dev" : {
"classmap": ["tests"]
},
"scripts": {
"test:behat": "behat",
"test:phpunit": "phpunit",
"test:phpunitcov": "phpunit --coverage-clover build/logs/clover.xml",
"test": [
"@test:behat",
"@test:phpunit"
],
"coverage": [
"@test:behat",
"@test:phpunitcov"
]
}
}
"name": "10up/wp_mock",
"description": "A mocking library to take the pain out of unit testing for WordPress",
"license": "GPL-2.0-or-later",
"version": "0.5.0",
"prefer-stable" : true,
"require": {
"php": ">=7.3 < 9.0",
"phpunit/phpunit": "^9.5.24",
"mockery/mockery": "^1.5",
"antecedent/patchwork": "^2.1"
},
"require-dev": {
"behat/behat": "^v3.11.0",
"sebastian/comparator": "^4.0.8",
"php-coveralls/php-coveralls": "^v2.5.3",
"sempro/phpunit-pretty-print": "^1.4",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-phpunit": "^1.2",
"phpstan/phpstan-mockery": "^1.1",
"phpcompatibility/php-compatibility": "^9.3",
"friendsofphp/php-cs-fixer": "^3.4",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2"
},
"autoload": {
"psr-4": {
"WP_Mock\\": "./php/WP_Mock"
},
"classmap": [
"php/WP_Mock.php"
]
},
"config": {
"platform": {
"php" : "7.3"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload-dev" : {
"classmap": ["tests"]
},
"scripts": {
"test:behat": "behat",
"test:phpunit": "phpunit",
"test:phpunitcov": "phpunit --coverage-clover build/logs/clover.xml",
"test": [
"@test:behat",
"@test:phpunit"
],
"coverage": [
"@test:behat",
"@test:phpunitcov"
],
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
}
}
Loading