Skip to content

Commit 6845eae

Browse files
committed
Fix phpstan errors
1 parent dca16b8 commit 6845eae

File tree

10 files changed

+207
-180
lines changed

10 files changed

+207
-180
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ trim_trailing_whitespace = true
1010

1111
[*.md]
1212
trim_trailing_whitespace = false
13+
14+
[{*.yml,*.yaml,*.neon}]
15+
indent_size = 2

.gitattributes

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
* text=auto
2-
3-
/.github export-ignore
4-
/tests export-ignore
1+
* text=auto eol=lf
2+
*.pp eol=lf linguist-language=EBNF
3+
*.pp2 eol=lf linguist-language=EBNF
54

65
.editorconfig export-ignore
6+
.php-cs-fixer.php export-ignore
77
.gitattributes export-ignore
88
.gitignore export-ignore
9-
.styleci.yml export-ignore
10-
.travis.yml export-ignore
119

12-
monorepo-builder.php export-ignore
1310
phpunit.xml export-ignore
11+
psalm.xml export-ignore
12+
rector.php export-ignore
13+
14+
/.github export-ignore
15+
/example export-ignore
16+
/tests export-ignore

.github/workflows/codestyle.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: codestyle
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
psalm:
9+
name: Code Style
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '8.3' ]
15+
os: [ ubuntu-latest ]
16+
steps:
17+
- name: Set Git To Use LF
18+
run: |
19+
git config --global core.autocrlf false
20+
git config --global core.eol lf
21+
- name: Checkout
22+
uses: actions/[email protected]
23+
- name: Setup PHP ${{ matrix.php }}
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
- name: Validate Composer
28+
run: composer validate
29+
- name: Install Dependencies
30+
uses: nick-invision/retry@v2
31+
with:
32+
timeout_minutes: 5
33+
max_attempts: 5
34+
command: composer update --prefer-dist --no-interaction --no-progress
35+
- name: Check Code Style
36+
run: composer phpcs:check

.github/workflows/main.yml

Lines changed: 34 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,39 @@
11
name: build
22

33
on:
4-
push:
5-
pull_request:
6-
schedule:
7-
- cron: '0 0 * * *'
8-
9-
env:
10-
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
4+
push:
5+
pull_request:
116

127
jobs:
13-
security:
14-
name: Security
15-
runs-on: ${{ matrix.os }}
16-
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
php: [ '8.1' ]
21-
os: [ ubuntu-latest ]
22-
23-
steps: # General Steps
24-
- name: Set Git To Use LF
25-
run: |
26-
git config --global core.autocrlf false
27-
git config --global core.eol lf
28-
- name: Checkout
29-
uses: actions/checkout@v2
30-
31-
# Install PHP Dependencies
32-
- name: Setup PHP ${{ matrix.php }}
33-
uses: shivammathur/setup-php@v2
34-
with:
35-
php-version: ${{ matrix.php }}
36-
- name: Validate Composer
37-
run: composer validate
38-
- name: Get Composer Cache Directory
39-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
40-
id: composer-cache
41-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
42-
- name: Restore Composer Cache
43-
uses: actions/cache@v1
44-
with:
45-
path: ${{ steps.composer-cache.outputs.dir }}
46-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
47-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
48-
- name: Install Dependencies
49-
uses: nick-invision/retry@v1
50-
with:
51-
timeout_minutes: 5
52-
max_attempts: 5
53-
command: composer update --prefer-dist --no-interaction --no-progress
54-
55-
# Execution
56-
- name: Security Advisories
57-
run: composer require --dev roave/security-advisories:dev-latest
58-
59-
static-analysis:
60-
name: Psalm
61-
runs-on: ${{ matrix.os }}
62-
63-
strategy:
64-
fail-fast: false
65-
matrix:
66-
php: [ '7.4', '8.0', '8.1' ]
67-
os: [ ubuntu-latest ]
68-
69-
steps: # General Steps
70-
- name: Set Git To Use LF
71-
run: |
72-
git config --global core.autocrlf false
73-
git config --global core.eol lf
74-
- name: Checkout
75-
uses: actions/checkout@v2
76-
77-
# Install PHP Dependencies
78-
- name: Setup PHP ${{ matrix.php }}
79-
uses: shivammathur/setup-php@v2
80-
with:
81-
php-version: ${{ matrix.php }}
82-
- name: Validate Composer
83-
run: composer validate
84-
- name: Get Composer Cache Directory
85-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
86-
id: composer-cache
87-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
88-
- name: Restore Composer Cache
89-
uses: actions/cache@v1
90-
with:
91-
path: ${{ steps.composer-cache.outputs.dir }}
92-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
93-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
94-
- name: Install Dependencies
95-
uses: nick-invision/retry@v1
96-
with:
97-
timeout_minutes: 5
98-
max_attempts: 5
99-
command: composer update --prefer-dist --no-interaction --no-progress
100-
101-
# Execution
102-
- name: Static Analysis
103-
continue-on-error: true
104-
run: vendor/bin/psalm --no-cache
105-
106-
coding-standards:
107-
name: Coding Standards
108-
runs-on: ${{ matrix.os }}
109-
110-
strategy:
111-
fail-fast: false
112-
matrix:
113-
php: [ '8.1' ]
114-
os: [ ubuntu-latest ]
115-
116-
steps: # General Steps
117-
- name: Set Git To Use LF
118-
run: |
119-
git config --global core.autocrlf false
120-
git config --global core.eol lf
121-
- name: Checkout
122-
uses: actions/checkout@v2
123-
124-
# Install PHP Dependencies
125-
- name: Setup PHP ${{ matrix.php }}
126-
uses: shivammathur/setup-php@v2
127-
with:
128-
php-version: ${{ matrix.php }}
129-
- name: Validate Composer
130-
run: composer validate
131-
- name: Get Composer Cache Directory
132-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
133-
id: composer-cache
134-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
135-
- name: Restore Composer Cache
136-
uses: actions/cache@v1
137-
with:
138-
path: ${{ steps.composer-cache.outputs.dir }}
139-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
140-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
141-
- name: Install Dependencies
142-
uses: nick-invision/retry@v1
143-
with:
144-
timeout_minutes: 5
145-
max_attempts: 5
146-
command: composer update --prefer-dist --no-interaction --no-progress
147-
148-
# Execution
149-
- name: Check Coding Standards
150-
run: vendor/bin/phpcs --standard=phpcs.xml
8+
tests:
9+
name: Unit Tests (${{matrix.php}}-${{matrix.ts}}, ${{ matrix.os }}, ${{ matrix.stability }})
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
15+
ts: [ 'ts', 'nts' ]
16+
os: [ ubuntu-latest, macos-latest, windows-latest ]
17+
stability: [ prefer-lowest, prefer-stable ]
18+
steps:
19+
- name: Checkout
20+
uses: actions/[email protected]
21+
- name: Setup PHP ${{ matrix.php }}
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
tools: composer:v2
26+
ini-values: ffi.enable=1
27+
extensions: ffi
28+
env:
29+
phpts: ${{ matrix.ts }}
30+
- name: Validate Composer
31+
run: composer validate
32+
- name: Install Dependencies
33+
uses: nick-invision/retry@v2
34+
with:
35+
timeout_minutes: 5
36+
max_attempts: 5
37+
command: composer update --prefer-dist --no-interaction --no-progress
38+
- name: Execute Tests
39+
run: composer test

