Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Test"

on:
push:
pull_request:

jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Check code style
run: vendor/bin/php-cs-fixer fix --dry-run --show-progress=dots --verbose --diff
- name: Run static analysis
run: vendor/bin/phpstan
- name: Test with phpunit
run: vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
phpunit.xml
/.phpunit.result.cache
/.php-cs-fixer.cache
47 changes: 47 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
# https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/rules/index.rst

$finder = PhpCsFixer\Finder::create()
->in(['src', 'tests'])
->exclude(['vendor'])
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'@PHP81Migration' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'constant_case' => true,
'increment_style' => false,
'lowercase_keywords' => true,
'normalize_index_brace' => true,
'no_closing_tag' => true,
'no_extra_blank_lines' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false,
'phpdoc_order' => true,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'protected_to_private' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_line_comment_style' => false,
'single_line_throw' => false,
'single_quote' => false,
'single_trait_insert_per_statement' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{"name": "Johannes M. Schmitt", "email": "[email protected]"}
],
"require": {
"php": "^8.0",
"phpoption/phpoption": "1.*"
},
"autoload": {
Expand All @@ -20,6 +21,13 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.6",
"friendsofphp/php-cs-fixer": "^3.8"
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon -vvv --ansi",
"format": "vendor/bin/php-cs-fixer fix --show-progress=dots --verbose --diff",
"test": "vendor/bin/phpunit"
}
}
Loading