Skip to content

Commit 5da0ffe

Browse files
committed
Fixed latest additional scrutinizer analysis report
1 parent 1836cb0 commit 5da0ffe

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

lib/Phpfastcache/Cluster/Drivers/FullReplication/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getItem(string $key): ExtendedCacheItemInterface
7676

7777
if ($item === null) {
7878
$item = new Item($this, $key, $this->getEventManager());
79-
$item->expiresAfter(abs($this->getConfig()->getDefaultTtl()));
79+
$item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl()));
8080
}
8181

8282
return $this->getStandardizedItem($item, $this);

lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function getItem(string $key): ExtendedCacheItemInterface
6262
return $this->getStandardizedItem(
6363
$this->makeOperation(static function (ExtendedCacheItemPoolInterface $pool) use ($key) {
6464
return $pool->getItem($key);
65-
}) ?? (new Item($this, $key, $this->getEventManager()))->expiresAfter(abs($this->getConfig()->getDefaultTtl())),
65+
}) ?? (new Item($this, $key, $this->getEventManager()))->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())),
6666
$this
6767
);
6868
}

lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getItem(string $key): ExtendedCacheItemInterface
5454

5555
if ($item === null) {
5656
$item = new Item($this, $key, $this->getEventManager());
57-
$item->expiresAfter(abs($this->getConfig()->getDefaultTtl()));
57+
$item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl()));
5858
}
5959

6060
return $this->getStandardizedItem($item, $this);

lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function getItem(string $key): ExtendedCacheItemInterface
199199
* Reset the Item
200200
*/
201201
$item->set(null)
202-
->expiresAfter(abs($this->getConfig()->getDefaultTtl()))
202+
->expiresAfter((int) abs($this->getConfig()->getDefaultTtl()))
203203
->setHit(false)
204204
->setTags([]);
205205
if ($this->getConfig()->isItemDetailedDate()) {
@@ -215,7 +215,7 @@ public function getItem(string $key): ExtendedCacheItemInterface
215215
$item->setHit(true);
216216
}
217217
} else {
218-
$item->expiresAfter(abs($this->getConfig()->getDefaultTtl()));
218+
$item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl()));
219219
}
220220
}
221221
} else {

lib/Phpfastcache/Core/Pool/DriverBaseTrait.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,27 @@ public static function getItemClass(): string
143143
public function driverPreWrap(ExtendedCacheItemInterface $item, bool $stringifyDate = false): array
144144
{
145145
$wrap = [
146-
self::DRIVER_KEY_WRAPPER_INDEX => $item->getKey(), // Stored but not really used, allow you to quickly identify the cache key
147-
self::DRIVER_DATA_WRAPPER_INDEX => $item->getRawValue(),
148-
self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(),
146+
ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX => $item->getKey(), // Stored but not really used, allow you to quickly identify the cache key
147+
ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX => $item->getRawValue(),
148+
TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(),
149149
self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(),
150150
];
151151

152152
if ($this->getConfig()->isItemDetailedDate()) {
153-
$wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new DateTime();// Always on the latest date
153+
$wrap[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = new DateTime();// Always on the latest date
154154
/**
155155
* If the creation date exists
156156
* reuse it else set a new Date
157157
*/
158-
$wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate();
158+
$wrap[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate();
159159
} else {
160-
$wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null;
161-
$wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null;
160+
$wrap[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = null;
161+
$wrap[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = null;
162162
}
163163

164164
if ($stringifyDate) {
165165
\array_walk($wrap, static function (mixed &$value, string $key): void {
166-
if ($value instanceof DateTimeInterface && $key !== self::DRIVER_DATA_WRAPPER_INDEX) {
166+
if ($value instanceof DateTimeInterface && $key !== ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX) {
167167
$value = $value->format(DateTimeInterface::W3C);
168168
}
169169
});
@@ -198,7 +198,7 @@ public function setConfig(ConfigurationOptionInterface $config): static
198198
*/
199199
public function driverUnwrapData(array $wrapper): mixed
200200
{
201-
return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX];
201+
return $wrapper[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX];
202202
}
203203

204204
/**

lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace Phpfastcache\Core\Pool\IO;
1818

19-
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
19+
use Phpfastcache\Config\IOConfigurationOptionInterface;
2020
use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait;
2121
use Phpfastcache\Entities\DriverStatistic;
2222
use Phpfastcache\Event\Event;
@@ -25,6 +25,9 @@
2525
use Phpfastcache\Util\Directory;
2626
use Phpfastcache\Util\SapiDetector;
2727

28+
/**
29+
* @method IOConfigurationOptionInterface getConfig()
30+
*/
2831
trait IOHelperTrait
2932
{
3033
use TaggableCacheItemPoolTrait;

lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function fetchItemsByTagFromBackend(string $tagName): array
139139
*/
140140
protected function getTagKey(string $key): string
141141
{
142-
return self::DRIVER_TAGS_KEY_PREFIX . $key;
142+
return TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX . $key;
143143
}
144144

145145
/**
@@ -395,7 +395,7 @@ public function prependItemsByTag(string $tagName, array|string $data, int $stra
395395
*/
396396
protected function driverUnwrapTags(array $wrapper): array
397397
{
398-
return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX];
398+
return $wrapper[TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX];
399399
}
400400

401401
/**
@@ -425,7 +425,7 @@ protected function driverWriteTags(ExtendedCacheItemInterface $item): bool
425425
* on tags item, it can lead
426426
* to an infinite recursive calls
427427
*/
428-
if (str_starts_with($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX)) {
428+
if (str_starts_with($item->getKey(), TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX)) {
429429
throw new PhpfastcacheLogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey());
430430
}
431431

0 commit comments

Comments
 (0)