Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmullie committed Apr 7, 2024
1 parent 577545a commit 50a3d72
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 28 deletions.
5 changes: 2 additions & 3 deletions src/Adapters/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function get(string $key, mixed &$token = null): mixed
return $value;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$tokens = [];
if (empty($keys)) {
Expand Down Expand Up @@ -532,11 +532,10 @@ protected function expire(string|array $key = [], int $ttl = 0): void

/**
* @param string|string[] $key
* @param bool $success
*
* @return mixed|false
*/
protected function fetch(string|array $key, bool &$success = null): mixed
protected function fetch(string|array $key, ?bool &$success = null): mixed
{
/*
* $key can also be numeric, in which case APC is able to retrieve it,
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Collections/Utils/PrefixKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function get(string $key, mixed &$token = null): mixed
return $this->cache->get($key, $token);
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$keys = array_map([$this, 'prefix'], $keys);
$results = $this->cache->getMulti($keys, $tokens);
Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/Couchbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Couchbase implements KeyValueStore
/**
* @var int|null Timeout in ms
*/
protected int|null $timeout;
protected ?int $timeout;

/**
* @param int|null $timeout K/V timeout in ms
Expand All @@ -39,7 +39,7 @@ public function __construct(
\Couchbase\Collection $client,
\Couchbase\BucketManager|\Couchbase\Management\BucketManager $bucketManager,
\Couchbase\Bucket $bucket,
int $timeout = null
?int $timeout = null
) {
$this->collection = $client;
$this->bucketManager = $bucketManager;
Expand Down Expand Up @@ -71,7 +71,7 @@ public function get(string $key, mixed &$token = null): mixed
}
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
// SDK >=3.0 no longer provides *multi operations
$results = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Flysystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function get(string $key, mixed &$token = null): mixed
return $value;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$results = [];
$tokens = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function get(string $key, mixed &$token = null): mixed
return $values[$key];
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$tokens = [];
if (empty($keys)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/MemoryStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MemoryStore implements KeyValueStore
/**
* @param int|string|null $limit Memory limit in bytes (defaults to 10% of memory_limit)
*/
public function __construct(int|string $limit = null)
public function __construct(int|string|null $limit = null)
{
if ($limit === null) {
$phpLimit = ini_get('memory_limit');
Expand Down Expand Up @@ -60,7 +60,7 @@ public function get(string $key, mixed &$token = null): mixed
return unserialize($value, ['allowed_classes' => true]);
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$items = [];
$tokens = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function get(string $key, mixed &$token = null): mixed
return $return;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$return = parent::getMulti($keys, $tokens);

Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Redis implements KeyValueStore
{
protected \Redis $client;

protected string|null $version = null;
protected ?string $version = null;

public function __construct(\Redis $client)
{
Expand Down Expand Up @@ -60,7 +60,7 @@ public function get(string $key, mixed &$token = null): mixed
return $value;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$tokens = [];
if (empty($keys)) {
Expand Down Expand Up @@ -507,7 +507,7 @@ public function getCollection(string $name): KeyValueStore
*
* @return int|null TTL in seconds, or `null` for no expiration
*/
protected function ttl(int $expire): int|null
protected function ttl(int $expire): ?int
{
if ($expire === 0) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function get(string $key, mixed &$token = null): mixed
return $this->unserialize($result['v']);
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$tokens = [];
if (empty($keys)) {
Expand Down Expand Up @@ -396,7 +396,7 @@ protected function clearExpired(): void
* Transforms expiration times into TIMESTAMP (Y-m-d H:i:s) format, which DB
* will understand and be able to compare with other dates.
*/
protected function expire(int $expire): string|null
protected function expire(int $expire): ?string
{
if ($expire === 0) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Buffered/BufferedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function get(string $key, mixed &$token = null): mixed
*
* {@inheritdoc}
*/
public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$values = $this->transaction->getMulti($keys, $tokens);

Expand Down
2 changes: 1 addition & 1 deletion src/Buffered/TransactionalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function get(string $key, mixed &$token = null): mixed
return end($this->transactions)->get($key, $token);
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
return end($this->transactions)->getMulti($keys, $tokens);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Buffered/Utils/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function get(string $key, mixed &$token = null): mixed
return $value;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
// retrieve all that we can from local cache
$values = $this->local->getMulti($keys);
Expand Down
2 changes: 1 addition & 1 deletion src/KeyValueStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function get(string $key, mixed &$token = null): mixed;
*
* @return mixed[] [key => value]
*/
public function getMulti(array $keys, array &$tokens = null): array;
public function getMulti(array $keys, ?array &$tokens = null): array;

/**
* Stores a value, regardless of whether or not the key already exists (in
Expand Down
6 changes: 3 additions & 3 deletions src/Psr16/SimpleCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function get(string $key, mixed $default = null): mixed
return $multi[$key] ?? $default;
}

public function set(string $key, mixed $value, int|\DateInterval $ttl = null): bool
public function set(string $key, mixed $value, int|\DateInterval|null $ttl = null): bool
{
$this->assertValidKey($key);
$ttl = $this->ttl($ttl);
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
return array_merge($nulls, $results);
}

public function setMultiple(iterable $values, int|\DateInterval $ttl = null): bool
public function setMultiple(iterable $values, int|\DateInterval|null $ttl = null): bool
{
if ($values instanceof \Traversable) {
// we also need the keys, and an array is stricter about what it can
Expand Down Expand Up @@ -160,7 +160,7 @@ protected function assertValidKey(string $key): void
* Accepts all TTL inputs valid in PSR-16 (null|int|DateInterval) and
* converts them into TTL for KeyValueStore (int).
*/
protected function ttl(null|int|\DateInterval $ttl): int
protected function ttl(int|\DateInterval|null $ttl): int
{
if ($ttl === null) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Psr6/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Item implements CacheItemInterface

protected int $expire = 0;

protected bool|null $isHit;
protected ?bool $isHit;

protected bool $changed = false;

Expand Down
4 changes: 2 additions & 2 deletions src/Scale/Shard.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Shard implements KeyValueStore
/**
* Overloadable with multiple KeyValueStore objects.
*/
public function __construct(KeyValueStore $cache1, KeyValueStore $cache2 = null /* , [KeyValueStore $cache3, [...]] */)
public function __construct(KeyValueStore $cache1, ?KeyValueStore $cache2 = null /* , [KeyValueStore $cache3, [...]] */)
{
$caches = func_get_args();
$caches = array_filter($caches);
Expand All @@ -54,7 +54,7 @@ public function get(string $key, mixed &$token = null): mixed
return $this->getShard($key)->get($key, $token);
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
$shards = $this->getShards($keys);
$results = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Scale/StampedeProtector.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function get(string $key, mixed &$token = null): mixed
return $values[$key] ?? false;
}

public function getMulti(array $keys, array &$tokens = null): array
public function getMulti(array $keys, ?array &$tokens = null): array
{
// fetch both requested keys + stampede protection indicators at once
$stampedeKeys = array_combine($keys, array_map([$this, 'stampedeKey'], $keys));
Expand Down

0 comments on commit 50a3d72

Please sign in to comment.