Skip to content

Commit e6d5312

Browse files
committed
improve code quality
1 parent 429b3fc commit e6d5312

44 files changed

Lines changed: 9551 additions & 311 deletions

Some content is hidden

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

.ddev/config.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ webserver_type: nginx-fpm
66
xdebug_enabled: false
77
additional_hostnames: []
88
additional_fqdns: []
9-
database:
10-
type: mariadb
11-
version: "10.11"
9+
omit_containers: [db, ddev-ssh-agent]
1210
hooks:
1311
post-start:
1412
- exec: composer i

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [8.1, 8.2, 8.3]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php }}
23+
extensions: mbstring, iconv
24+
coverage: pcov
25+
26+
- name: Validate composer.json and composer.lock
27+
run: composer validate --strict
28+
29+
- name: Cache Composer packages
30+
id: composer-cache
31+
uses: actions/cache@v3
32+
with:
33+
path: vendor
34+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-php-
37+
38+
- name: Install dependencies
39+
run: composer install --prefer-dist --no-progress
40+
41+
- name: Run PHPStan
42+
run: composer run phpstan
43+
44+
- name: Run PHP CodeSniffer
45+
run: composer run phpcs
46+
47+
- name: Run tests
48+
run: composer run test
49+
50+
- name: Run tests with coverage
51+
run: composer run test-coverage
52+
53+
- name: Upload coverage to Codecov
54+
uses: codecov/codecov-action@v3
55+
with:
56+
file: ./coverage.xml
57+
flags: unittests
58+
name: codecov-umbrella
59+
fail_ci_if_error: true
60+
61+
security:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Setup PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: 8.3
70+
71+
- name: Install dependencies
72+
run: composer install --prefer-dist --no-progress
73+
74+
- name: Run security audit
75+
run: composer audit
76+
77+
outdated:
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- name: Setup PHP
83+
uses: shivammathur/setup-php@v2
84+
with:
85+
php-version: 8.3
86+
87+
- name: Install dependencies
88+
run: composer install --prefer-dist --no-progress
89+
90+
- name: Check for outdated dependencies
91+
run: composer outdated --direct

.github/workflows/main.yml

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,117 @@
1-
name: Create tag and release
1+
name: CI/CD Pipeline
22
on:
33
push:
44
branches:
55
- master
6+
- develop
7+
pull_request:
8+
branches:
9+
- master
10+
- develop
11+
612
jobs:
7-
build:
13+
test:
14+
name: Run Tests
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
php: [8.1, 8.2, 8.3]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v5
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
extensions: mbstring, iconv
29+
coverage: xdebug
30+
31+
- name: Validate composer.json
32+
run: composer validate --strict
33+
34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
37+
38+
- name: Cache dependencies
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
43+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
44+
45+
- name: Install dependencies
46+
run: composer install --prefer-dist --no-progress
47+
48+
- name: Run PHPUnit tests
49+
run: composer test
50+
51+
- name: Run PHPUnit with coverage
52+
run: composer test-coverage
53+
54+
- name: Upload coverage to Coveralls
55+
if: matrix.php == '8.3'
56+
env:
57+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
58+
run: |
59+
if [ -f vendor/bin/php-coveralls ]; then
60+
vendor/bin/php-coveralls --coverage_clover=coverage.xml --json_path=coveralls.json
61+
fi
62+
63+
code-quality:
64+
name: Code Quality
65+
runs-on: ubuntu-latest
66+
needs: test
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Setup PHP
73+
uses: shivammathur/setup-php@v2
74+
with:
75+
php-version: '8.3'
76+
extensions: mbstring, iconv
77+
78+
- name: Install dependencies
79+
run: composer install --prefer-dist --no-progress
80+
81+
- name: Run PHPStan
82+
run: composer phpstan
83+
84+
- name: Run PHP CodeSniffer
85+
run: composer phpcs
86+
87+
- name: Run PHP Code Beautifier and Fixer
88+
run: composer phpcbf
89+
90+
release:
91+
name: Create Release
892
runs-on: ubuntu-latest
93+
needs: [test, code-quality]
94+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
95+
996
steps:
1097
- name: Checkout code
11-
uses: actions/checkout@master
98+
uses: actions/checkout@v4
99+
100+
- name: Setup PHP
101+
uses: shivammathur/setup-php@v2
102+
with:
103+
php-version: '8.3'
104+
extensions: mbstring, iconv
105+
106+
- name: Install dependencies
107+
run: composer install --prefer-dist --no-progress
108+
109+
- name: Generate configuration files
110+
run: composer generate
12111

13112
- name: Bump version and push tag
14113
id: create_tag
15-
uses: mathieudutour/github-tag-action@v6.0
114+
uses: mathieudutour/github-tag-action@v6.2
16115
with:
17116
github_token: ${{ secrets.GITHUB_TOKEN }}
18117

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
vendor/
2-
.idea/
2+
.idea/
3+
.phpunit.cache/
4+
.php-cs-fixer.cache

.htaccess

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# https://github.com/Stevie-Ray/referrer-spam-blocker
2-
# Updated 2025-08-24 21:12:29
2+
# Updated 2025-08-24 23:18:10
3+
34

45
<IfModule mod_rewrite.c>
56

