8000 minor #33508 [Cache] Add types to constructors and private/final/inte… · symfony/symfony@312cbf9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 312cbf9

Browse files
minor #33508 [Cache] Add types to constructors and private/final/internal methods (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache] Add types to constructors and private/final/internal methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32179, #33228 | License | MIT | Doc PR | N/A I'm currently preparing a large PR collecting changes like these. However, the changeset for the Cache component was large enough to justify a dedicated PR, imho. Commits ------- 919afd2 [Cache] Add types to constructors and private/final/internal methods.
2 parents 81ac674 + 919afd2 commit 312cbf9

File tree

63 files changed

+111
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+111
-160
lines changed

src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private function generateItems(iterable $items)
260260
}
261261
}
262262

263-
private function getId($key)
263+
private function getId($key): string
264264
{
265265
CacheItem::validateKey($key);
266266

src/Symfony/Component/Cache/CacheItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static function validateKey($key): string
185185
*
186186
* @internal
187187
*/
188-
public static function log(LoggerInterface $logger = null, $message, $context = [])
188+
public static function log(?LoggerInterface $logger, string $message, array $context = [])
189189
{
190190
if ($logger) {
191191
$logger->warning($message, $context);

src/Symfony/Component/Cache/LockRegistry.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public static function compute(callable $callback, ItemInterface $item, bool &$s
131131
$logger && $logger->info('Item "{key}" not found while lock was released, now retrying', ['key' => $item->getKey()]);
132132
}
133133
}
134+
135+
return null;
134136
}
135137

136138
private static function open(int $key)

src/Symfony/Component/Cache/Simple/AbstractCache.php

Lines chan A851 ged: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private function normalizeTtl($ttl)
177177
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)));
178178
}
179179

180-
private function generateValues(iterable $values, array &$keys, $default)
180+
private function generateValues(iterable $values, array &$keys, $default): iterable
181181
{
182182
try {
183183
foreach ($values as $id => $value) {

src/Symfony/Component/Cache/Simple/ChainCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getMultiple($keys, $default = null)
9292
return $this->generateItems($this->caches[0]->getMultiple($keys, $miss), 0, $miss, $default);
9393
}
9494

95-
private function generateItems(iterable $values, int $cacheIndex, $miss, $default)
95+
private function generateItems(iterable $values, int $cacheIndex, $miss, $default): iterable
9696
{
9797
$missing = [];
9898
$nextCacheIndex = $cacheIndex + 1;

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function setMultiple($values, $ttl = null)
229229
return $saved;
230230
}
231231

232-
private function generateItems(array $keys, $default)
232+
private function generateItems(array $keys, $default): iterable
233233
{
234234
$fallbackKeys = [];
235235

src/Symfony/Component/Cache/Simple/TraceableCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function getCalls()
236236
}
237237
}
238238

239-
private function start(string $name)
239+
private function start(string $name): TraceableCacheEvent
240240
{
241241
$this->calls[] = $event = new TraceableCacheEvent();
242242
$event->name = $name;

src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class AbstractRedisAdapterTest extends AdapterTestCase
2424

2525
protected static $redis;
2626

27-
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
27+
public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
2828
{
2929
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
3030
}

src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ApcuAdapterTest extends AdapterTestCase
2323
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
2424
];
2525

26-
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
26+
public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
2727
{
2828
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
2929
$this->markTestSkipped('APCu extension is required.');

src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ArrayAdapterTest extends AdapterTestCase
2525
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
2626
];
2727

28-
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
28+
public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
2929
{
3030
return new ArrayAdapter($defaultLifetime);
3131
}

0 commit comments

Comments
 (0)
0