Skip to content

Commit

Permalink
php 8.0 min version
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Mar 6, 2022
1 parent 0ba6716 commit ac0094a
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 91 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,6 @@ on:
- cron: '0 0 * * *'

jobs:
php74-min:
name: PHP 7.4 (--prefer-lowest)
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: composer test
uses: docker://chubbyphp/ci-php74:latest
env:
COMPOSER_ARGS: "--prefer-lowest"
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php74:
name: PHP 7.4
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: composer test
uses: docker://chubbyphp/ci-php74:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php80:
name: PHP 8.0
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Dominik Zogg
Copyright (c) 2022 Dominik Zogg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ A request handler adapter for workerman, using PSR-7, PSR-15 and PSR-17.

## Requirements

* php: ^7.4|^8.0
* php: ^8.0
* [psr/http-factory][2]: ^1.0.1
* [psr/http-message][3]: ^1.0.1
* [psr/http-server-handler][4]: ^1.0.1
* [psr/log][5]: ^1.1.4
* [workerman/workerman][6]: ^4.0.24
* [psr/log][5]: ^1.1.4|^2.0|^3.0
* [workerman/workerman][6]: ^4.0.30

## Installation

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

```sh
composer require chubbyphp/chubbyphp-workerman-request-handler "^1.1"
composer require chubbyphp/chubbyphp-workerman-request-handler "^1.2"
```

## Usage
Expand Down Expand Up @@ -131,7 +131,7 @@ $http->onMessage = $onMessage;

## Copyright

Dominik Zogg 2021
Dominik Zogg 2022

