Skip to content

Commit ac0094a

Browse files
author
Dominik Zogg
committed
php 8.0 min version
1 parent 0ba6716 commit ac0094a

File tree

10 files changed

+41
-91
lines changed

10 files changed

+41
-91
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,6 @@ on:
77
- cron: '0 0 * * *'
88

99
jobs:
10-
php74-min:
11-
name: PHP 7.4 (--prefer-lowest)
12-
runs-on: ubuntu-20.04
13-
steps:
14-
- name: checkout
15-
uses: actions/checkout@v2
16-
- name: composer test
17-
uses: docker://chubbyphp/ci-php74:latest
18-
env:
19-
COMPOSER_ARGS: "--prefer-lowest"
20-
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
22-
php74:
23-
name: PHP 7.4
24-
runs-on: ubuntu-20.04
25-
steps:
26-
- name: checkout
27-
uses: actions/checkout@v2
28-
- name: composer test
29-
uses: docker://chubbyphp/ci-php74:latest
30-
env:
31-
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
3310
php80:
3411
name: PHP 8.0
3512
runs-on: ubuntu-20.04

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2021 Dominik Zogg
1+
Copyright (c) 2022 Dominik Zogg
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

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

2626
## Requirements
2727

28-
* php: ^7.4|^8.0
28+
* php: ^8.0
2929
* [psr/http-factory][2]: ^1.0.1
3030
* [psr/http-message][3]: ^1.0.1
3131
* [psr/http-server-handler][4]: ^1.0.1
32-
* [psr/log][5]: ^1.1.4
33-
* [workerman/workerman][6]: ^4.0.24
32+
* [psr/log][5]: ^1.1.4|^2.0|^3.0
33+
* [workerman/workerman][6]: ^4.0.30
3434

3535
## Installation
3636

3737
Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-workerman-request-handler][1].
3838

3939
```sh
40-
composer require chubbyphp/chubbyphp-workerman-request-handler "^1.1"
40+
composer require chubbyphp/chubbyphp-workerman-request-handler "^1.2"
4141
```
4242

4343
## Usage
@@ -131,7 +131,7 @@ $http->onMessage = $onMessage;
131131

132132
## Copyright
133133

134-
Dominik Zogg 2021
134+
Dominik Zogg 2022
135135

136136
[1]: https://packagist.org/packages/chubbyphp/chubbyphp-workerman-request-handler
137137
[2]: https://packagist.org/packages/psr/http-factory

composer.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.4|^8.0",
20+
"php": "^8.0",
2121
"psr/http-factory": "^1.0.1",
2222
"psr/http-message": "^1.0.1",
2323
"psr/http-server-handler": "^1.0.1",
24-
"psr/log": "^1.1.4",
25-
"workerman/workerman": "^4.0.24"
24+
"psr/log": "^1.1.4|^2.0|^3.0",
25+
"workerman/workerman": "^4.0.30"
2626
},
2727
"require-dev": {
28-
"blackfire/php-sdk": "^1.23",
28+
"blackfire/php-sdk": "^1.29",
2929
"chubbyphp/chubbyphp-dev-helper": "dev-master",
3030
"chubbyphp/chubbyphp-mock": "^1.6.1",
31-
"infection/infection": "^0.25.3",
32-
"php-coveralls/php-coveralls": "^2.5.1",
31+
"infection/infection": "^0.26.5",
32+
"php-coveralls/php-coveralls": "^2.5.2",
3333
"phploc/phploc": "^7.0.2",
3434
"phpstan/extension-installer": "^1.1",
35-
"phpstan/phpstan": "^1.1.2",
36-
"phpunit/phpunit": "^9.5.10"
35+
"phpstan/phpstan": "^1.4.8",
36+
"phpunit/phpunit": "^9.5.17"
3737
},
3838
"autoload": {
3939
"psr-4": { "Chubbyphp\\WorkermanRequestHandler\\": "src/" }
@@ -42,11 +42,15 @@
4242
"psr-4": { "Chubbyphp\\Tests\\WorkermanRequestHandler\\": "tests/" }
4343
},
4444
"config": {
45-
"sort-packages": true
45+
"sort-packages": true,
46+
"allow-plugins": {
47+
"infection/extension-installer": true,
48+
"phpstan/extension-installer": true
49+
}
4650
},
4751
"extra": {
4852
"branch-alias": {
49-
"dev-master": "1.1-dev"
53+
"dev-master": "1.2-dev"
5054
}
5155
},
5256
"scripts": {
@@ -64,7 +68,7 @@
6468
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=100 --verbose --coverage=build/phpunit",
6569
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-result-file=build/phpunit/result.cache",
6670
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
67-
"test:loc": "mkdir -p build && vendor/bin/phploc src --verbose | tee build/phploc.log",
71+
"test:loc": "mkdir -p build && vendor/bin/phploc src | tee build/phploc.log",
6872
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=7 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
6973
"test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-result-file=build/phpunit/result.cache"
7074
}

