Skip to content

Commit 2ec29d3

Browse files
committed
Migrate to PHP 8.3+ and add docs/wiki
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent ed8fc9d commit 2ec29d3

39 files changed

Lines changed: 838 additions & 219 deletions

.docheader

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* This source file is subject to the license bundled
55
* with this source code in the file LICENSE.
66
*
7-
* @link https://github.com/php-fast-forward/http-factory
87
* @copyright Copyright (c) 2025-%year% Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
98
* @license https://opensource.org/licenses/MIT MIT License
9+
*
10+
* @see https://github.com/php-fast-forward/http-factory
11+
* @see https://github.com/php-fast-forward
12+
* @see https://datatracker.ietf.org/doc/html/rfc2119
1013
*/

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "composer"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
commit-message:
8+
prefix: "Composer"
9+
include: "scope"
10+
labels:
11+
- "composer"
12+
- "dependencies"
13+
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
commit-message:
19+
prefix: "GitHub Actions"
20+
include: "scope"
21+
labels:
22+
- "github-actions"
23+
- "continuous-integration"

.github/workflows/reports.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Fast Forward Reports"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
reports:
16+
uses: php-fast-forward/dev-tools/.github/workflows/reports.yml@main
17+
secrets: inherit

.github/workflows/tests.yml

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,15 @@
1-
name: Run PHPUnit Tests
1+
name: "Fast Forward Test Suite"
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
6-
push:
7-
branches: [ "main" ]
4+
push:
5+
workflow_dispatch:
86

97
permissions:
10-
contents: read
11-
pages: write
12-
id-token: write
13-
14-
concurrency:
15-
group: "pages"
16-
cancel-in-progress: false
8+
contents: write
9+
pages: write
10+
id-token: write
1711

