Skip to content

Commit 44b3b4a

Browse files
committed
Add middleware support and align with Contributte OSS standards
- Add middleware system (Middleware interface, CorsMiddleware, Middlewares factory) - Update Application to support middleware chain via $app->use() - Fix Router to properly handle HTTP method matching for multiple routes - Update tests to use Toolkit::test() pattern - Add GitHub Actions workflows (codesniffer, coverage, phpstan, tests) - Update configuration files to match Contributte standards - Update composer.json with contributte/phpstan, contributte/qa, contributte/tester - PHPStan level 9 compliance
1 parent 4bb9a85 commit 44b3b4a

24 files changed

Lines changed: 1057 additions & 785 deletions

.editorconfig

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ trim_trailing_whitespace = true
88
indent_style = tab
99
indent_size = 4
1010

11-
[*.md]
12-
trim_trailing_whitespace = false
13-
14-
[*.{yml,yaml}]
11+
[*.{json,yaml,yml,md}]
1512
indent_style = space
1613
indent_size = 2
17-
18-
[*.neon]
19-
indent_style = tab
20-
indent_size = 4

.gitattributes

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
* text=auto eol=lf
2-
3-
# Git
1+
.docs export-ignore
2+
.editorconfig export-ignore
43
.gitattributes export-ignore
54
.gitignore export-ignore
6-
7-
# CI
8-
.github/ export-ignore
9-
10-
# IDE
11-
.editorconfig export-ignore
12-
13-
# Development
14-
tests/ export-ignore
5+
.github export-ignore
6+
Makefile export-ignore
157
phpstan.neon export-ignore
168
ruleset.xml export-ignore
17-
Makefile export-ignore
9+
tests export-ignore

.github/workflows/codesniffer.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Codesniffer
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "**"
9+
schedule:
10+
- cron: "0 8 * * 1"
11+
12+
jobs:
13+
codesniffer:
14+
name: Codesniffer
15+
uses: contributte/.github/.github/workflows/codesniffer.yml@master
16+
with:
17+
php: 8.2

.github/workflows/coverage.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Coverage
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "**"
9+
schedule:
10+
- cron: "0 9 * * 1"
11+
12+
jobs:
13+
coverage:
14+
name: Nette Tester
15+
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
16+
with:
17+
php: 8.2

.github/workflows/phpstan.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Phpstan
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "**"
9+
schedule:
10+
- cron: "0 10 * * 1"
11+
12+
jobs:
13+
phpstan:
14+
name: Phpstan
15+
uses: contributte/.github/.github/workflows/phpstan.yml@master
16+
with:
17+
php: 8.2

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "**"
9+
schedule:
10+
- cron: "0 10 * * 1"
11+
12+
jobs:
13+
test85:
14+
name: Tests (PHP 8.5)
15+
uses: contributte/.github/.github/workflows/nette-tester.yml@master
16+
with:
17+
php: 8.5
18+
19+
test84:
20+
name: Tests (PHP 8.4)
21+
uses: contributte/.github/.github/workflows/nette-tester.yml@master
22+
with:
23+
php: 8.4
24+
25+
test83:
26+
name: Tests (PHP 8.3)
27+
uses: contributte/.github/.github/workflows/nette-tester.yml@master
28+
with:
29+
php: 8.3
30+
31+
test82:
32+
name: Tests (PHP 8.2)
33+
uses: contributte/.github/.github/workflows/nette-tester.yml@master
34+
with:
35+
php: 8.2
36+
37+
testlowest:
38+
name: Tests (PHP 8.2, lowest)
39+
uses: contributte/.github/.github/workflows/nette-tester.yml@master
40+
with:
41+
php: 8.2
42+
composer: composer update --no-interaction --no-progress --prefer-dist --prefer-lowest --prefer-stable

.gitignore

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
# Composer
2-
/vendor/
3-
composer.lock
1+
/.idea
42

5-
# IDE
6-
/.idea/
7-
/.vscode/
8-
*.swp
9-
*.swo
3+
/vendor
4+
/composer.lock
105

11-
# OS
12-
.DS_Store
13-
Thumbs.db
14-
15-
# Testing
16-
/coverage.html
17-
/coverage.xml
18-
19-
# Temporary
20-
/temp/
6+
/tests/tmp
7+
/coverage.*
8+
*.log
9+
*.html
10+
*.expected
11+
*.actual

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
.PHONY: install qa cs csf phpstan tests coverage
2-
1+
.PHONY: install
32
install:
43
composer update
54

5+
.PHONY: qa
66
qa: phpstan cs
77

8+
.PHONY: cs
89
cs:
910
ifdef GITHUB_ACTION
10-
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --colors -nsp -q --report=checkstyle src tests | cs2pr
11+
vendor/bin/phpcs --standard=ruleset.xml --extensions="php,phpt" --encoding=utf-8 --colors -nsp -q --report=checkstyle src tests | cs2pr
1112
else
12-
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests
13+
vendor/bin/phpcs --standard=ruleset.xml --extensions="php,phpt" --encoding=utf-8 --colors -nsp src tests
1314
endif
1415

16+
.PHONY: csf
1517
csf:
16-
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests
18+
vendor/bin/phpcbf --standard=ruleset.xml --extensions="php,phpt" --encoding=utf-8 --colors -nsp src tests
1719

20+
.PHONY: phpstan
1821
phpstan:
1922
vendor/bin/phpstan analyse -c phpstan.neon
2023

24+
.PHONY: tests
2125
tests:
22-
vendor/bin/tester -s -p php --colors 1 -C tests
26+
vendor/bin/tester -s -p php --colors 1 -C tests/Cases
2327

28+
.PHONY: coverage
2429
coverage:
2530
ifdef GITHUB_ACTION
26-
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests
31+
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/Cases
2732
else
28-
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests
33+
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests/Cases
2934
endif

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=8.1",
21-
"nette/routing": "^3.1",
22-
"nette/http": "^3.3"
20+
"php": ">=8.2",
21+
"nette/http": "^3.3.0",
22+
"nette/routing": "^3.1.0"
2323
},
2424
"require-dev": {
25-
"contributte/phpstan": "^0.1",
26-
"contributte/tester": "^0.3",
27-
"nette/tester": "^2.5",
28-
"phpstan/phpstan": "^2.0",
29-
"squizlabs/php_codesniffer": "^3.10"
25+
"contributte/phpstan": "~0.1.0",
26+
"contributte/qa": "~0.4.0",
27+
"contributte/tester": "~0.3.0",
28+
"nette/tester": "^2.5.0"
3029
},
3130
"autoload": {
3231
"psr-4": {
@@ -38,6 +37,8 @@
3837
"Tests\\": "tests/"
3938
}
4039
},
40+
"minimum-stability": "dev",
41+
"prefer-stable": true,
4142
"extra": {
4243
"branch-alias": {
4344
"dev-master": "0.1.x-dev"
@@ -48,6 +49,5 @@
4849
"allow-plugins": {
4950
"dealerdirect/phpcodesniffer-composer-installer": true
5051
}
51-
},
52-
"minimum-stability": "stable"
52+
}
5353
}

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ includes:
22
- vendor/contributte/phpstan/phpstan.neon
33

44
parameters:
5-
level: 8
6-
phpVersion: 80100
5+
level: 9
6+
phpVersion: 80200
77

88
scanDirectories:
99
- src

0 commit comments

Comments
 (0)