Skip to content

Commit 6265146

Browse files
committed
php85
1 parent 64224af commit 6265146

File tree

6 files changed

+108
-37
lines changed

6 files changed

+108
-37
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,36 @@ on:
66
- cron: "0 0 * * *"
77

88
jobs:
9-
php82:
10-
name: PHP 8.2
9+
php83:
10+
name: PHP 8.3
1111
runs-on: ubuntu-24.04
1212
steps:
1313
- name: checkout
1414
uses: actions/checkout@v4
1515
- name: composer test
16-
uses: docker://ghcr.io/chubbyphp/ci-php82:latest
16+
uses: docker://ghcr.io/chubbyphp/ci-php83:latest
1717
env:
1818
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1919
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
20-
php83:
21-
name: PHP 8.3
20+
php84:
21+
name: PHP 8.4
2222
runs-on: ubuntu-24.04
2323
steps:
2424
- name: checkout
2525
uses: actions/checkout@v4
2626
- name: composer test
27-
uses: docker://ghcr.io/chubbyphp/ci-php83:latest
27+
uses: docker://ghcr.io/chubbyphp/ci-php84:latest
2828
env:
2929
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
31-
php84:
32-
name: PHP 8.4
31+
php85:
32+
name: PHP 8.5
3333
runs-on: ubuntu-24.04
3434
steps:
3535
- name: checkout
3636
uses: actions/checkout@v4
3737
- name: composer test
38-
uses: docker://ghcr.io/chubbyphp/ci-php84:latest
38+
uses: docker://ghcr.io/chubbyphp/ci-php85:latest
3939
env:
4040
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
$config = require __DIR__ . '/vendor/chubbyphp/chubbyphp-dev-helper/phpcs.php';
1414

1515
return (new PhpCsFixer\Config)
16+
->setUnsupportedPhpVersionAllowed(true)
1617
->setIndent($config['indent'])
1718
->setLineEnding($config['lineEnding'])
1819
->setRules($config['rules'])

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ A request handler adapter for swoole, using PSR-7, PSR-15 and PSR-17.
2525

2626
## Requirements
2727

28-
* php: ^8.2
29-
* [ext-swoole][2]: ^5.1.7|^6.0
30-
* [dflydev/fig-cookies][3]: ^3.1
28+
* php: ^8.3
29+
* [ext-swoole][2]: ^5.1.8|^6.1.3
30+
* [dflydev/fig-cookies][3]: ^3.2
3131
* [psr/http-factory][4]: ^1.1
3232
* [psr/http-message][5]: ^1.1|^2.0
3333
* [psr/http-server-handler][6]: ^1.0.2
@@ -38,7 +38,7 @@ A request handler adapter for swoole, using PSR-7, PSR-15 and PSR-17.
3838
Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-swoole-request-handler][1].
3939

4040
```sh
41-
composer require chubbyphp/chubbyphp-swoole-request-handler "^1.5"
41+
composer require chubbyphp/chubbyphp-swoole-request-handler "^1.6"
4242
```
4343