1812
jobs:
19-
tests:
20-
runs-on: ubuntu-latest
21-
22-
steps:
23-
- uses: actions/checkout@v4
24-
25-
- name: Get Composer Cache Directory
26-
id: composer-cache
27-
run: |
28-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29-
30-
- name: Cache Composer dependencies
31-
uses: actions/cache@v4
32-
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-composer-
37-
38-
- name: Install dependencies
39-
uses: php-actions/composer@v6
40-
env:
41-
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
42-
with:
43-
php_version: '8.4'
44-
45-
- name: Run PHPUnit tests
46-
uses: php-actions/phpunit@v3
47-
env:
48-
XDEBUG_MODE: coverage
49-
with:
50-
php_version: '8.4'
51-
php_extensions: pcov
52-
53-
- name: Ensure minimum code coverage
54-
env:
55-
MINIMUM_COVERAGE: 80
56-
run: |
57-
COVERAGE=$(php -r '
58-
$xml = new SimpleXMLElement(file_get_contents("public/coverage/clover.xml"));
59-
$m = $xml->project->metrics;
60-
$pct = (int) round(((int) $m["coveredstatements"]) * 100 / (int) $m["statements"]);
61-
echo $pct;
62-
')
63-
echo "Coverage: ${COVERAGE}%"
64-
if [ "${COVERAGE}" -lt ${{ env.MINIMUM_COVERAGE }} ]; then
65-
echo "Code coverage below ${{ env.MINIMUM_COVERAGE }}% threshold."
66-
exit 1
67-
fi
68-
69-
- name: Upload artifact
70-
if: github.ref == 'refs/heads/main'
71-
uses: actions/upload-pages-artifact@v3
72-
with:
73-
path: public/coverage
74-
75-
deploy:
76-
if: github.ref == 'refs/heads/main'
77-
needs: tests
78-
environment:
79-
name: github-pages
80-
url: ${{ steps.deployment.outputs.page_url }}
81-
runs-on: ubuntu-latest
82-
steps:
83-
- name: Deploy to GitHub Pages
84-
id: deployment
85-
uses: actions/deploy-pages@v4
13+
tests:
14+
uses: php-fast-forward/dev-tools/.github/workflows/tests.yml@main
15+
secrets: inherit

.github/workflows/wiki.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Fast Forward Wiki Update"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
wiki:
16+
uses: php-fast-forward/dev-tools/.github/workflows/wiki.yml@main
17+
secrets: inherit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.idea/
2+
.vscode/
23
public/
4+
tmp/
35
vendor/
46
composer.lock
57
*.cache

.php-cs-fixer.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

composer.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
"source": "https://github.com/php-fast-forward/http-factory"
1616
},
1717
"require": {
18-
"php": "^8.2",
18+
"php": "^8.3",
1919
"fast-forward/container": "^1.5",
2020
"fast-forward/http-message": "^1.2",
2121
"nyholm/psr7-server": "^1.1",
2222
"psr/http-factory": "^1.1"
2323
},
2424
"require-dev": {
25-
"coisa/php-cs-fixer": "^2.1",
26-
"phpspec/prophecy-phpunit": "^2.3",
27-
"phpunit/phpunit": "^9.6 || ^10.5 || ^11.5"
25+
"fast-forward/dev-tools": "dev-main"
2826
},
2927
"minimum-stability": "stable",
3028
"autoload": {
@@ -38,23 +36,27 @@
3836
}
3937
},
4038
"config": {
39+
"allow-plugins": {
40+
"ergebnis/composer-normalize": true,
41+
"fast-forward/dev-tools": true,
42+
"phpdocumentor/shim": true,
43+
"phpro/grumphp": true
44+
},
45+
"platform": {
46+
"php": "8.3.0"
47+
},
4148
"sort-packages": true
4249
},
4350
"extra": {
4451
"branch-alias": {
4552
"dev-main": "1.x-dev"
53+
},
54+
"grumphp": {
55+
"config-default-path": "vendor/fast-forward/dev-tools/grumphp.yml"
4656
}
4757
},
4858
"scripts": {
49-
"cs-check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff",
50-
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
51-
"mutation-testing": "infection --threads=4",
52-
"pre-commit": [
53-
"@cs-check",
54-
"@static-analysis",
55-
"@tests"
56-
],
57-
"static-analysis": "phpstan analyse --level 5 src",
58-
"tests": "phpunit --testdox"
59+
"dev-tools": "dev-tools",
60+
"dev-tools:fix": "@dev-tools --fix"
5961
}
6062
}

docs/advanced/aliases.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Aliases and Factories
2+
=====================
3+
4+
All PSR-17 aliases are resolved to a single instance of `Nyholm\Psr7\Factory\Psr17Factory`, ensuring consistency and resource efficiency.
5+
6+
Details:
7+
--------
8+
9+
- **Singleton Pattern**: The same instance is reused for all PSR-17 interfaces, reducing memory usage and initialization overhead.
10+
- **Custom Implementations**: You can override any alias by registering your own implementation in the container.
11+
- **ServerRequestInterface**: Resolved using the static `fromGlobals()` method from `Nyholm\Psr7Server\ServerRequestCreator`, providing easy access to the current HTTP request.
12+
- **Extensibility**: The provider is designed to be extensible, allowing you to add or replace factories as needed for your application.

docs/advanced/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Advanced Topics
2+
===============
3+
4+
Overview
5+
--------
6+
7+
This section covers advanced usage and internal details of FastForward HTTP Factory. Each topic below provides in-depth documentation and examples:
8+
9+
- **Integration with PSR-11 Containers**: How to use the service provider with different containers and best practices for configuration.
10+
- **Aliases and Factories**: Details on how PSR-17 aliases are resolved, singleton patterns, and customization.
11+
- **Automated Tests**: How the package is tested, what is covered, and how to extend tests for your own use cases.
12+
- **Code Coverage**: How to access and interpret the coverage report, and tips for maintaining high test coverage.
13+
14+
Select a topic from the list above for more details.
15+
16+
.. toctree::
17+
:maxdepth: 2
18+
:caption: Advanced Topics
19+
20+
integration
21+
aliases

0 commit comments

Comments
 (0)