infection.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
},
77
"timeout": 10,
88
"logs": {
9-
"text": "build/phpinfection.log",
10-
"badge": {
11-
"branch": "master"
9+
"text": "build/phpinfection/infection.log",
10+
"html": "build/phpinfection/infection.html",
11+
"json": "build/phpinfection/infection.json",
12+
"summary": "build/phpinfection/summary.log",
13+
"stryker": {
14+
"report": "master"
1215
}
1316
},
1417
"mutators": {

src/Adapter/BlackfireOnMessageAdapter.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@
1616

1717
final class BlackfireOnMessageAdapter implements OnMessageInterface
1818
{
19-
private OnMessageInterface $onRequest;
20-
21-
private Client $client;
22-
2319
private Configuration $config;
2420

2521
private LoggerInterface $logger;
2622

2723
public function __construct(
28-
OnMessageInterface $onRequest,
29-
Client $client,
24+
private OnMessageInterface $onRequest,
25+
private Client $client,
3026
?Configuration $config = null,
3127
?LoggerInterface $logger = null
3228
) {
33-
$this->onRequest = $onRequest;
34-
$this->client = $client;
3529
$this->config = $config ?? new Configuration();
3630
$this->logger = $logger ?? new NullLogger();
3731
}
@@ -48,7 +42,7 @@ public function __invoke(WorkermanTcpConnection $workermanTcpConnection, Workerm
4842

4943
$this->onRequest->__invoke($workermanTcpConnection, $workermanRequest);
5044

51-
if (null === $probe) {
45+
if (!$probe instanceof Probe) {
5246
return;
5347
}
5448

src/Adapter/NewRelicOnMessageAdapter.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@
1010

1111
final class NewRelicOnMessageAdapter implements OnMessageInterface
1212
{
13-
private OnMessageInterface $onRequest;
14-
15-
private string $appname;
16-
17-
public function __construct(OnMessageInterface $onRequest, string $appname)
13+
public function __construct(private OnMessageInterface $onRequest, private string $appname)
1814
{
19-
$this->onRequest = $onRequest;
20-
$this->appname = $appname;
2115
}
2216

2317
public function __invoke(WorkermanTcpConnection $workermanTcpConnection, WorkermanRequest $workermanRequest): void

src/OnMessage.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,11 @@
1010

1111
final class OnMessage implements OnMessageInterface
1212
{
13-
private PsrRequestFactoryInterface $psrRequestFactory;
14-
15-
private WorkermanResponseEmitterInterface $workermanResponseEmitter;
16-
17-
private RequestHandlerInterface $requestHander;
18-
1913
public function __construct(
20-
PsrRequestFactoryInterface $psrRequestFactory,
21-
WorkermanResponseEmitterInterface $workermanResponseEmitter,
22-
RequestHandlerInterface $requestHander
14+
private PsrRequestFactoryInterface $psrRequestFactory,
15+
private WorkermanResponseEmitterInterface $workermanResponseEmitter,
16+
private RequestHandlerInterface $requestHander
2317
) {
24-
$this->psrRequestFactory = $psrRequestFactory;
25-
$this->workermanResponseEmitter = $workermanResponseEmitter;
26-
$this->requestHander = $requestHander;
2718
}
2819

2920
public function __invoke(WorkermanTcpConnection $workermanTcpConnection, WorkermanRequest $workermanRequest): void

src/PsrRequestFactory.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@
1313

1414
final class PsrRequestFactory implements PsrRequestFactoryInterface
1515
{
16-
private ServerRequestFactoryInterface $serverRequestFactory;
17-
18-
private StreamFactoryInterface $streamFactory;
19-
20-
private UploadedFileFactoryInterface $uploadedFileFactory;
21-
2216
public function __construct(
23-
ServerRequestFactoryInterface $serverRequestFactory,
24-
StreamFactoryInterface $streamFactory,
25-
UploadedFileFactoryInterface $uploadedFileFactory
17+
private ServerRequestFactoryInterface $serverRequestFactory,
18+
private StreamFactoryInterface $streamFactory,
19+
private UploadedFileFactoryInterface $uploadedFileFactory
2620
) {
27-
$this->serverRequestFactory = $serverRequestFactory;
28-
$this->streamFactory = $streamFactory;
29-
$this->uploadedFileFactory = $uploadedFileFactory;
3021
}
3122

3223
public function create(WorkermanRequest $workermanRequest): ServerRequestInterface
@@ -65,11 +56,7 @@ private function uploadedFiles(array $files): array
6556
{
6657
$uploadedFiles = [];
6758
foreach ($files as $key => $file) {
68-
if (isset($file['tmp_name'])) {
69-
$uploadedFiles[$key] = $this->createUploadedFile($file);
70-
} else {
71-
$uploadedFiles[$key] = $this->uploadedFiles($file);
72-
}
59+
$uploadedFiles[$key] = isset($file['tmp_name']) ? $this->createUploadedFile($file) : $this->uploadedFiles($file);
7360
}
7461

7562
return $uploadedFiles;
@@ -82,7 +69,7 @@ private function createUploadedFile(array $file): UploadedFileInterface
8269
{
8370
try {
8471
$stream = $this->streamFactory->createStreamFromFile($file['tmp_name']);
85-
} catch (\RuntimeException $exception) {
72+
} catch (\RuntimeException) {
8673
$stream = $this->streamFactory->createStream();
8774
}
8875

tests/Unit/PsrRequestFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testInvoke(): void
4848
'type' => 'application/pdf',
4949
'tmp_name' => '/tmp/php9875842a',
5050
'error' => 0,
51-
'size' => 1048576,
51+
'size' => 1_048_576,
5252
],
5353
'certificates' => [
5454
[
@@ -108,7 +108,7 @@ public function testInvoke(): void
108108
/** @var MockObject|UploadedFileFactoryInterface $uploadedFileFactory */
109109
$uploadedFileFactory = $this->getMockByCalls(UploadedFileFactoryInterface::class, [
110110
Call::create('createUploadedFile')
111-
->with($uploadedFileStream1, 1048576, 0, 'CV.pdf', 'application/pdf')
111+
->with($uploadedFileStream1, 1_048_576, 0, 'CV.pdf', 'application/pdf')
112112
->willReturn($uploadedFile1),
113113
Call::create('createUploadedFile')
114114
->with($uploadedFileStream2, 389120, 0, 'Advanced PHP 2017.pdf', 'application/pdf')

0 commit comments

Comments
 (0)