Skip to content

Commit 70c7894

Browse files
committed
Added many missing types; in particular, mixed and union types.
1 parent 9aaf5b5 commit 70c7894

27 files changed

+69
-172
lines changed

src/Cache/CacheItem.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,32 @@
1010
*/
1111
final class CacheItem implements CacheItemInterface
1212
{
13-
private $key;
14-
15-
private $value;
16-
17-
private $hit;
18-
19-
private function __construct(string $key, $value, bool $hit)
13+
private function __construct(private readonly string $key, private mixed $value, private readonly bool $hit)
2014
{
21-
$this->key = $key;
22-
$this->value = $value;
23-
$this->hit = $hit;
2415
}
2516

2617
public function getKey(): string
2718
{
2819
return $this->key;
2920
}
3021

31-
/**
32-
* @return mixed
33-
*/
34-
public function get()
22+
public function get(): mixed
3523
{
3624
return $this->value;
3725
}
3826

39-
public function isHit(): bool
40-
{
41-
return $this->hit;
42-
}
43-
44-
/**
45-
* @param mixed $value
46-
*/
47-
public function set($value): self
27+
public function set(mixed $value): self
4828
{
4929
$this->value = $value;
5030

5131
return $this;
5232
}
5333

34+
public function isHit(): bool
35+
{
36+
return $this->hit;
37+
}
38+
5439
public function expiresAt($expiration): self
5540
{
5641
throw new NotImplementedException;

src/Cache/MemoryCache.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ class MemoryCache extends \ArrayObject implements CacheItemPoolInterface
1313
{
1414
/**
1515
* @param string $key
16-
*
17-
* @return mixed
1816
*/
19-
public function getItem($key)
17+
public function getItem($key): mixed
2018
{
2119
return \Closure::bind(
2220
function () use ($key): self {

src/Collection/ProviderRecords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ProviderRecords extends RecordCollection
99
{
10-
private $resource;
10+
private ProviderResource $resource;
1111

1212
public function __construct(\Iterator $providerRecords, ProviderResource $resource)
1313
{

src/Connector/CachingConnector.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ class CachingConnector implements Connector, ConnectorWrapper
1616
{
1717
public const RESERVED_CHARACTERS = '{}()/\@:';
1818

19-
/**
20-
* @var Connector
21-
*/
22-
private $connector;
23-
24-
/**
25-
* @var CacheItemPoolInterface
26-
*/
27-
private $cache;
19+
private CacheItemPoolInterface $cache;
2820

2921
public function __construct(
30-
Connector $connector,
22+
private Connector $connector,
3123
CacheItemPoolInterface $cache = null
3224
) {
33-
$this->connector = $connector;
3425
$this->cache = $cache ?: new MemoryCache;
3526
}
3627

@@ -45,7 +36,7 @@ public function __clone()
4536
/**
4637
* @throws InvalidCacheKeyException Cache key contains invalid data.
4738
*/
48-
public function fetch(DataSource $source)
39+
public function fetch(DataSource $source): mixed
4940
{
5041
$this->validateCacheKey($key = $source->computeHash());
5142

src/Connector/Connector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ interface Connector
1515
*
1616
* @return mixed Data.
1717
*/
18-
public function fetch(DataSource $source);
18+
public function fetch(DataSource $source): mixed;
1919
}

src/Connector/NullConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
final class NullConnector implements Connector
77
{
8-
public function fetch(DataSource $source)
8+
public function fetch(DataSource $source): mixed
99
{
10-
// Intentionally empty.
10+
return null;
1111
}
1212
}

src/Connector/Recoverable/ExponentialAsyncDelayRecoverableExceptionHandler.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,17 @@
1010
*/
1111
class ExponentialAsyncDelayRecoverableExceptionHandler implements RecoverableExceptionHandler
1212
{
13-
private $initialDelay;
14-
15-
/**
16-
* @var AsyncExponentialBackoffExceptionHandler
17-
*/
18-
private $handler;
13+
private AsyncExponentialBackoffExceptionHandler $handler;
1914

2015
/**
2116
* Initializes this instance with the specified initial delay. The initial delay will be used when the first
2217
* exception is handled; subsequent exceptions will cause longer delays.
2318
*
2419
* @param int $initialDelay Initial delay in milliseconds.
2520
*/
26-
public function __construct(int $initialDelay = AsyncExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT)
27-
{
28-
$this->initialDelay = $initialDelay;
21+
public function __construct(
22+
private readonly int $initialDelay = AsyncExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT
23+
) {
2924
}
3025

3126
public function initialize(): void

src/Connector/Recoverable/ExponentialSleepRecoverableExceptionHandler.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,17 @@
1010
*/
1111
class ExponentialSleepRecoverableExceptionHandler implements RecoverableExceptionHandler
1212
{
13-
private $initialDelay;
14-
15-
/**
16-
* @var ExponentialBackoffExceptionHandler
17-
*/
18-
private $handler;
13+
private ExponentialBackoffExceptionHandler $handler;
1914

2015
/**
2116
* Initializes this instance with the specified initial delay. The initial delay will be used when the first
2217
* exception is handled; subsequent exceptions will cause longer delays.
2318
*
2419
* @param int $initialDelay Initial delay in microseconds.
2520
*/
26-
public function __construct(int $initialDelay = ExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT)
27-
{
28-
$this->initialDelay = $initialDelay;
21+
public function __construct(
22+
private readonly int $initialDelay = ExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT
23+
) {
2924
}
3025

3126
public function initialize(): void

src/PorterAwareTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
trait PorterAwareTrait
77
{
8-
/** @var Porter */
9-
private $porter;
8+
private Porter $porter;
109

1110
private function getPorter(): Porter
1211
{

src/Provider/Resource/StaticResource.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
class StaticResource implements ProviderResource
1010
{
11-
private $data;
12-
13-
public function __construct(\Iterator $data)
11+
public function __construct(private readonly \Iterator $data)
1412
{
15-
$this->data = $data;
1613
}
1714

1815
public function getProviderClassName(): string

0 commit comments

Comments
 (0)