Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Dec 17, 2024
1 parent b7e23b9 commit bf5bffc
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[{*.yml,*.yaml,*.neon}]
indent_size = 2
17 changes: 11 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
* text=auto

/.github export-ignore

/tests export-ignore
phpunit.xml export-ignore
* text=auto eol=lf
*.pp eol=lf linguist-language=EBNF
*.pp2 eol=lf linguist-language=EBNF

.editorconfig export-ignore
.php-cs-fixer.php export-ignore
.gitattributes export-ignore
.gitignore export-ignore

phpunit.xml export-ignore
psalm.xml export-ignore
rector.php export-ignore

/.github export-ignore
/example export-ignore
/tests export-ignore
36 changes: 36 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: codestyle

on:
push:
pull_request:

jobs:
psalm:
name: Code Style
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ ubuntu-latest ]
steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
- name: Check Code Style
run: composer phpcs:check
121 changes: 17 additions & 104 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,126 +1,39 @@
name: build

on: [push, pull_request]
on:
push:
pull_request:

jobs:
security:
name: Security
tests:
name: Unit Tests (${{matrix.php}}-${{matrix.ts}}, ${{ matrix.os }}, ${{ matrix.stability }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.1' ]
os: [ ubuntu-latest ]
steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
- name: Security Advisories
run: composer require --dev roave/security-advisories:dev-latest

static-analysis:
name: Psalm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.1' ]
os: [ ubuntu-latest ]

steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress

- name: Static Analysis
continue-on-error: true
run: vendor/bin/psalm --no-cache

coding-standards:
name: Coding Standards
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.1' ]
os: [ ubuntu-latest ]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress

- name: Check Coding Standards
run: vendor/bin/phpcs --standard=phpcs.xml

test:
name: Build (${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
ts: [ 'ts', 'nts' ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
stability: [ prefer-lowest, prefer-stable ]

steps:
- name: Checkout
uses: actions/checkout@v2

uses: actions/checkout@v3.3.0
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

ini-values: ffi.enable=1
extensions: ffi
env:
phpts: ${{ matrix.ts }}
- name: Validate Composer
run: composer validate
- name: Install Dependencies
uses: nick-invision/retry@v1
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --ignore-platform-reqs --prefer-dist --no-interaction --no-progress

command: composer update --prefer-dist --no-interaction --no-progress
- name: Execute Tests
run: vendor/bin/phpunit
run: composer test
40 changes: 40 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: security

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
security:
name: Security
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ ubuntu-latest ]
steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
- name: Composer Audit
run: composer audit
- name: Security Advisories
run: composer require --dev roave/security-advisories:dev-latest
36 changes: 36 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: static-analysis

on:
push:
pull_request:

jobs:
psalm:
name: Psalm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ ubuntu-latest ]
steps:
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
- name: Static Analysis
run: composer linter
25 changes: 20 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"name": "Nesmeyanov Kirill",
"email": "nesk@xakep.ru",
"homepage": "https://serafimarts.ru",
"homepage": "https://nesk.me",
"role": "maintainer"
}
],
Expand All @@ -28,18 +28,33 @@
}
},
"require-dev": {
"vimeo/psalm": "^5.4",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7"
"friendsofphp/php-cs-fixer": "^3.53",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0"
},
"autoload-dev": {
"psr-4": {
"FFI\\Proxy\\Tests\\": "tests"
}
},
"config": {
"sort-packages": true,
"optimize-autoloader": true
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"scripts": {
"test": ["@test:unit"],
"test:unit": "phpunit --testdox --testsuite=unit",
"linter": "@linter:check",
"linter:check": "phpstan analyse --configuration phpstan.neon",
"linter:baseline": "@linter:check -- --generate-baseline",
"phpcs": "@phpcs:check",
"phpcs:check": "@phpcs:fix -- --dry-run",
"phpcs:fix": "php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --verbose --diff"
},
"extra": {
"branch-alias": {
Expand Down
28 changes: 28 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
level: max
phpVersion:
min: 70400
max: 80400
parallel:
jobSize: 20
maximumNumberOfProcesses: 4
minimumNumberOfJobsPerProcess: 2
paths:
- src
tmpDir: vendor/.cache.phpstan
rememberPossiblyImpureFunctionValues: false
checkTooWideReturnTypesInProtectedAndPublicMethods: true
checkImplicitMixed: true
checkBenevolentUnionTypes: true
reportPossiblyNonexistentGeneralArrayOffset: true
reportPossiblyNonexistentConstantArrayOffset: true
reportAlwaysTrueInLastCondition: true
reportAnyTypeWideningInVarTag: true
checkMissingOverrideMethodAttribute: false
inferPrivatePropertyTypeFromConstructor: true
tipsOfTheDay: false
checkMissingCallableSignature: true
16 changes: 0 additions & 16 deletions psalm.xml

This file was deleted.

Loading

0 comments on commit bf5bffc

Please sign in to comment.