Skip to content

Commit 4d25b51

Browse files
committed
update depndencies
1 parent 74f66aa commit 4d25b51

File tree

11 files changed

+59
-90
lines changed

11 files changed

+59
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ nbproject
77
.settings
88
composer.lock
99
/vendor
10+
.phpunit.cache
1011
.phpunit.result.cache
1112
/dist

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"name": "n1215/openapi-http-foundation-validator",
33
"type": "library",
44
"require": {
5-
"php": ">=7.4",
6-
"league/openapi-psr7-validator": "^0.15.2",
7-
"psr/cache": "^1.0",
8-
"psr/simple-cache": "^1.0",
9-
"symfony/psr-http-message-bridge": "^2.1"
5+
"php": ">=8.1",
6+
"league/openapi-psr7-validator": "^0.21",
7+
"psr/cache": "1.0|^2.0|^3.0",
8+
"psr/simple-cache": "^1.0|^2.0|^3.0",
9+
"symfony/psr-http-message-bridge": "^2.3"
1010
},
1111
"require-dev": {
12-
"nyholm/psr7": "^1.4",
13-
"phpstan/phpstan": "^0.12.98",
14-
"phpunit/phpunit": "^9.5",
15-
"squizlabs/php_codesniffer": "^3.6",
16-
"yiisoft/cache": "^1.0"
12+
"nyholm/psr7": "^1.8",
13+
"phpstan/phpstan": "^1.10",
14+
"phpunit/phpunit": "^10.3",
15+
"squizlabs/php_codesniffer": "^3.7",
16+
"yiisoft/cache": "^3.0"
1717
},
1818
"autoload": {
1919
"psr-4": {

phpstan.neon.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ parameters:
22
paths:
33
- src
44
- tests
5-
# The level 8 is the highest level
6-
level: 8
5+
level: 9

phpunit.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" failOnWarning="true" stopOnFailure="true">
3-
<coverage processUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">./src</directory>
6-
</include>
7-
</coverage>
8-
<testsuites>
9-
<testsuite name="Tests">
10-
<directory suffix="Test.php">./tests</directory>
11-
</testsuite>
12-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" failOnWarning="true" stopOnFailure="true" cacheDirectory=".phpunit.cache">
3+
<coverage/>
4+
<testsuites>
5+
<testsuite name="Tests">
6+
<directory suffix="Test.php">./tests</directory>
7+
</testsuite>
8+
</testsuites>
9+
<source>
10+
<include>
11+
<directory suffix=".php">./src</directory>
12+
</include>
13+
</source>
1314
</phpunit>

src/Cache/Psr6CacheItem.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,16 @@
1212

1313
class Psr6CacheItem implements CacheItemInterface
1414
{
15-
protected string $key;
16-
17-
/**
18-
* @var mixed
19-
*/
20-
protected $value;
21-
22-
protected ?DateTimeInterface $expiration;
23-
2415
/**
2516
* @param string $key
2617
* @param mixed $value
2718
* @param DateTimeInterface|null $expiration
2819
*/
29-
public function __construct(string $key, $value, ?DateTimeInterface $expiration = null)
30-
{
31-
$this->key = $key;
32-
$this->value = $value;
33-
$this->expiration = $expiration;
20+
public function __construct(
21+
private readonly string $key,
22+
private mixed $value,
23+
private ?DateTimeInterface $expiration = null
24+
) {
3425
}
3526

3627
/**
@@ -44,7 +35,7 @@ public function getKey(): string
4435
/**
4536
* @inheritDoc
4637
*/
47-
public function get()
38+
public function get(): mixed
4839
{
4940
return $this->value;
5041
}
@@ -60,7 +51,7 @@ public function isHit(): bool
6051
/**
6152
* @inheritDoc
6253
*/
63-
public function set($value): self
54+
public function set($value): static
6455
{
6556
$this->value = $value;
6657
return $this;
@@ -69,7 +60,7 @@ public function set($value): self
6960
/**
7061
* @inheritDoc
7162
*/
72-
public function expiresAt($expiration): self
63+
public function expiresAt($expiration): static
7364
{
7465
$this->expiration = $expiration;
7566
return $this;
@@ -78,13 +69,17 @@ public function expiresAt($expiration): self
7869
/**
7970
* @inheritDoc
8071
*/
81-
public function expiresAfter($time): self
72+
public function expiresAfter($time): static
8273
{
8374
if (is_int($time)) {
8475
if ($time <= 0) {
8576
throw new InvalidArgumentException('$time should be a positive integer, DateInterval, or null.');
8677
}
87-
$this->expiration = (new DateTimeImmutable())->add(DateInterval::createFromDateString("{$time} seconds"));
78+
$interval = DateInterval::createFromDateString("$time seconds");
79+
if ($interval === false) {
80+
throw new InvalidArgumentException('Failed to parse DateInterval.');
81+
}
82+
$this->expiration = (new DateTimeImmutable())->add($interval);
8883
} elseif ($time instanceof DateInterval) {
8984
$this->expiration = (new DateTimeImmutable())->add($time);
9085
} else {

src/Cache/Psr6CachePool.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class Psr6CachePool implements CacheItemPoolInterface
1414
{
15-
protected CacheInterface $cache;
16-
17-
public function __construct(CacheInterface $cache)
18-
{
19-
$this->cache = $cache;
15+
public function __construct(
16+
private readonly CacheInterface $cache
17+
) {
2018
}
2119

2220
/**
@@ -34,7 +32,7 @@ public function getItem($key): CacheItemInterface
3432

3533
/**
3634
* @param string[] $keys
37-
* @return array<mixed>
35+
* @return array<CacheItemInterface>
3836
*/
3937
public function getItems(array $keys = []): array
4038
{
@@ -74,7 +72,9 @@ public function deleteItem($key): bool
7472
}
7573

7674
/**
77-
* @inheritDoc
75+
* @param string[] $keys
76+
* @return bool
77+
* @throws \Psr\Cache\InvalidArgumentException&\Throwable
7878
*/
7979
public function deleteItems(array $keys): bool
8080
{

src/HttpFoundation/RequestValidator.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ final class RequestValidator implements RequestValidatorInterface
1414
{
1515
private bool $isEnabled = true;
1616

17-
private HttpMessageFactoryInterface $psrHttpFactory;
18-
19-
private Psr7ServerRequestValidator $psr7ServerRequestValidator;
20-
2117
public function __construct(
22-
HttpMessageFactoryInterface $psrHttpFactory,
23-
Psr7ServerRequestValidator $psr7ServerRequestValidator
18+
private readonly HttpMessageFactoryInterface $psrHttpFactory,
19+
private readonly Psr7ServerRequestValidator $psr7ServerRequestValidator
2420
) {
25-
$this->psrHttpFactory = $psrHttpFactory;
26-
$this->psr7ServerRequestValidator = $psr7ServerRequestValidator;
2721
}
2822

2923
/**

src/HttpFoundation/ResponseValidator.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ final class ResponseValidator implements ResponseValidatorInterface
1616
{
1717
private bool $isEnabled = true;
1818

19-
private HttpMessageFactoryInterface $psrHttpFactory;
20-
21-
private Psr7ResponseValidator $psr7ResponseValidator;
22-
2319
public function __construct(
24-
HttpMessageFactoryInterface $psrHttpFactory,
25-
Psr7ResponseValidator $psr7ResponseValidator
20+
private readonly HttpMessageFactoryInterface $psrHttpFactory,
21+
private readonly Psr7ResponseValidator $psr7ResponseValidator
2622
) {
27-
$this->psrHttpFactory = $psrHttpFactory;
28-
$this->psr7ResponseValidator = $psr7ResponseValidator;
2923
}
3024

3125
/**

src/HttpFoundation/ValidatorBuilder.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ class ValidatorBuilder
1414
{
1515
protected Psr7ValidatorBuilder $psr7ValidatorBuilder;
1616

17-
protected HttpMessageFactoryInterface $httpMessageFactory;
18-
19-
public function __construct(HttpMessageFactoryInterface $httpMessageFactory)
20-
{
17+
public function __construct(
18+
private readonly HttpMessageFactoryInterface $httpMessageFactory
19+
) {
2120
$this->psr7ValidatorBuilder = new Psr7ValidatorBuilder();
22-
$this->httpMessageFactory = $httpMessageFactory;
2321
}
2422

2523
/**

src/HttpFoundation/Validators.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@
88

99
class Validators
1010
{
11-
private OpenApi $schema;
12-
13-
private RequestValidator $requestValidator;
14-
15-
private ResponseValidator $responseValidator;
16-
1711
public function __construct(
18-
OpenApi $schema,
19-
RequestValidator $requestValidator,
20-
ResponseValidator $responseValidator
12+
private readonly OpenApi $schema,
13+
private readonly RequestValidator $requestValidator,
14+
private readonly ResponseValidator $responseValidator
2115
) {
22-
$this->schema = $schema;
23-
$this->requestValidator = $requestValidator;
24-
$this->responseValidator = $responseValidator;
2516
}
2617

2718
public function getSchema(): OpenApi

0 commit comments

Comments
 (0)