Skip to content

Commit 6b90538

Browse files
committed
Fix phpstan errors
1 parent c4e1cc3 commit 6b90538

12 files changed

+221
-146
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ trim_trailing_whitespace = true
1111
[*.md]
1212
trim_trailing_whitespace = false
1313

14-
[*.yml]
14+
[{*.yml,*.yaml,*.neon}]
1515
indent_size = 2

.gitattributes

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
* text=auto
2-
3-
/.github export-ignore
4-
5-
/tests export-ignore
6-
phpunit.xml export-ignore
1+
* text=auto eol=lf
2+
*.pp eol=lf linguist-language=EBNF
3+
*.pp2 eol=lf linguist-language=EBNF
74

85
.editorconfig export-ignore
6+
.php-cs-fixer.php export-ignore
97
.gitattributes export-ignore
108
.gitignore export-ignore
119

10+
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

+36
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

+17-104
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,39 @@
11
name: build
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
6-
security:
7-
name: Security
8+
tests:
9+
name: Unit Tests (${{matrix.php}}-${{matrix.ts}}, ${{ matrix.os }}, ${{ matrix.stability }})
810
runs-on: ${{ matrix.os }}
911
strategy:
1012
fail-fast: false
1113
matrix:
12-
php: [ '8.1' ]
13-
os: [ ubuntu-latest ]
14-
steps:
15-
- name: Set Git To Use LF
16-
run: |
17-
git config --global core.autocrlf false
18-
git config --global core.eol lf
19-
- name: Checkout
20-
uses: actions/checkout@v2
21-
- name: Setup PHP ${{ matrix.php }}
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ matrix.php }}
25-
- name: Install Dependencies
26-
uses: nick-invision/retry@v1
27-
with:
28-
timeout_minutes: 5
29-
max_attempts: 5
30-
command: composer update --prefer-dist --no-interaction --no-progress
31-
- name: Security Advisories
32-
run: composer require --dev roave/security-advisories:dev-latest
33-
34-
static-analysis:
35-
name: Psalm
36-
runs-on: ${{ matrix.os }}
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
php: [ '8.1' ]
41-
os: [ ubuntu-latest ]
42-
43-
steps:
44-
- name: Set Git To Use LF
45-
run: |
46-
git config --global core.autocrlf false
47-
git config --global core.eol lf
48-
49-
- name: Checkout
50-
uses: actions/checkout@v2
51-
52-
- name: Setup PHP ${{ matrix.php }}
53-
uses: shivammathur/setup-php@v2
54-
with:
55-
php-version: ${{ matrix.php }}
56-
tools: composer:v2
57-
58-
- name: Install Dependencies
59-
uses: nick-invision/retry@v1
60-
with:
61-
timeout_minutes: 5
62-
max_attempts: 5
63-
command: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress
64-
65-
- name: Static Analysis
66-
continue-on-error: true
67-
run: vendor/bin/psalm --no-cache
68-
69-
coding-standards:
70-
name: Coding Standards
71-
runs-on: ${{ matrix.os }}
72-
strategy:
73-
fail-fast: false
74-
matrix:
75-
php: [ '8.1' ]
76-
os: [ ubuntu-latest ]
77-
78-
steps:
79-
- name: Checkout
80-
uses: actions/checkout@v2
81-
82-
- name: Setup PHP ${{ matrix.php }}
83-
uses: shivammathur/setup-php@v2
84-
with:
85-
php-version: ${{ matrix.php }}
86-
tools: composer:v2
87-
88-
- name: Install Dependencies
89-
uses: nick-invision/retry@v1
90-
with:
91-
timeout_minutes: 5
92-
max_attempts: 5
93-
command: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress
94-
95-
- name: Check Coding Standards
96-
run: vendor/bin/phpcs --standard=phpcs.xml
97-
98-
test:
99-
name: Build (${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }})
100-
runs-on: ${{ matrix.os }}
101-
strategy:
102-
fail-fast: false
103-
matrix:
104-
php: [ '7.4', '8.0', '8.1', '8.2' ]
14+
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
15+
ts: [ 'ts', 'nts' ]
10516
os: [ ubuntu-latest, macos-latest, windows-latest ]
10617
stability: [ prefer-lowest, prefer-stable ]
107-
10818
steps:
10919
- name: Checkout
110-
uses: actions/checkout@v2
111-
20+
uses: actions/[email protected]
11221
- name: Setup PHP ${{ matrix.php }}
11322
uses: shivammathur/setup-php@v2
11423
with:
11524
php-version: ${{ matrix.php }}
11625
tools: composer:v2
117-
26+
ini-values: ffi.enable=1
27+
extensions: ffi
28+
env:
29+
phpts: ${{ matrix.ts }}
30+
- name: Validate Composer
31+
run: composer validate
11832
- name: Install Dependencies
119-
uses: nick-invision/retry@v1
33+
uses: nick-invision/retry@v2
12034
with:
12135
timeout_minutes: 5
12236
max_attempts: 5
123-
command: composer update --${{ matrix.stability }} --ignore-platform-reqs --prefer-dist --no-interaction --no-progress
124-
37+
command: composer update --prefer-dist --no-interaction --no-progress
12538
- name: Execute Tests
126-
run: vendor/bin/phpunit
39+
run: composer test

