Skip to content

Commit 18256af

Browse files
authored
Merge pull request #428 from taylorvance/main
More explicit nullable types for PHP 8.4
2 parents 6f66c55 + c697f8e commit 18256af

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/Stash/Interfaces/ItemInterface.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function setPool(PoolInterface $driver): void;
3333
* @param array $key
3434
* @param string|null $namespace
3535
*/
36-
public function setKey(array $key, string $namespace = null): void;
36+
public function setKey(array $key, ?string $namespace = null): void;
3737

3838
/**
3939
* This disables any IO operations by this object, effectively preventing
@@ -91,7 +91,7 @@ public function isMiss(): bool;
9191
* @param null $ttl
9292
* @return bool
9393
*/
94-
public function lock(int $ttl = null): bool;
94+
public function lock(?int $ttl = null): bool;
9595

9696
/**
9797
* Takes and stores data for later retrieval. This data can be any php data,
@@ -110,7 +110,7 @@ public function set(mixed $value): static;
110110
* @param int|\DateInterval|null $ttl
111111
* @return \Stash\Item|bool
112112
*/
113-
public function extend(int|\DateInterval $ttl = null): \Stash\Item|bool;
113+
public function extend(int|\DateInterval|null $ttl = null): \Stash\Item|bool;
114114

115115
/**
116116
* Return true if caching is disabled
@@ -163,7 +163,7 @@ public function expiresAt(\DateTimeInterface|null $expiration): static;
163163
* @param int|\DateInterval|\DateTimeInterface|null $ttl An integer, date interval, or date
164164
* @return self
165165
*/
166-
public function setTTL(int|\DateInterval|\DateTimeInterface $ttl = null): static;
166+
public function setTTL(int|\DateInterval|\DateTimeInterface|null $ttl = null): static;
167167

168168
/**
169169
* Set the cache invalidation method for this item.

src/Stash/Interfaces/PoolInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getDriver(): DriverInterface;
117117
* @return bool
118118
* @throws \InvalidArgumentException Namespaces must be alphanumeric
119119
*/
120-
public function setNamespace(string $namespace = null): bool;
120+
public function setNamespace(?string $namespace = null): bool;
121121

122122
/**
123123
* Returns the current namespace, or false if no namespace was set.

src/Stash/Item.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function setPool(PoolInterface $pool): void
173173
* @param array $key the key to set for this cache item
174174
* @param string $namespace the namespace for this cache item
175175
*/
176-
public function setKey(array $key, string $namespace = null): void
176+
public function setKey(array $key, ?string $namespace = null): void
177177
{
178178
$this->namespace = $namespace;
179179

@@ -360,7 +360,7 @@ public function isMiss(): bool
360360
* @param int $ttl time to live
361361
* @return bool
362362
*/
363-
public function lock(int $ttl = null): bool
363+
public function lock(?int $ttl = null): bool
364364
{
365365
if ($this->isDisabled()) {
366366
return true;
@@ -407,7 +407,7 @@ public function set(mixed $value): static
407407
* @param int|\DateInterval|\DateTimeInterface|null $ttl time to live
408408
* @return \Stash\Item
409409
*/
410-
public function setTTL(int|\DateInterval|\DateTimeInterface $ttl = null): static
410+
public function setTTL(int|\DateInterval|\DateTimeInterface|null $ttl = null): static
411411
{
412412
if (is_numeric($ttl) || ($ttl instanceof \DateInterval)) {
413413
return $this->expiresAfter($ttl);
@@ -427,7 +427,7 @@ public function setTTL(int|\DateInterval|\DateTimeInterface $ttl = null): static
427427
* @throws \Stash\Exception\InvalidArgumentException
428428
* @return \Stash\Item
429429
*/
430-
public function expiresAt(int|\DateInterval|\DateTimeInterface $expiration = null): static
430+
public function expiresAt(int|\DateInterval|\DateTimeInterface|null $expiration = null): static
431431
{
432432
if (!is_null($expiration) && !($expiration instanceof \DateTimeInterface)) {
433433
# For compatbility with PHP 5.4 we also allow inheriting from the DateTime object.
@@ -526,10 +526,10 @@ protected function executeSet(mixed $data, int|\DateTimeInterface|null $time): b
526526
/**
527527
* {@inheritdoc}
528528
*
529-
* @param int|\DateInterval $ttl time to live
529+
* @param int|\DateInterval|null $ttl time to live
530530
* @return \Stash\Item|false
531531
*/
532-
public function extend(int|\DateInterval $ttl = null): \Stash\Item|bool
532+
public function extend(int|\DateInterval|null $ttl = null): \Stash\Item|bool
533533
{
534534
if ($this->isDisabled()) {
535535
return false;

src/Stash/Pool.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Pool implements PoolInterface
9292
*
9393
* @param DriverInterface $driver
9494
*/
95-
public function __construct(DriverInterface $driver = null)
95+
public function __construct(?DriverInterface $driver = null)
9696
{
9797
if (isset($driver)) {
9898
$this->setDriver($driver);
@@ -296,7 +296,7 @@ public function getDriver(): DriverInterface
296296
/**
297297
* {@inheritdoc}
298298
*/
299-
public function setNamespace(string $namespace = null): bool
299+
public function setNamespace(?string $namespace = null): bool
300300
{
301301
if (is_null($namespace)) {
302302
$this->namespace = null;

src/Stash/Utilities.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static function decode($data, $method)
100100
* @param DriverInterface $driver
101101
* @return string Path for Stash files
102102
*/
103-
public static function getBaseDirectory(DriverInterface $driver = null)
103+
public static function getBaseDirectory(?DriverInterface $driver = null)
104104
{
105105
$tmp = rtrim(sys_get_temp_dir(), '/\\') . '/';
106106

tests/Stash/Test/Driver/AbstractDriverTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function setUp() : void
6666
}
6767
}
6868

69-
protected function getFreshDriver(array $options = null)
69+
protected function getFreshDriver(?array $options = null)
7070
{
7171
$driverClass = $this->driverClass;
7272

tests/Stash/Test/Stubs/PoolGetDriverStub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function purge(): bool
6060
return false;
6161
}
6262

63-
public function setNamespace(string $namespace = null): bool
63+
public function setNamespace(?string $namespace = null): bool
6464
{
6565
return false;
6666
}

0 commit comments

Comments
 (0)