Skip to content

Commit

Permalink
Add initial version of the GEWISPHP Coding Standards
Browse files Browse the repository at this point in the history
These are heavily based on the Doctrine and Slevomat Coding Standards.

Also includes a GitHub Action that can be re-used across projects.
  • Loading branch information
tomudding committed Apr 28, 2023
0 parents commit d687ca8
Show file tree
Hide file tree
Showing 9 changed files with 1,163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf

36 changes: 36 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PHP Coding Standards

on:
workflow_call:
inputs:
php-version:
description: 'The PHP version to use when running the job'
default: '8.2'
required: false
type: 'string'

jobs:
php-codesniffer:
name: PHP_CodeSniffer
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
tools: cs2pr

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2

- name: Run PHP_CS
run: vendor/bin/phpcs --no-colors --report=checkstyle -q | cs2pr --graceful-warnings
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
phpcs.log
phpcs.xml
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2013 Steve Müller
Copyright (c) 2023 Gemeenschap van Wiskunde en Informatica Studenten

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GEWISPHP Coding Standards

The GEWISPHP Coding Standard is a set of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules that are applied to all PHP projects of Study Association GEWIS. These standards are heavily based on the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard) and the [Slevomat Coding Standard](https://github.com/slevomat/coding-standard).
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "gewis/gewisphp-coding-standards",
"type": "phpcodesniffer-standard",
"description": "The GEWISPHP Coding Standard is a set of PHP_CS rules that are applied to PHP projects of Study Association GEWIS.",
"keywords": [
"gewis",
"coding",
"standard"
],
"homepage": "https://github.com/GEWIS/gewisphp-coding-standards",
"license": "MIT",
"require": {
"php": "^8.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"slevomat/coding-standard": "^8.11",
"squizlabs/php_codesniffer": "^3.7.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"GEWISPHPCodingStandards\\": "src/GEWISPHPCodingStandards/"
}
}
}
266 changes: 266 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset
name="PHP_CS Coding Standards for gewis/gewisphp-coding-standards"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<description>The PHP_CS standard for gewis/gewisphp-coding-standards itself.</description>

<arg name="basepath" value="." />
<arg name="colors" />
<arg name="error-severity" value="1" />
<arg name="extensions" value="php" />
<arg name="parallel" value="8" />
<arg name="warning-severity" value="1" />

<arg value="nps" />

<file>src</file>

<rule ref="GEWISPHPCodingStandards" />
</ruleset>
Loading

0 comments on commit d687ca8

Please sign in to comment.