-
Notifications
You must be signed in to change notification settings - Fork 20
64 lines (59 loc) · 1.82 KB
/
code-standards.yml
File metadata and controls
64 lines (59 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: PHP Code Standards
on:
workflow_call:
inputs:
version:
type: string
default: "^3.0"
config:
type: string
default: ""
path:
type: string
default: "."
rules:
type: string
default: |
{
"@PSR2": true,
"array_syntax": {"syntax":"short"},
"concat_space": {"spacing":"one"},
"new_with_parentheses": true,
"no_unused_imports": true,
"ordered_imports": true,
"return_type_declaration": {"space_before": "none"},
"single_quote": true,
"single_space_around_construct": true,
"cast_spaces": true,
"whitespace_after_comma_in_array": true,
"no_whitespace_in_blank_line": true,
"binary_operator_spaces": {"default": "at_least_single_space"},
"no_extra_blank_lines": true
}
add-rules:
type: string
default: "{}"
permissions:
contents: read
jobs:
php_code_standards:
runs-on: ubuntu-latest
name: PHP Code Standards
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v2
- name: Run PHP CS Fixer
run: |
composer global require friendsofphp/php-cs-fixer:${{ inputs.version }} -q
CONFIG="${{ inputs.config }}"
RULES=$(echo $'${{ inputs.rules }} ${{ inputs.add-rules }}'|tr -d '\n\t\r '|jq -s '.[0] * .[1]' -crM)
set -x
~/.composer/vendor/bin/php-cs-fixer fix \
${{ inputs.path }} \
$(if [ ! -z "$CONFIG" ]; then echo "--config=$CONFIG"; else echo --rules=$RULES; fi) \
--dry-run --diff