[1]: https://packagist.org/packages/chubbyphp/chubbyphp-workerman-request-handler
[2]: https://packagist.org/packages/psr/http-factory
Expand Down
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"psr/http-factory": "^1.0.1",
"psr/http-message": "^1.0.1",
"psr/http-server-handler": "^1.0.1",
"psr/log": "^1.1.4",
"workerman/workerman": "^4.0.24"
"psr/log": "^1.1.4|^2.0|^3.0",
"workerman/workerman": "^4.0.30"
},
"require-dev": {
"blackfire/php-sdk": "^1.23",
"blackfire/php-sdk": "^1.29",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-mock": "^1.6.1",
"infection/infection": "^0.25.3",
"php-coveralls/php-coveralls": "^2.5.1",
"infection/infection": "^0.26.5",
"php-coveralls/php-coveralls": "^2.5.2",
"phploc/phploc": "^7.0.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1.2",
"phpunit/phpunit": "^9.5.10"
"phpstan/phpstan": "^1.4.8",
"phpunit/phpunit": "^9.5.17"
},
"autoload": {
"psr-4": { "Chubbyphp\\WorkermanRequestHandler\\": "src/" }
Expand All @@ -42,11 +42,15 @@
"psr-4": { "Chubbyphp\\Tests\\WorkermanRequestHandler\\": "tests/" }
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
"dev-master": "1.2-dev"
}
},
"scripts": {
Expand All @@ -64,7 +68,7 @@
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=100 --verbose --coverage=build/phpunit",
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-result-file=build/phpunit/result.cache",
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
"test:loc": "mkdir -p build && vendor/bin/phploc src --verbose | tee build/phploc.log",
"test:loc": "mkdir -p build && vendor/bin/phploc src | tee build/phploc.log",
"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'",
"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"
}
Expand Down
9 changes: 6 additions & 3 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
},
"timeout": 10,
"logs": {
"text": "build/phpinfection.log",
"badge": {
"branch": "master"
"text": "build/phpinfection/infection.log",
"html": "build/phpinfection/infection.html",
"json": "build/phpinfection/infection.json",
"summary": "build/phpinfection/summary.log",
"stryker": {
"report": "master"
}
},
"mutators": {
Expand Down
12 changes: 3 additions & 9 deletions src/Adapter/BlackfireOnMessageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@

final class BlackfireOnMessageAdapter implements OnMessageInterface
{
private OnMessageInterface $onRequest;

private Client $client;

private Configuration $config;

private LoggerInterface $logger;

public function __construct(
OnMessageInterface $onRequest,
Client $client,
private OnMessageInterface $onRequest,
private Client $client,
?Configuration $config = null,
?LoggerInterface $logger = null
) {
$this->onRequest = $onRequest;
$this->client = $client;
$this->config = $config ?? new Configuration();
$this->logger = $logger ?? new NullLogger();
}
Expand All @@ -48,7 +42,7 @@ public function __invoke(WorkermanTcpConnection $workermanTcpConnection, Workerm

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

if (null === $probe) {
if (!$probe instanceof Probe) {
return;
}

Expand Down
8 changes: 1 addition & 7 deletions src/Adapter/NewRelicOnMessageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@

final class NewRelicOnMessageAdapter implements OnMessageInterface
{
private OnMessageInterface $onRequest;

private string $appname;

public function __construct(OnMessageInterface $onRequest, string $appname)
public function __construct(private OnMessageInterface $onRequest, private string $appname)
{
$this->onRequest = $onRequest;
$this->appname = $appname;
}

public function __invoke(WorkermanTcpConnection $workermanTcpConnection, WorkermanRequest $workermanRequest): void
Expand Down
15 changes: 3 additions & 12 deletions src/OnMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@

final class OnMessage implements OnMessageInterface
{
private PsrRequestFactoryInterface $psrRequestFactory;

private WorkermanResponseEmitterInterface $workermanResponseEmitter;

private RequestHandlerInterface $requestHander;

public function __construct(
PsrRequestFactoryInterface $psrRequestFactory,
WorkermanResponseEmitterInterface $workermanResponseEmitter,
RequestHandlerInterface $requestHander
private PsrRequestFactoryInterface $psrRequestFactory,
private WorkermanResponseEmitterInterface $workermanResponseEmitter,
private RequestHandlerInterface $requestHander
) {
$this->psrRequestFactory = $psrRequestFactory;
$this->workermanResponseEmitter = $workermanResponseEmitter;
$this->requestHander = $requestHander;
}

public function __invoke(WorkermanTcpConnection $workermanTcpConnection, WorkermanRequest $workermanRequest): void
Expand Down
23 changes: 5 additions & 18 deletions src/PsrRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,11 @@

final class PsrRequestFactory implements PsrRequestFactoryInterface
{
private ServerRequestFactoryInterface $serverRequestFactory;

private StreamFactoryInterface $streamFactory;

private UploadedFileFactoryInterface $uploadedFileFactory;

public function __construct(
ServerRequestFactoryInterface $serverRequestFactory,
StreamFactoryInterface $streamFactory,
UploadedFileFactoryInterface $uploadedFileFactory
private ServerRequestFactoryInterface $serverRequestFactory,
private StreamFactoryInterface $streamFactory,
private UploadedFileFactoryInterface $uploadedFileFactory
) {
$this->serverRequestFactory = $serverRequestFactory;
$this->streamFactory = $streamFactory;
$this->uploadedFileFactory = $uploadedFileFactory;
}

public function create(WorkermanRequest $workermanRequest): ServerRequestInterface
Expand Down Expand Up @@ -65,11 +56,7 @@ private function uploadedFiles(array $files): array
{
$uploadedFiles = [];
foreach ($files as $key => $file) {
if (isset($file['tmp_name'])) {
$uploadedFiles[$key] = $this->createUploadedFile($file);
} else {
$uploadedFiles[$key] = $this->uploadedFiles($file);
}
$uploadedFiles[$key] = isset($file['tmp_name']) ? $this->createUploadedFile($file) : $this->uploadedFiles($file);
}

return $uploadedFiles;
Expand All @@ -82,7 +69,7 @@ private function createUploadedFile(array $file): UploadedFileInterface
{
try {
$stream = $this->streamFactory->createStreamFromFile($file['tmp_name']);
} catch (\RuntimeException $exception) {
} catch (\RuntimeException) {
$stream = $this->streamFactory->createStream();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/PsrRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testInvoke(): void
'type' => 'application/pdf',
'tmp_name' => '/tmp/php9875842a',
'error' => 0,
'size' => 1048576,
'size' => 1_048_576,
],
'certificates' => [
[
Expand Down Expand Up @@ -108,7 +108,7 @@ public function testInvoke(): void
/** @var MockObject|UploadedFileFactoryInterface $uploadedFileFactory */
$uploadedFileFactory = $this->getMockByCalls(UploadedFileFactoryInterface::class, [
Call::create('createUploadedFile')
->with($uploadedFileStream1, 1048576, 0, 'CV.pdf', 'application/pdf')
->with($uploadedFileStream1, 1_048_576, 0, 'CV.pdf', 'application/pdf')
->willReturn($uploadedFile1),
Call::create('createUploadedFile')
->with($uploadedFileStream2, 389120, 0, 'Advanced PHP 2017.pdf', 'application/pdf')
Expand Down

0 comments on commit ac0094a

Please sign in to comment.