.github/workflows/security.yml

+40
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

+36
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

+20-6
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
],
@@ -26,19 +26,33 @@
2626
}
2727
},
2828
"require-dev": {
29-
"vimeo/psalm": "^5.4",
3029
"phpunit/phpunit": "^9.5",
31-
"squizlabs/php_codesniffer": "^3.7",
32-
"jetbrains/phpstorm-attributes": "^1.0"
30+
"friendsofphp/php-cs-fixer": "^3.53",
31+
"phpstan/phpstan": "^2.0",
32+
"phpstan/phpstan-deprecation-rules": "^2.0",
33+
"phpstan/phpstan-strict-rules": "^2.0"
3334
},
3435
"autoload-dev": {
3536
"psr-4": {
3637
"FFI\\Env\\Tests\\": "tests"
3738
}
3839
},
3940
"config": {
40-
"sort-packages": true,
41-
"optimize-autoloader": true
41+
"optimize-autoloader": true,
42+
"preferred-install": {
43+
"*": "dist"
44+
},
45+
"sort-packages": true
46+
},
47+
"scripts": {
48+
"test": ["@test:unit"],
49+
"test:unit": "phpunit --testdox --testsuite=unit",
50+
"linter": "@linter:check",
51+
"linter:check": "phpstan analyse --configuration phpstan.neon",
52+
"linter:baseline": "@linter:check -- --generate-baseline",
53+
"phpcs": "@phpcs:check",
54+
"phpcs:check": "@phpcs:fix -- --dry-run",
55+
"phpcs:fix": "php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --verbose --diff"
4256
},
4357
"extra": {
4458
"branch-alias": {

phpstan.neon

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
4+
- vendor/phpstan/phpstan-strict-rules/rules.neon
5+
parameters:
6+
level: max
7+
phpVersion:
8+
min: 70400
9+
max: 80400
10+
parallel:
11+
jobSize: 20
12+
maximumNumberOfProcesses: 4
13+
minimumNumberOfJobsPerProcess: 2
14+
paths:
15+
- src
16+
tmpDir: vendor/.cache.phpstan
17+
rememberPossiblyImpureFunctionValues: false
18+
checkTooWideReturnTypesInProtectedAndPublicMethods: true
19+
checkImplicitMixed: true
20+
checkBenevolentUnionTypes: true
21+
reportPossiblyNonexistentGeneralArrayOffset: true
22+
reportPossiblyNonexistentConstantArrayOffset: true
23+
reportAlwaysTrueInLastCondition: true
24+
reportAnyTypeWideningInVarTag: true
25+
checkMissingOverrideMethodAttribute: false
26+
inferPrivatePropertyTypeFromConstructor: true
27+
tipsOfTheDay: false
28+
checkMissingCallableSignature: true

psalm.xml

-16
This file was deleted.

0 commit comments

Comments
 (0)