Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
php 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Dec 30, 2023
1 parent 42efb11 commit 36ac9a2
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 106 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ on:
- cron: '0 0 * * *'

jobs:
php80:
name: PHP 8.0
runs-on: ubuntu-20.04
php81:
name: PHP 8.1
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: composer test
uses: docker://chubbyphp/ci-php80:latest
uses: docker://chubbyphp/ci-php81:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php81:
name: PHP 8.1
runs-on: ubuntu-20.04
php82:
name: PHP 8.2
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: composer test
uses: docker://chubbyphp/ci-php81:latest
uses: docker://chubbyphp/ci-php82:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php82:
name: PHP 8.2
runs-on: ubuntu-20.04
php83:
name: PHP 8.3
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: composer test
uses: docker://chubbyphp/ci-php82:latest
uses: docker://chubbyphp/ci-php83:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.idea/
.phpunit.cache
.vscode/
build/
composer.lock
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/chubbyphp/chubbyphp-api-http/workflows/CI/badge.svg?branch=master)](https://github.com/chubbyphp/chubbyphp-api-http/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/chubbyphp-api-http/badge.svg?branch=master)](https://coveralls.io/github/chubbyphp/chubbyphp-api-http?branch=master)
[![Infection MSI](https://badge.stryker-mutator.io/github.com/chubbyphp/chubbyphp-api-http/master)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-api-http/master)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fchubbyphp-api-http%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-api-http/master)[![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-api-http/v/stable.png)](https://packagist.org/packages/chubbyphp/chubbyphp-api-http)
[![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-api-http/v/stable.png)](https://packagist.org/packages/chubbyphp/chubbyphp-api-http)
[![Total Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-api-http/downloads.png)](https://packagist.org/packages/chubbyphp/chubbyphp-api-http)
[![Monthly Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-api-http/d/monthly)](https://packagist.org/packages/chubbyphp/chubbyphp-api-http)
Expand All @@ -25,22 +25,22 @@ A simple http handler implementation for API.

## Requirements

* php: ^8.0
* chubbyphp/chubbyphp-deserialization: ^3.5.1
* chubbyphp/chubbyphp-http-exception: ^1.0.1
* chubbyphp/chubbyphp-negotiation: ^1.9
* chubbyphp/chubbyphp-serialization: ^3.3.1
* psr/http-factory: ^1.0.1
* psr/http-message: ^1.0.1
* psr/http-server-middleware: ^1.0.1
* psr/log: ^1.1.4|^2.0|^3.0
* php: ^8.1
* chubbyphp/chubbyphp-deserialization: ^4.0
* chubbyphp/chubbyphp-http-exception: ^1.1
* chubbyphp/chubbyphp-negotiation: ^2.0
* chubbyphp/chubbyphp-serialization: ^4.0
* psr/http-factory: ^1.0.2
* psr/http-message: ^1.1|^2.0
* psr/http-server-middleware: ^1.0.2
* psr/log: ^2.0|^3.0

## Installation

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

```sh
composer require chubbyphp/chubbyphp-api-http "^5.0"
composer require chubbyphp/chubbyphp-api-http "^6.0"
```

## Usage
Expand Down
39 changes: 18 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,26 @@
}
],
"require": {
"php": "^8.0",
"chubbyphp/chubbyphp-deserialization": "^3.5.1",
"chubbyphp/chubbyphp-http-exception": "^1.0.1",
"chubbyphp/chubbyphp-negotiation": "^1.9",
"chubbyphp/chubbyphp-serialization": "^3.3.1",
"psr/http-factory": "^1.0.1",
"psr/http-message": "^1.0.1",
"psr/http-server-middleware": "^1.0.1",
"psr/log": "^1.1.4|^2.0|^3.0"
"php": "^8.1",
"chubbyphp/chubbyphp-deserialization": "^4.0",
"chubbyphp/chubbyphp-http-exception": "^1.1",
"chubbyphp/chubbyphp-negotiation": "^2.0",
"chubbyphp/chubbyphp-serialization": "^4.0",
"psr/http-factory": "^1.0.2",
"psr/http-message": "^1.1|^2.0",
"psr/http-server-middleware": "^1.0.2",
"psr/log": "^2.0|^3.0"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^2.1",
"chubbyphp/chubbyphp-container": "^2.2",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.2",
"chubbyphp/chubbyphp-mock": "^1.6.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.4.8",
"phpunit/phpunit": "^9.5.17",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.3",
"chubbyphp/chubbyphp-mock": "^1.7",
"infection/infection": "^0.27.9",
"php-coveralls/php-coveralls": "^2.7",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.50",
"phpunit/phpunit": "^10.5.3",
"pimple/pimple": "^3.5",
"psr/container": "^2.0.2"
},
Expand All @@ -49,7 +48,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-master": "6.0-dev"
}
},
"scripts": {
Expand All @@ -60,14 +59,12 @@
"@test:integration",
"@test:infection",
"@test:static-analysis",
"@test:loc",
"@test:cs"
],
"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",
"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 | tee build/phploc.log",
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=8 --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
39 changes: 15 additions & 24 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
executionOrder="random"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" executionOrder="random" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
14 changes: 3 additions & 11 deletions src/Manager/RequestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,19 @@

final class RequestManager implements RequestManagerInterface
{
public function __construct(private DeserializerInterface $deserializer)
{
}
public function __construct(private DeserializerInterface $deserializer) {}

/**
* @param object|string $object
*/
public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
object|string $object,
?DenormalizerContextInterface $context = null
): object {
return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
}

/**
* @param object|string $object
*/
public function getDataFromRequestBody(
ServerRequestInterface $request,
$object,
object|string $object,
string $contentType,
?DenormalizerContextInterface $context = null
): object {
Expand Down
10 changes: 2 additions & 8 deletions src/Manager/RequestManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@

interface RequestManagerInterface
{
/**
* @param object|string $object
*/
public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
object|string $object,
?DenormalizerContextInterface $context = null
): object;

/**
* @param object|string $object
*/
public function getDataFromRequestBody(
ServerRequestInterface $request,
$object,
object|string $object,
string $contentType,
?DenormalizerContextInterface $context = null
): object;
Expand Down
3 changes: 1 addition & 2 deletions src/Manager/ResponseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ final class ResponseManager implements ResponseManagerInterface
public function __construct(
private ResponseFactoryInterface $responseFactory,
private SerializerInterface $serializer
) {
}
) {}

public function create(
object $object,
Expand Down
3 changes: 1 addition & 2 deletions src/Middleware/AcceptAndContentTypeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function __construct(
private AcceptNegotiatorInterface $acceptNegotiator,
private ContentTypeNegotiatorInterface $contentTypeNegotiator,
private ResponseManagerInterface $responseManager
) {
}
) {}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
Expand Down
8 changes: 5 additions & 3 deletions tests/Unit/Manager/ResponseManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testCreateWithDefaults(): void

/** @var MockObject|StreamInterface $body */
$body = $this->getMockByCalls(StreamInterface::class, [
Call::create('write')->with($bodyString),
Call::create('write')->with($bodyString)->willReturn(\strlen($bodyString)),
]);

/** @var MockObject|Response $response */
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testCreateWithoutDefaults(): void

/** @var MockObject|StreamInterface $body */
$body = $this->getMockByCalls(StreamInterface::class, [
Call::create('write')->with($bodyString),
Call::create('write')->with($bodyString)->willReturn(\strlen($bodyString)),
]);

/** @var MockObject|Response $response */
Expand Down Expand Up @@ -174,11 +174,13 @@ public function testCreateRedirectWithoutDefaults(): void

public function testCreateFromHttpException(): void
{
$bodyString = '{"title":"Method Not Allowed"}';

$httpException = HttpException::createMethodNotAllowed(['allowedMethods' => ['PATCH', 'PUT']]);

/** @var MockObject|StreamInterface $body */
$body = $this->getMockByCalls(StreamInterface::class, [
Call::create('write')->with('{"title":"Method Not Allowed"}'),
Call::create('write')->with($bodyString)->willReturn(\strlen($bodyString)),
]);

/** @var MockObject|Response $response */
Expand Down
8 changes: 2 additions & 6 deletions tests/Unit/Middleware/AcceptAndContentTypeMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ public function testWithAccept(): void
$response = $this->getMockByCalls(ResponseInterface::class, []);

$requestHandler = new class($response) implements RequestHandlerInterface {
public function __construct(private ResponseInterface $response)
{
}
public function __construct(private ResponseInterface $response) {}

public function handle(ServerRequestInterface $request): ResponseInterface
{
Expand Down Expand Up @@ -298,9 +296,7 @@ public function testWithContentType(): void
$response = $this->getMockByCalls(ResponseInterface::class, []);

$requestHandler = new class($response) implements RequestHandlerInterface {
public function __construct(private ResponseInterface $response)
{
}
public function __construct(private ResponseInterface $response) {}

public function handle(ServerRequestInterface $request): ResponseInterface
{
Expand Down
8 changes: 2 additions & 6 deletions tests/Unit/Middleware/ApiExceptionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public function testWithoutExceptionWithDebugWithLogger(): void
$response = $this->getMockByCalls(ResponseInterface::class);

$requestHandler = new class($response) implements RequestHandlerInterface {
public function __construct(private ResponseInterface $response)
{
}
public function __construct(private ResponseInterface $response) {}

public function handle(ServerRequestInterface $request): ResponseInterface
{
Expand Down Expand Up @@ -130,9 +128,7 @@ public function testWithHttpExceptionWithDebugWithLogger(): void
$response = $this->getMockByCalls(ResponseInterface::class);

$requestHandler = new class($httpException) implements RequestHandlerInterface {
public function __construct(private HttpExceptionInterface $httpException)
{
}
public function __construct(private HttpExceptionInterface $httpException) {}

public function handle(ServerRequestInterface $request): ResponseInterface
{
Expand Down

0 comments on commit 36ac9a2

Please sign in to comment.