.github/workflows/security.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: security
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
security:
11+
name: Security
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php: [ '8.3' ]
17+
os: [ ubuntu-latest ]
18+
steps:
19+
- name: Set Git To Use LF
20+
run: |
21+
git config --global core.autocrlf false
22+
git config --global core.eol lf
23+
- name: Checkout
24+
uses: actions/[email protected]
25+
- name: Setup PHP ${{ matrix.php }}
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
- name: Validate Composer
30+
run: composer validate
31+
- name: Install Dependencies
32+
uses: nick-invision/retry@v2
33+
with:
34+
timeout_minutes: 5
35+
max_attempts: 5
36+
command: composer update --prefer-dist --no-interaction --no-progress
37+
- name: Composer Audit
38+
run: composer audit
39+
- name: Security Advisories
40+
run: composer require --dev roave/security-advisories:dev-latest

.github/workflows/static-analysis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: static-analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
psalm:
9+
name: Psalm
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '8.3' ]
15+
os: [ ubuntu-latest ]
16+
steps:
17+
- name: Set Git To Use LF
18+
run: |
19+
git config --global core.autocrlf false
20+
git config --global core.eol lf
21+
- name: Checkout
22+
uses: actions/[email protected]
23+
- name: Setup PHP ${{ matrix.php }}
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
- name: Validate Composer
28+
run: composer validate
29+
- name: Install Dependencies
30+
uses: nick-invision/retry@v2
31+
with:
32+
timeout_minutes: 5
33+
max_attempts: 5
34+
command: composer update --prefer-dist --no-interaction --no-progress
35+
- name: Static Analysis
36+
run: composer linter

composer.json

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"name": "Nesmeyanov Kirill",
1515
"email": "[email protected]",
16-
"homepage": "https://serafimarts.ru",
16+
"homepage": "https://nesk.me",
1717
"role": "maintainer"
1818
}
1919
],
@@ -27,23 +27,32 @@
2727
}
2828
},
2929
"require-dev": {
30-
"vimeo/psalm": "^4.21",
31-
"squizlabs/php_codesniffer": "^3.6"
30+
"phpunit/phpunit": "^9.5",
31+
"friendsofphp/php-cs-fixer": "^3.53",
32+
"phpstan/phpstan": "^2.0",
33+
"phpstan/phpstan-deprecation-rules": "^2.0",
34+
"phpstan/phpstan-strict-rules": "^2.0"
3235
},
3336
"config": {
34-
"sort-packages": true,
35-
"allow-plugins": {
36-
"composer/package-versions-deprecated": true
37-
}
37+
"optimize-autoloader": true,
38+
"preferred-install": {
39+
"*": "dist"
40+
},
41+
"sort-packages": true
3842
},
3943
"scripts": {
40-
"test": [
41-
"psalm --no-cache",
42-
"phpcs --standard=phpcs.xml"
43-
]
44+
"test": ["@test:unit"],
45+
"test:unit": "phpunit --testdox --testsuite=unit",
46+
"linter": "@linter:check",
47+
"linter:check": "phpstan analyse --configuration phpstan.neon",
48+
"linter:baseline": "@linter:check -- --generate-baseline",
49+
"phpcs": "@phpcs:check",
50+
"phpcs:check": "@phpcs:fix -- --dry-run",
51+
"phpcs:fix": "php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --verbose --diff"
4452
},
4553
"extra": {
4654
"branch-alias": {
55+
"dev-main": "1.0.x-dev",
4756
"dev-master": "1.0.x-dev"
4857
}
4958
},

0 commit comments

Comments
 (0)