Skip to content

Commit a0ea2ad

Browse files
authored
Merge pull request #41 from lcobucci/upgrade-dependencies
Upgrade dependencies
2 parents bf9a8e7 + e5e95bf commit a0ea2ad

18 files changed

+64
-139
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build:
66
rabbitmq: false
77
mongodb: false
88
php:
9-
version: 7.3
9+
version: 7.4
1010

1111
cache:
1212
disabled: false

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ sudo: false
33
language: php
44

55
php:
6-
- 7.3
7-
- 7.4snapshot
6+
- 7.4
87
- nightly
98

109
cache:

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ use Zend\Diactoros\StreamFactory;
7575
$middleware = ContentTypeMiddleware::fromRecommendedSettings(
7676
// First argument is the list of formats you want to support:
7777
[
78-
'json' => [
79-
'extension' => ['json'],
80-
'mime-type' => ['application/json', 'text/json', 'application/x-json'],
81-
'charset' => true,
82-
],
78+
'json',
79+
// You may also specify the full configuration of the format.
80+
// That's handy if you need to add extensions or mime-types:
8381
'html' => [
8482
'extension' => ['html', 'htm', 'php'],
8583
'mime-type' => ['text/html', 'application/xhtml+xml'],

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
},
2121
"require": {
22-
"php": "^7.3",
22+
"php": "^7.4 || ^8.0",
2323
"ext-json": "*",
2424
"fig/http-message-util": "^1.1",
2525
"psr/http-factory": "^1.0",
@@ -28,24 +28,25 @@
2828
"require-dev": {
2929
"infection/infection": "^0.15",
3030
"jms/serializer": "^3.5",
31-
"lcobucci/coding-standard": "^3.1",
31+
"laminas/laminas-diactoros": "^2.2",
32+
"lcobucci/coding-standard": "^4.0",
3233
"league/plates": "^3.3",
33-
"middlewares/negotiation": "^1.1",
34-
"phpstan/phpstan": "^0.11",
35-
"phpstan/phpstan-deprecation-rules": "^0.11",
36-
"phpstan/phpstan-phpunit": "^0.11",
37-
"phpstan/phpstan-strict-rules": "^0.11",
34+
"middlewares/negotiation": "^2.0",
35+
"phpstan/extension-installer": "^1.0",
36+
"phpstan/phpstan": "^0.12",
37+
"phpstan/phpstan-deprecation-rules": "^0.12",
38+
"phpstan/phpstan-phpunit": "^0.12",
39+
"phpstan/phpstan-strict-rules": "^0.12",
3840
"phpunit/phpunit": "^9.0",
3941
"squizlabs/php_codesniffer": "^3.5",
40-
"twig/twig": "^2.12",
41-
"zendframework/zend-diactoros": "^2.2"
42+
"twig/twig": "^3.0"
4243
},
4344
"suggest": {
4445
"jms/serializer": "For content formatting using a more flexible serializer",
4546
"league/plates": "For content formatting using Plates as template engine",
4647
"middlewares/negotiation": "For acceptable format identification",
4748
"twig/twig": "For content formatting using Twig as template engine",
48-
"zendframework/zend-diactoros": "For concrete implementation of PSR-7"
49+
"laminas/laminas-diactoros": "For concrete implementation of PSR-7"
4950
},
5051
"autoload": {
5152
"psr-4": {

phpstan.neon.dist

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
includes:
2-
- vendor/phpstan/phpstan-phpunit/extension.neon
3-
- vendor/phpstan/phpstan-phpunit/rules.neon
4-
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
5-
- vendor/phpstan/phpstan-strict-rules/rules.neon
6-
71
parameters:
82
level: 7
93
paths:
@@ -13,3 +7,5 @@ parameters:
137
-
148
message: '#Variable method call on#'
159
path: tests/UnformattedResponseTest.php
10+
11+
- '#static\(Lcobucci\\ContentNegotiation\\UnformattedResponse\) but returns Lcobucci\\ContentNegotiation\\UnformattedResponse#'

src/ContentTypeMiddleware.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@
1515

1616
final class ContentTypeMiddleware implements MiddlewareInterface
1717
{
18-
/**
19-
* @var MiddlewareInterface
20-
*/
21-
private $negotiator;
22-
23-
/**
24-
* @var StreamFactoryInterface
25-
*/
26-
private $streamFactory;
18+
private MiddlewareInterface $negotiator;
19+
private StreamFactoryInterface $streamFactory;
2720

2821
/**
2922
* @var Formatter[]
3023
*/
31-
private $formatters;
24+
private array $formatters;
3225

3326
/**
3427
* @param Formatter[] $formatters

src/Formatter/JmsSerializer.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@
1111

1212
final class JmsSerializer implements Formatter
1313
{
14-
/**
15-
* @var SerializerInterface
16-
*/
17-
private $serializer;
18-
19-
/**
20-
* @var string
21-
*/
22-
private $format;
14+
private SerializerInterface $serializer;
15+
private string $format;
2316

2417
public function __construct(SerializerInterface $serializer, string $format)
2518
{

src/Formatter/Json.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,20 @@
66
use Lcobucci\ContentNegotiation\ContentCouldNotBeFormatted;
77
use Lcobucci\ContentNegotiation\Formatter;
88
use Throwable;
9+
use function json_encode;
10+
use function sprintf;
911
use const JSON_HEX_AMP;
1012
use const JSON_HEX_APOS;
1113
use const JSON_HEX_QUOT;
1214
use const JSON_HEX_TAG;
1315
use const JSON_THROW_ON_ERROR;
1416
use const JSON_UNESCAPED_SLASHES;
15-
use function assert;
16-
use function is_string;
17-
use function json_encode;
18-
use function sprintf;
1917

2018
final class Json implements Formatter
2119
{
2220
private const DEFAULT_FLAGS = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES;
2321

24-
/**
25-
* @var int
26-
*/
27-
private $flags;
22+
private int $flags;
2823

2924
public function __construct(int $flags = self::DEFAULT_FLAGS)
3025
{
@@ -37,10 +32,7 @@ public function __construct(int $flags = self::DEFAULT_FLAGS)
3732
public function format($content, array $attributes = []): string
3833
{
3934
try {
40-
$content = json_encode($content, $this->flags | JSON_THROW_ON_ERROR);
41-
assert(is_string($content));
42-
43-
return $content;
35+
return json_encode($content, $this->flags | JSON_THROW_ON_ERROR);
4436
} catch (Throwable $exception) {
4537
throw new ContentCouldNotBeFormatted(
4638
sprintf('An exception was thrown during JSON formatting: %s', $exception->getMessage()),

src/Formatter/Plates.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@ final class Plates implements Formatter
1212
{
1313
private const DEFAULT_ATTRIBUTE = 'template';
1414

15-
/**
16-
* @var Engine
17-
*/
18-
private $engine;
19-
20-
/**
21-
* @var string
22-
*/
23-
private $attributeName;
15+
private Engine $engine;
16+
private string $attributeName;
2417

2518
public function __construct(Engine $engine, string $attributeName = self::DEFAULT_ATTRIBUTE)
2619
{

src/Formatter/Twig.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@
66
use Lcobucci\ContentNegotiation\ContentCouldNotBeFormatted;
77
use Lcobucci\ContentNegotiation\Formatter;
88
use Throwable;
9-
use Twig_Environment;
9+
use Twig\Environment;
1010

1111
final class Twig implements Formatter
1212
{
1313
private const DEFAULT_ATTRIBUTE = 'template';
1414

15-
/**
16-
* @var Twig_Environment
17-
*/
18-
private $environment;
19-
20-
/**
21-
* @var string
22-
*/
23-
private $attributeName;
15+
private Environment $environment;
16+
private string $attributeName;
2417

2518
public function __construct(
26-
Twig_Environment $environment,
19+
Environment $environment,
2720
string $attributeName = self::DEFAULT_ATTRIBUTE
2821
) {
2922
$this->environment = $environment;

0 commit comments

Comments
 (0)