@@ -1121,7 +1122,6 @@ RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*e\-kwiaciarz\.pl.*$ [NC,OR]
11211122
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*e\-stroymart\.kz.*$ [NC,OR]
11221123
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*e2click\.com.*$ [NC,OR]
11231124
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*eandsgallery\.com.*$ [NC,OR]
1124-
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*eaplay\.ru/a00af605.*$ [NC,OR]
11251125
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*eaptekaplus\.ru.*$ [NC,OR]
11261126
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*earn\-from\-articles\.com.*$ [NC,OR]
11271127
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*earnian\-money\.info.*$ [NC,OR]
@@ -2246,7 +2246,6 @@ RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*lida\-ru\.com.*$ [NC,OR]
22462246
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*lider82\.ru.*$ [NC,OR]
22472247
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*life\.biz\.ua.*$ [NC,OR]
22482248
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*lifebyleese\.com.*$ [NC,OR]
2249-
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*lifehacĸer\.com.*$ [NC,OR]
22502249
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*lifespeaker\.ru.*$ [NC,OR]
22512250
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*ligastavok\-in\.ru.*$ [NC,OR]
22522251
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*light\.ifmo\.ru.*$ [NC,OR]
@@ -2714,7 +2713,6 @@ RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*oklogistic\.ru.*$ [NC,OR]
27142713
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*okna\-systems\.pro.*$ [NC,OR]
27152714
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*okno\.ooo.*$ [NC,OR]
27162715
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*okoshkah\.com.*$ [NC,OR]
2717-
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*okout\.ru/a00af605.*$ [NC,OR]
27182716
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*okroshki\.ru.*$ [NC,OR]
27192717
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*oktube\.ru.*$ [NC,OR]
27202718
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?.*oledonline\.xyz.*$ [NC,OR]
@@ -5614,7 +5612,6 @@ SetEnvIfNoCase Referer e\-kwiaciarz\.pl spambot=yes
56145612
SetEnvIfNoCase Referer e\-stroymart\.kz spambot=yes
56155613
SetEnvIfNoCase Referer e2click\.com spambot=yes
56165614
SetEnvIfNoCase Referer eandsgallery\.com spambot=yes
5617-
SetEnvIfNoCase Referer eaplay\.ru/a00af605 spambot=yes
56185615
SetEnvIfNoCase Referer eaptekaplus\.ru spambot=yes
56195616
SetEnvIfNoCase Referer earn\-from\-articles\.com spambot=yes
56205617
SetEnvIfNoCase Referer earnian\-money\.info spambot=yes
@@ -6739,7 +6736,6 @@ SetEnvIfNoCase Referer lida\-ru\.com spambot=yes
67396736
SetEnvIfNoCase Referer lider82\.ru spambot=yes
67406737
SetEnvIfNoCase Referer life\.biz\.ua spambot=yes
67416738
SetEnvIfNoCase Referer lifebyleese\.com spambot=yes
6742-
SetEnvIfNoCase Referer lifehacĸer\.com spambot=yes
67436739
SetEnvIfNoCase Referer lifespeaker\.ru spambot=yes
67446740
SetEnvIfNoCase Referer ligastavok\-in\.ru spambot=yes
67456741
SetEnvIfNoCase Referer light\.ifmo\.ru spambot=yes
@@ -7207,7 +7203,6 @@ SetEnvIfNoCase Referer oklogistic\.ru spambot=yes
72077203
SetEnvIfNoCase Referer okna\-systems\.pro spambot=yes
72087204
SetEnvIfNoCase Referer okno\.ooo spambot=yes
72097205
SetEnvIfNoCase Referer okoshkah\.com spambot=yes
7210-
SetEnvIfNoCase Referer okout\.ru/a00af605 spambot=yes
72117206
SetEnvIfNoCase Referer okroshki\.ru spambot=yes
72127207
SetEnvIfNoCase Referer oktube\.ru spambot=yes
72137208
SetEnvIfNoCase Referer oledonline\.xyz spambot=yes

.php-cs-fixer.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in([
7+
__DIR__ . '/src',
8+
__DIR__ . '/tests',
9+
])
10+
->exclude('vendor');
11+
12+
return (new PhpCsFixer\Config())
13+
->setRules([
14+
'@PSR12' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'binary_operator_spaces' => true,
17+
'blank_line_after_opening_tag' => true,
18+
'blank_line_before_statement' => [
19+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
20+
],
21+
'cast_spaces' => true,
22+
'class_attributes_separation' => [
23+
'elements' => [
24+
'method' => 'one',
25+
'property' => 'one',
26+
],
27+
],
28+
'concat_space' => ['spacing' => 'one'],
29+
'declare_equal_normalize' => true,
30+
'function_typehint_space' => true,
31+
'include' => true,
32+
'lowercase_cast' => true,
33+
'method_argument_space' => [
34+
'on_multiline' => 'ensure_fully_multiline',
35+
'keep_multiple_spaces_after_comma' => true,
36+
],
37+
'native_function_casing' => true,
38+
'native_function_type_declaration_casing' => true,
39+
'new_with_braces' => true,
40+
'no_blank_lines_after_class_opening' => true,
41+
'no_blank_lines_after_phpdoc' => true,
42+
'no_empty_statement' => true,
43+
'no_extra_blank_lines' => true,
44+
'no_leading_import_slash' => true,
45+
'no_leading_namespace_whitespace' => true,
46+
'no_trailing_comma_in_singleline' => true,
47+
'no_unused_imports' => true,
48+
'no_whitespace_in_blank_line' => true,
49+
'object_operator_without_whitespace' => true,
50+
'phpdoc_indent' => true,
51+
'phpdoc_no_access' => true,
52+
'phpdoc_no_package' => true,
53+
'phpdoc_scalar' => true,
54+
'phpdoc_single_line_var_spacing' => true,
55+
'phpdoc_trim' => true,
56+
'phpdoc_var_without_name' => true,
57+
58+
'single_quote' => true,
59+
'standardize_not_equals' => true,
60+
'ternary_operator_spaces' => true,
61+
'trailing_comma_in_multiline' => true,
62+
'trim_array_spaces' => true,
63+
'unary_operator_spaces' => true,
64+
'whitespace_after_comma_in_array' => true,
65+
])
66+
->setFinder($finder);

0 commit comments

Comments
 (0)