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 640562f commit 7d39a1e
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 225 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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ A simple http handler implementation for API.

## Requirements

* php: ^7.4|^8.0
* chubbyphp/chubbyphp-deserialization: ^3.0
* chubbyphp/chubbyphp-negotiation: ^1.7
* chubbyphp/chubbyphp-serialization: ^3.0
* php: ^8.0
* chubbyphp/chubbyphp-deserialization: ^3.4.1
* chubbyphp/chubbyphp-negotiation: ^1.9
* chubbyphp/chubbyphp-serialization: ^3.2
* psr/http-factory: ^1.0.1
* psr/http-message: ^1.0.1
* psr/http-server-middleware: ^1.0.1
* psr/log: ^1.1.3
* psr/log: ^1.1.4|^2.0|^3.0

## Installation

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

```sh
composer require chubbyphp/chubbyphp-api-http "^4.1"
composer require chubbyphp/chubbyphp-api-http "^4.2"
```

## Usage
Expand All @@ -59,7 +59,7 @@ composer require chubbyphp/chubbyphp-api-http "^4.1"

## Copyright

Dominik Zogg 2021
Dominik Zogg 2022

[1]: https://packagist.org/packages/chubbyphp/chubbyphp-api-http
[2]: doc/ApiProblem/ApiProblem.md
Expand Down
36 changes: 20 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
}
],
"require": {
"php": "^7.4|^8.0",
"chubbyphp/chubbyphp-deserialization": "^3.0",
"chubbyphp/chubbyphp-negotiation": "^1.7",
"chubbyphp/chubbyphp-serialization": "^3.0",
"php": "^8.0",
"chubbyphp/chubbyphp-deserialization": "^3.4.1",
"chubbyphp/chubbyphp-negotiation": "^1.9",
"chubbyphp/chubbyphp-serialization": "^3.2",
"psr/http-factory": "^1.0.1",
"psr/http-message": "^1.0.1",
"psr/http-server-middleware": "^1.0.1",
"psr/log": "^1.1.3"
"psr/log": "^1.1.4|^2.0|^3.0"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^1.4|^2.0",
"chubbyphp/chubbyphp-container": "^2.1",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.1.1",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.2",
"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",
"pimple/pimple": "^3.4",
"psr/container": "^1.1.1|^2.0.1"
"phpstan/phpstan": "^1.4.8",
"phpunit/phpunit": "^9.5.17",
"pimple/pimple": "^3.5",
"psr/container": "^2.0.2"
},
"autoload": {
"psr-4": { "Chubbyphp\\ApiHttp\\": "src/" }
Expand All @@ -40,11 +40,15 @@
"psr-4": { "Chubbyphp\\Tests\\ApiHttp\\": "tests/" }
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.2-dev"
}
},
"scripts": {
Expand All @@ -59,7 +63,7 @@
"@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=98 --verbose --coverage=build/phpunit",
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=63 --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",
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
25 changes: 5 additions & 20 deletions src/ApiProblem/AbstractApiProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,13 @@

abstract class AbstractApiProblem implements ApiProblemInterface
{
protected string $type;

protected int $status;

protected string $title;

protected ?string $detail;

protected ?string $instance;

public function __construct(
string $type,
int $status,
string $title,
?string $detail = null,
?string $instance = null
protected string $type,
protected int $status,
protected string $title,
protected ?string $detail = null,
protected ?string $instance = null
) {
$this->type = $type;
$this->status = $status;
$this->title = $title;
$this->detail = $detail;
$this->instance = $instance;
}

public function getType(): string
Expand Down
9 changes: 1 addition & 8 deletions src/ApiProblem/ClientError/BadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

final class BadRequest extends AbstractApiProblem
{
/**
* @var array<int, array<mixed>>
*/
private array $invalidParameters = [];

/**
* @param array<int, array<mixed>> $invalidParameters
*/
public function __construct(array $invalidParameters, ?string $detail = null, ?string $instance = null)
public function __construct(private array $invalidParameters, ?string $detail = null, ?string $instance = null)
{
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.1',
Expand All @@ -25,8 +20,6 @@ public function __construct(array $invalidParameters, ?string $detail = null, ?s
$detail,
$instance
);

$this->invalidParameters = $invalidParameters;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/ApiProblem/ClientError/ExpectationFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

final class ExpectationFailed extends AbstractApiProblem
{
/**
* @var array<int, string>
*/
private array $failedExpectations = [];

/**
* @param array<int, string> $failedExpectations
*/
public function __construct(array $failedExpectations, ?string $detail = null, ?string $instance = null)
public function __construct(private array $failedExpectations, ?string $detail = null, ?string $instance = null)
{
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.18',
Expand All @@ -25,8 +20,6 @@ public function __construct(array $failedExpectations, ?string $detail = null, ?
$detail,
$instance
);

$this->failedExpectations = $failedExpectations;
}

/**
Expand Down
18 changes: 6 additions & 12 deletions src/ApiProblem/ClientError/MethodNotAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,23 @@

final class MethodNotAllowed extends AbstractApiProblem
{
private string $method;

/**
* @var array<int, string>
*/
private array $allowedMethods = [];

/**
* @param string $method,
* @param array<int, string> $allowedMethods
*/
public function __construct(string $method, array $allowedMethods, ?string $detail = null, ?string $instance = null)
{
public function __construct(
private string $method,
private array $allowedMethods,
?string $detail = null,
?string $instance = null
) {
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.6',
405,
'Method Not Allowed',
$detail,
$instance
);

$this->method = $method;
$this->allowedMethods = $allowedMethods;
}

/**
Expand Down
14 changes: 2 additions & 12 deletions src/ApiProblem/ClientError/NotAcceptable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@

final class NotAcceptable extends AbstractApiProblem
{
private string $accept;

/**
* @var array<int, string>
*/
private array $acceptables = [];

/**
* @param array<int, string> $acceptables
*/
public function __construct(
string $accept,
array $acceptables,
private string $accept,
private array $acceptables,
?string $detail = null,
?string $instance = null
) {
Expand All @@ -31,9 +24,6 @@ public function __construct(
$detail,
$instance
);

$this->accept = $accept;
$this->acceptables = $acceptables;
}

public function getAccept(): string
Expand Down
9 changes: 1 addition & 8 deletions src/ApiProblem/ClientError/PaymentRequired.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

final class PaymentRequired extends AbstractApiProblem
{
/**
* @var array<int, string>
*/
private array $paymentTypes = [];

/**
* @param array<int, string> $paymentTypes
*/
public function __construct(array $paymentTypes, ?string $detail = null, ?string $instance = null)
public function __construct(private array $paymentTypes, ?string $detail = null, ?string $instance = null)
{
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.3',
Expand All @@ -25,8 +20,6 @@ public function __construct(array $paymentTypes, ?string $detail = null, ?string
$detail,
$instance
);

$this->paymentTypes = $paymentTypes;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/ApiProblem/ClientError/PreconditionFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

final class PreconditionFailed extends AbstractApiProblem
{
/**
* @var array<int, string>
*/
private array $failedPreconditions = [];

/**
* @param array<int, string> $failedPreconditions
*/
public function __construct(array $failedPreconditions, ?string $detail = null, ?string $instance = null)
public function __construct(private array $failedPreconditions, ?string $detail = null, ?string $instance = null)
{
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.13',
Expand All @@ -25,8 +20,6 @@ public function __construct(array $failedPreconditions, ?string $detail = null,
$detail,
$instance
);

$this->failedPreconditions = $failedPreconditions;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/ApiProblem/ClientError/RequestEntityTooLarge.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

final class RequestEntityTooLarge extends AbstractApiProblem
{
private int $maxContentLength;

public function __construct(int $maxContentLength, ?string $detail = null, ?string $instance = null)
public function __construct(private int $maxContentLength, ?string $detail = null, ?string $instance = null)
{
parent::__construct(
'https://tools.ietf.org/html/rfc2616#section-10.4.14',
Expand All @@ -19,8 +17,6 @@ public function __construct(int $maxContentLength, ?string $detail = null, ?stri
$detail,
$instance
);

$this->maxContentLength = $maxContentLength;
}

public function getMaxContentLength(): int
Expand Down
Loading

0 comments on commit 7d39a1e

Please sign in to comment.