4444
## Usage

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.2",
21-
"ext-swoole": "^5.1.7|^6.0",
22-
"dflydev/fig-cookies": "^3.1",
20+
"php": "^8.3",
21+
"ext-swoole": "^5.1.8|^6.1.3",
22+
"dflydev/fig-cookies": "^3.2",
2323
"psr/http-factory": "^1.1",
2424
"psr/http-message": "^1.1|^2.0",
2525
"psr/http-server-handler": "^1.0.2",
2626
"psr/log": "^2.0|^3.0.2"
2727
},
2828
"require-dev": {
29-
"blackfire/php-sdk": "^2.5.7",
29+
"blackfire/php-sdk": "^2.5.10",
3030
"chubbyphp/chubbyphp-dev-helper": "dev-master",
31-
"chubbyphp/chubbyphp-mock": "^2.0",
32-
"infection/infection": "^0.29.12",
33-
"php-coveralls/php-coveralls": "^2.7",
31+
"chubbyphp/chubbyphp-mock": "^2.0.1",
32+
"infection/infection": "^0.31.9",
33+
"php-coveralls/php-coveralls": "^2.9",
3434
"phpstan/extension-installer": "^1.4.3",
35-
"phpstan/phpstan": "^2.1.6",
36-
"phpunit/phpunit": "^11.5.9",
37-
"swoole/ide-helper": "^5.1.7|^6.0"
35+
"phpstan/phpstan": "^2.1.32",
36+
"phpunit/phpunit": "^12.4.5",
37+
"swoole/ide-helper": "^5.1.8|^6.1.3"
3838
},
3939
"autoload": {
4040
"psr-4": {
@@ -59,7 +59,7 @@
5959
}
6060
},
6161
"scripts": {
62-
"fix:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache",
62+
"fix:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache",
6363
"test": [
6464
"@test:lint",
6565
"@test:unit",
@@ -68,7 +68,7 @@
6868
"@test:static-analysis",
6969
"@test:cs"
7070
],
71-
"test:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache",
71+
"test:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache",
7272
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=96 --verbose --coverage=build/phpunit",
7373
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-directory=build/phpunit",
7474
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",

src/Adapter/BlackfireOnRequestAdapter.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,12 @@
1717

1818
final class BlackfireOnRequestAdapter implements OnRequestInterface
1919
{
20-
private Configuration $config;
21-
22-
private LoggerInterface $logger;
23-
2420
public function __construct(
2521
private OnRequestInterface $onRequest,
2622
private Client $client,
27-
?Configuration $config = null,
28-
?LoggerInterface $logger = null
29-
) {
30-
$this->config = $config ?? new Configuration();
31-
$this->logger = $logger ?? new NullLogger();
32-
}
23+
private Configuration $config = new Configuration(),
24+
private LoggerInterface $logger = new NullLogger()
25+
) {}
3326

3427
public function __invoke(SwooleRequest $swooleRequest, SwooleResponse $swooleResponse): void
3528
{

tests/Unit/Adapter/BlackfireOnRequestAdapterTest.php

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Blackfire\Client;
88
use Blackfire\Exception\LogicException;
9+
use Blackfire\Exception\RuntimeException;
910
use Blackfire\Probe;
1011
use Blackfire\Profile\Configuration;
1112
use Chubbyphp\Mock\MockMethod\WithCallback;
@@ -121,7 +122,7 @@ public function testInvokeWithConfigAndWithLogger(): void
121122
}
122123

123124
#[DoesNotPerformAssertions]
124-
public function testInvokeWithExceptionOnCreateProbe(): void
125+
public function testInvokeWithLogicExceptionOnCreateProbe(): void
125126
{
126127
$builder = new MockObjectBuilder();
127128

@@ -157,7 +158,43 @@ public function testInvokeWithExceptionOnCreateProbe(): void
157158
}
158159

159160
#[DoesNotPerformAssertions]
160-
public function testInvokeWithExceptionOnProbeEnd(): void
161+
public function testInvokeWithRuntimeExceptionOnCreateProbe(): void
162+
{
163+
$builder = new MockObjectBuilder();
164+
165+
/** @var SwooleRequest $swooleRequest */
166+
$swooleRequest = $builder->create(SwooleRequest::class, []);
167+
$swooleRequest->header['x-blackfire-query'] = 'swoole';
168+
169+
/** @var SwooleResponse $swooleResponse */
170+
$swooleResponse = $builder->create(SwooleResponse::class, []);
171+
172+
/** @var OnRequestInterface $onRequest */
173+
$onRequest = $builder->create(OnRequestInterface::class, [
174+
new WithoutReturn('__invoke', [$swooleRequest, $swooleResponse]),
175+
]);
176+
177+
/** @var Configuration $config */
178+
$config = $builder->create(Configuration::class, []);
179+
180+
$exception = new RuntimeException('Something went wrong');
181+
182+
/** @var Client $client */
183+
$client = $builder->create(Client::class, [
184+
new WithException('createProbe', [$config, true], $exception),
185+
]);
186+
187+
/** @var LoggerInterface $logger */
188+
$logger = $builder->create(LoggerInterface::class, [
189+
new WithoutReturn('error', ['Blackfire exception: Something went wrong', []]),
190+
]);
191+
192+
$adapter = new BlackfireOnRequestAdapter($onRequest, $client, $config, $logger);
193+
$adapter($swooleRequest, $swooleResponse);
194+
}
195+
196+
#[DoesNotPerformAssertions]
197+
public function testInvokeWithLogicExceptionOnProbeEnd(): void
161198
{
162199
$builder = new MockObjectBuilder();
163200

@@ -195,4 +232,44 @@ public function testInvokeWithExceptionOnProbeEnd(): void
195232
$adapter = new BlackfireOnRequestAdapter($onRequest, $client, $config, $logger);
196233
$adapter($swooleRequest, $swooleResponse);
197234
}
235+
236+
#[DoesNotPerformAssertions]
237+
public function testInvokeWithRuntimeExceptionOnProbeEnd(): void
238+
{
239+
$builder = new MockObjectBuilder();
240+
241+
/** @var SwooleRequest $swooleRequest */
242+
$swooleRequest = $builder->create(SwooleRequest::class, []);
243+
$swooleRequest->header['x-blackfire-query'] = 'swoole';
244+
245+
/** @var SwooleResponse $swooleResponse */
246+
$swooleResponse = $builder->create(SwooleResponse::class, []);
247+
248+
/** @var OnRequestInterface $onRequest */
249+
$onRequest = $builder->create(OnRequestInterface::class, [
250+
new WithoutReturn('__invoke', [$swooleRequest, $swooleResponse]),
251+
]);
252+
253+
/** @var Configuration $config */
254+
$config = $builder->create(Configuration::class, []);
255+
256+
/** @var Probe $probe */
257+
$probe = $builder->create(Probe::class, []);
258+
259+
$exception = new RuntimeException('Something went wrong');
260+
261+
/** @var Client $client */
262+
$client = $builder->create(Client::class, [
263+
new WithReturn('createProbe', [$config, true], $probe),
264+
new WithException('endProbe', [$probe], $exception),
265+
]);
266+
267+
/** @var LoggerInterface $logger */
268+
$logger = $builder->create(LoggerInterface::class, [
269+
new WithoutReturn('error', ['Blackfire exception: Something went wrong', []]),
270+
]);
271+
272+
$adapter = new BlackfireOnRequestAdapter($onRequest, $client, $config, $logger);
273+
$adapter($swooleRequest, $swooleResponse);
274+
}
198275
}

0 commit comments

Comments
 (0)