Skip to content

Commit eceaecd

Browse files
committed
chore: make CSRF protection explicit and add project checks
1 parent c20a110 commit eceaecd

55 files changed

Lines changed: 716 additions & 162 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "composer"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
ignore:
8+
- dependency-name: "*"
9+
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Coding Standards
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
pull_request:
8+
paths-ignore:
9+
- '**.md'
10+
workflow_dispatch:
11+
inputs:
12+
php_version:
13+
default: '8.4'
14+
15+
jobs:
16+
coding-standards:
17+
name: Coding Standards
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ inputs.php_version || '8.4' }}
27+
tools: cs2pr
28+
coverage: none
29+
30+
- name: Get composer cache directory
31+
id: composer-cache
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
34+
- name: Cache dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: ${{ steps.composer-cache.outputs.dir }}
38+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
39+
restore-keys: ${{ runner.os }}-composer-
40+
41+
- name: Install dependencies
42+
run: composer install --no-interaction --prefer-dist
43+
44+
- name: Run PHP_CodeSniffer
45+
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle --standard=./phpcs.xml src | cs2pr
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
pull_request:
8+
paths-ignore:
9+
- '**.md'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
operating-system:
20+
- ubuntu-latest
21+
php-version:
22+
- '8.0'
23+
- '8.1'
24+
- '8.2'
25+
- '8.3'
26+
- '8.4'
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup PHP ${{ matrix.php-version }}
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php-version }}
35+
coverage: none
36+
tools: none
37+
ini-values: assert.exception=1, zend.assertions=1
38+
39+
- name: Get composer cache directory
40+
id: composer-cache
41+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
42+
43+
- name: Cache dependencies
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ steps.composer-cache.outputs.dir }}
47+
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-php${{ matrix.php-version }}-composer-
50+
${{ runner.os }}-composer-
51+
52+
- name: Install dependencies
53+
run: composer update --no-interaction --no-progress --prefer-dist
54+
55+
- name: Run test suite
56+
run: ./vendor/bin/phpunit
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
pull_request:
8+
paths-ignore:
9+
- '**.md'
10+
workflow_dispatch:
11+
inputs:
12+
php_version:
13+
default: '8.4'
14+
15+
jobs:
16+
static-analysis-phpstan:
17+
name: PHPStan
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ inputs.php_version }}
29+
tools: cs2pr
30+
coverage: none
31+
32+
- name: Get composer cache directory
33+
id: composer-cache
34+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ steps.composer-cache.outputs.dir }}
40+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
41+
restore-keys: ${{ runner.os }}-composer-
42+
43+
- name: Install dependencies
44+
run: composer install --no-interaction --no-progress --prefer-dist
45+
46+
- name: Run PHPStan
47+
run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction --error-format=checkstyle | cs2pr
48+
49+
static-analysis-psalm:
50+
name: Psalm
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 0
57+
58+
- name: Setup PHP
59+
uses: shivammathur/setup-php@v2
60+
with:
61+
php-version: ${{ inputs.php_version }}
62+
tools: cs2pr
63+
coverage: none
64+
65+
- name: Get composer cache directory
66+
id: composer-cache
67+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
68+
69+
- name: Install dependencies
70+
run: composer install --no-interaction --no-progress --prefer-dist
71+
72+
- name: Run Psalm
73+
run: ./vendor/bin/psalm --show-info=false --output-format=checkstyle --shepherd | cs2pr
74+
75+
static-analysis-phpmd:
76+
name: PHPMD
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
with:
82+
fetch-depth: 0
83+
84+
- name: Setup PHP
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: ${{ inputs.php_version }}
88+
89+
- name: Get composer cache directory
90+
id: composer-cache
91+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
92+
93+
- name: Cache dependencies
94+
uses: actions/cache@v4
95+
with:
96+
path: ${{ steps.composer-cache.outputs.dir }}
97+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
98+
restore-keys: ${{ runner.os }}-composer-
99+
100+
- name: Install dependencies
101+
run: composer install --no-interaction --no-progress --prefer-dist
102+
103+
- name: Run PHP Mess Detector
104+
run: ./vendor/bin/phpmd src text ./phpmd.xml
105+
106+
static-analysis-composer-require-checker:
107+
name: ComposerRequireChecker
108+
runs-on: ubuntu-latest
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v4
112+
with:
113+
fetch-depth: 0
114+
115+
- name: Setup PHP
116+
uses: shivammathur/setup-php@v2
117+
with:
118+
php-version: ${{ inputs.php_version }}
119+
coverage: none
120+
121+
- name: Get composer cache directory
122+
id: composer-cache
123+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
124+
125+
- name: Install dependencies
126+
run: |
127+
composer install --no-interaction --no-progress --prefer-dist
128+
129+
- name: Run composer-require-checker with config
130+
run: ./vendor/bin/composer-require-checker check ./composer.json --config-file=./composer-require-checker.json

.php_cs renamed to .php-cs-fixer.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
@license http://opensource.org/licenses/MIT MIT
77
EOF;
88

