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 451dd7b commit 9185cdc
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 70 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ A simple negotiation library.

## Suggest

* chubbyphp/chubbyphp-container: ^1.0
* pimple/pimple: ^3.3
* chubbyphp/chubbyphp-container: ^2.1
* pimple/pimple: ^3.5

## Installation

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

```sh
composer require chubbyphp/chubbyphp-negotiation "^1.8"
composer require chubbyphp/chubbyphp-negotiation "^1.9"
```

## Usage
Expand Down Expand Up @@ -148,7 +148,7 @@ $container['negotiator.contentTypeNegotiator']

## Copyright

Dominik Zogg 2021
Dominik Zogg 2022

[1]: https://packagist.org/packages/chubbyphp/chubbyphp-negotiation

Expand Down
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^1.0|^2.0",
"chubbyphp/chubbyphp-container": "^2.1",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.0",
"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.3"
"phpstan/phpstan": "^1.4.8",
"phpunit/phpunit": "^9.5.17",
"pimple/pimple": "^3.5"
},
"autoload": {
"psr-4": { "Chubbyphp\\Negotiation\\": "src/" }
Expand All @@ -33,11 +33,15 @@
"psr-4": { "Chubbyphp\\Tests\\Negotiation\\": "tests/" }
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
"dev-master": "1.9-dev"
}
},
"scripts": {
Expand All @@ -55,7 +59,7 @@
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=97 --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=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
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
10 changes: 2 additions & 8 deletions src/AcceptLanguageNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
*/
final class AcceptLanguageNegotiator implements AcceptLanguageNegotiatorInterface
{
/**
* @var array<int, string>
*/
private array $supportedLocales;

/**
* @param array<int, string> $supportedLocales
*/
public function __construct(array $supportedLocales)
public function __construct(private array $supportedLocales)
{
$this->supportedLocales = $supportedLocales;
}

/**
Expand Down Expand Up @@ -59,7 +53,7 @@ private function acceptLanguages(string $header): array

$attributes = [];
foreach ($headerValueParts as $attribute) {
if (false !== strpos($attribute, '=')) {
if (str_contains($attribute, '=')) {
[$attributeKey, $attributeValue] = explode('=', $attribute);
$attributes[trim($attributeKey)] = trim($attributeValue);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AcceptNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function mediaTypes(string $header): array

$attributes = [];
foreach ($headerValueParts as $attribute) {
if (false !== strpos($attribute, '=')) {
if (str_contains($attribute, '=')) {
[$attributeKey, $attributeValue] = explode('=', $attribute);
$attributes[trim($attributeKey)] = trim($attributeValue);
}
Expand Down Expand Up @@ -147,7 +147,7 @@ private function compareMediaTypeWithTypeOnly(string $mediaType, array $attribut
}

foreach ($this->supportedMediaTypes as $supportedMediaType) {
if (1 === preg_match('/^'.preg_quote($mediaTypeParts[1]).'\/.+$/', $supportedMediaType)) {
if (1 === preg_match('/^'.preg_quote($mediaTypeParts[1], '/').'\/.+$/', $supportedMediaType)) {
return new NegotiatedValue($supportedMediaType, $attributes);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/ContentTypeNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
*/
final class ContentTypeNegotiator implements ContentTypeNegotiatorInterface
{
/**
* @var array<int, string>
*/
private array $supportedMediaTypes;

/**
* @param array<int, string> $supportedMediaTypes
*/
public function __construct(array $supportedMediaTypes)
public function __construct(private array $supportedMediaTypes)
{
$this->supportedMediaTypes = $supportedMediaTypes;
}

/**
Expand All @@ -47,7 +41,7 @@ public function negotiate(Request $request): ?NegotiatedValueInterface

private function compareMediaTypes(string $header): ?NegotiatedValueInterface
{
if (false !== strpos($header, ',')) {
if (str_contains($header, ',')) {
return null;
}

Expand Down
11 changes: 1 addition & 10 deletions src/NegotiatedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@

final class NegotiatedValue implements NegotiatedValueInterface
{
private string $value;

/**
* @var array<string, string>
*/
private array $attributes;

/**
* @param array<string, string> $attributes
*/
public function __construct(string $value, array $attributes = [])
public function __construct(private string $value, private array $attributes = [])
{
$this->value = $value;
$this->attributes = $attributes;
}

public function getValue(): string
Expand Down

0 comments on commit 9185cdc

Please sign in to comment.