Skip to content

Commit d4efdfb

Browse files
authored
Merge pull request #20 from nanasess/add-development-libraries
feat: add comprehensive development tools and improve code quality
2 parents 3da9373 + db51081 commit d4efdfb

File tree

11 files changed

+626
-463
lines changed

11 files changed

+626
-463
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ insert_final_newline = true
1212
trim_trailing_whitespace = true
1313

1414
[*.md]
15-
trim_trailing_whitespace = false
15+
trim_trailing_whitespace = false
16+
17+
[{*.neon,phpstan.neon.dist}]
18+
indent_style = tab

.github/workflows/ci.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,41 @@ name: CI
22
on: [push, pull_request]
33

44
permissions:
5-
contents: read # to fetch code (actions/checkout)
5+
contents: read # to fetch code (actions/checkout)
66

77
jobs:
8+
php-cs-fixer:
9+
name: PHP-CS-Fixer
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Install dependencies
15+
uses: php-actions/composer@v6
16+
with:
17+
php_version: '8.1'
18+
- name: Run PHP-CS-Fixer
19+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --allow-risky=yes
20+
21+
phpstan:
22+
name: PHPStan
23+
needs: php-cs-fixer
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Install dependencies
29+
uses: php-actions/composer@v6
30+
with:
31+
php_version: '8.1'
32+
- name: Run PHPStan
33+
uses: php-actions/phpstan@v3
34+
with:
35+
php_version: '8.1'
36+
837
tests:
938
name: Tests
39+
needs: phpstan
1040
timeout-minutes: 10
1141
runs-on: ${{ matrix.os }}
1242
steps:

.github/workflows/rector.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# github action that checks code with Rector
2+
name: Rector
3+
4+
on:
5+
pull_request: null
6+
7+
jobs:
8+
rector:
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.head.repo.full_name == 'nanasess/bcmath-polyfill'
11+
steps:
12+
-
13+
if: github.event.pull_request.head.repo.full_name == github.repository
14+
uses: actions/checkout@v4
15+
with:
16+
# Must be used to trigger workflow after push
17+
token: ${{ secrets.ACCESS_TOKEN }}
18+
19+
-
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: 8.1
23+
coverage: none
24+
25+
- uses: "ramsey/composer-install@v3"
26+
27+
- run: vendor/bin/rector --ansi
28+
# @todo apply coding standard if used
29+
30+
-
31+
# commit only to core contributors who have repository access
32+
uses: stefanzweifel/git-auto-commit-action@v5
33+
with:
34+
commit_message: '[rector] Rector fixes'
35+
commit_author: 'GitHub Action <[email protected]>'
36+
commit_user_email: '[email protected]'

.php-cs-fixer.dist.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__.'/src')
5+
->in(__DIR__.'/lib')
6+
->in(__DIR__.'/tests')
7+
;
8+
9+
return (new PhpCsFixer\Config())
10+
->setRules([
11+
'@PER-CS' => true,
12+
'@PHP81Migration' => true,
13+
'@PHPUnit100Migration:risky' => true,
14+
'@PhpCsFixer' => true,
15+
'fully_qualified_strict_types' => false,
16+
'yoda_style' => false,
17+
'php_unit_data_provider_method_order' => false,
18+
'phpdoc_align' => false,
19+
'ordered_class_elements' => false,
20+
'increment_style' => false,
21+
'@PhpCsFixer:risky' => true,
22+
'strict_comparison' => false,
23+
'is_null' => false,
24+
'native_function_invocation' => false,
25+
'error_suppression' => true,
26+
'php_unit_test_case_static_method_calls' => false,
27+
'final_internal_class' => false,
28+
'php_unit_data_provider_name' => false,
29+
])
30+
->setFinder($finder)
31+
;

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
},
3434
"require-dev": {
3535
"phpunit/phpunit": "^10.5",
36-
"squizlabs/php_codesniffer": "^3.0"
36+
"phpstan/phpstan": "^2.1",
37+
"friendsofphp/php-cs-fixer": "^3.86",
38+
"rector/rector": "^2.1"
3739
},
3840
"suggest": {
3941
"ext-gmp": "Will enable faster math operations"

0 commit comments

Comments
 (0)