9-
return \PhpCsFixer\Config::create()
9+
return (new \PhpCsFixer\Config())
1010
->setRiskyAllowed(true)
1111
->setRules(array(
1212
'@PSR2' => true,
13-
'header_comment' => ['header' => $header, 'commentType' => 'PHPDoc', 'separate' => 'none'],
13+
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc', 'separate' => 'none'],
1414
'array_syntax' => ['syntax' => 'short'],
15-
'binary_operator_spaces' => ['align_equals' => false, 'align_double_arrow' => false],
15+
'binary_operator_spaces' => ['default' => 'single_space'],
1616
'blank_line_after_opening_tag' => true,
1717
'blank_line_after_namespace' => false,
18-
'blank_line_before_return' => true,
18+
'blank_line_before_statement' => ['statements' => ['return']],
1919
'cast_spaces' => true,
2020
// 'class_keyword_remove' => true,
2121
'combine_consecutive_unsets' => true,
@@ -24,41 +24,40 @@
2424
'declare_strict_types' => false,
2525
'dir_constant' => true,
2626
'ereg_to_preg' => true,
27-
'function_typehint_space' => true,
27+
'type_declaration_spaces' => true,
2828
'general_phpdoc_annotation_remove' => true,
29-
'hash_to_slash_comment' => true,
29+
'single_line_comment_style' => ['comment_types' => ['hash']],
3030
'heredoc_to_nowdoc' => true,
3131
'include' => true,
3232
'indentation_type' => true,
33-
'is_null' => ['use_yoda_style' => false],
33+
'is_null' => true,
3434
'linebreak_after_opening_tag' => true,
3535
'lowercase_cast' => true,
3636
// 'mb_str_functions' => true,
37-
'method_separation' => true,
37+
'class_attributes_separation' => ['elements' => ['method' => 'one', 'trait_import' => 'none']],
3838
'modernize_types_casting' => true,
3939
'native_function_casing' => true,
4040
// 'native_function_invocation' => true,
41-
'new_with_braces' => false, //
41+
'new_with_parentheses' => false, //
4242
'no_alias_functions' => true,
4343
'no_blank_lines_after_class_opening' => true,
4444
'no_blank_lines_after_phpdoc' => true,
45-
'no_blank_lines_before_namespace' => true,
45+
'blank_lines_before_namespace' => ['min_line_breaks' => 1, 'max_line_breaks' => 1],
4646
'no_empty_comment' => true,
4747
'no_empty_phpdoc' => true,
4848
'no_empty_statement' => true,
49-
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use', 'useTrait'],
49+
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use']],
5050
'no_leading_import_slash' => true,
5151
'no_leading_namespace_whitespace' => true,
5252
'no_mixed_echo_print' => ['use' => 'echo'],
5353
'no_multiline_whitespace_around_double_arrow' => true,
54-
'no_multiline_whitespace_before_semicolons' => true,
54+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
5555
'no_php4_constructor' => false,
5656
'no_short_bool_cast' => true,
57-
'no_short_echo_tag' => false,
57+
'echo_tag_syntax' => false,
5858
'no_singleline_whitespace_before_semicolons' => true,
5959
'no_spaces_around_offset' => true,
60-
'no_trailing_comma_in_list_call' => true,
61-
'no_trailing_comma_in_singleline_array' => true,
60+
'no_trailing_comma_in_singleline' => true,
6261
'no_trailing_whitespace' => true,
6362
'no_trailing_whitespace_in_comment' => true,
6463
'no_unneeded_control_parentheses' => true,
@@ -82,9 +81,9 @@
8281
'phpdoc_align' => true,
8382
'phpdoc_annotation_without_dot' => true,
8483
'phpdoc_indent' => true,
85-
'phpdoc_inline_tag' => true,
84+
'phpdoc_inline_tag_normalizer' => true,
8685
'phpdoc_no_access' => true,
87-
'phpdoc_no_alias_tag' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var'],
86+
'phpdoc_no_alias_tag' => ['replacements' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var']],
8887
'phpdoc_no_empty_return' => true,
8988
'phpdoc_no_package' => true,
9089
// 'phpdoc_no_useless_inheritdoc' => true,
@@ -101,8 +100,7 @@
101100
'pow_to_exponentiation' => true,
102101
// 'pre_increment' => true,
103102
'protected_to_private' => true,
104-
'psr0' => true,
105-
'psr4' => true,
103+
'psr_autoloading' => true,
106104
'random_api_migration' => true,
107105
'return_type_declaration' => ['space_before' => 'one'],
108106
'self_accessor' => true,
@@ -125,8 +123,10 @@
125123
->setFinder(
126124
PhpCsFixer\Finder::create()
127125
->exclude('tests/Fake')
126+
->exclude('tests/tmp')
128127
->exclude('src-data')
129128
->exclude('src-deprecated')
129+
->exclude('docs/demo/tmp')
130130
->in(__DIR__)
131131
)->setLineEnding("\n")
132132
->setUsingCache(false);

0 commit comments

Comments
 (0)