lint/psalm

This commit is contained in:
Robin Appelman 2022-04-08 17:17:26 +02:00
commit 1290acf675
6 changed files with 103 additions and 1 deletions

41
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: Php Lint
on: [push, pull_request]
jobs:
php-linters:
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: ['7.4', '8.0']
name: php${{ matrix.php-versions }} lint
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php${{ matrix.php-versons }}
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: inotify
- name: Install dependencies
run: composer i
- name: Lint
run: composer run lint
php-cs-fixer:
name: php-cs check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@master
with:
php-version: 7.4
tools: composer:v1
coverage: none
extensions: inotify
- name: Install dependencies
run: composer i
- name: Run coding standards check
run: composer run cs:check

20
.github/workflows/static-analysis.yml vendored Normal file
View file

@ -0,0 +1,20 @@
name: Php Static analysis
on: [push, pull_request]
jobs:
static-psalm-analysis:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php
uses: shivammathur/setup-php@master
with:
php-version: 7.4
tools: composer:v1
coverage: none
extensions: redis
- name: Install dependencies
run: composer i
- name: Run coding standards check
run: composer run psalm

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ composer.lock
vendor
coverage.xml
.phpunit.result.cache
*.cache

15
.php_cs.dist Normal file
View file

@ -0,0 +1,15 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'braces' => ['position_after_functions_and_oop_constructs' => 'same'],
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => false],
])
->setIndent("\t")
->setFinder($finder)
;

View file

@ -9,10 +9,14 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.3 || >=8.0",
"sabre/dav": "^4.0.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.0",
"friendsofphp/php-cs-fixer": "^2",
"phpstan/phpstan": "^0.12",
"psalm/phar": "^4.3",
"phpunit/phpunit": "^8"
},
"autoload": {
@ -24,5 +28,11 @@
"psr-4": {
"SearchDAV\\Test\\": "tests/"
}
},
"scripts": {
"lint": "parallel-lint --exclude src --exclude vendor --exclude target --exclude build .",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar"
}
}

15
psalm.xml Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>