1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace RoaveTest\DoctrineSimpleCache; |
5
|
|
|
|
6
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
7
|
|
|
use Roave\DoctrineSimpleCache\Exception\CacheException; |
8
|
|
|
use Roave\DoctrineSimpleCache\Exception\InvalidArgumentException; |
9
|
|
|
use Roave\DoctrineSimpleCache\SimpleCacheAdapter; |
10
|
|
|
use RoaveTestAsset\DoctrineSimpleCache\FullyImplementedCache; |
11
|
|
|
use RoaveTestAsset\DoctrineSimpleCache\NotClearableCache; |
12
|
|
|
use RoaveTestAsset\DoctrineSimpleCache\NotMultiGettableCache; |
13
|
|
|
use RoaveTestAsset\DoctrineSimpleCache\NotMultiPuttableCache; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @covers \Roave\DoctrineSimpleCache\SimpleCacheAdapter |
17
|
|
|
*/ |
18
|
|
|
final class SimpleCacheAdapterTest extends \PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
public function invalidTTLs() : array |
21
|
|
|
{ |
22
|
|
|
return [ |
23
|
|
|
[''], |
24
|
|
|
[true], |
25
|
|
|
[false], |
26
|
|
|
['abc'], |
27
|
|
|
[2.5], |
28
|
|
|
[' 1'], // can be casted to a int |
29
|
|
|
['12foo'], // can be casted to a int |
30
|
|
|
['025'], // can be interpreted as hex |
31
|
|
|
[new \stdClass()], |
32
|
|
|
[['array']], |
33
|
|
|
]; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function validKeys() |
37
|
|
|
{ |
38
|
|
|
return [ |
39
|
|
|
['AbC19_.'], |
40
|
|
|
['1234567890123456789012345678901234567890123456789012345678901234'], |
41
|
|
|
]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function invalidKeys() |
45
|
|
|
{ |
46
|
|
|
return [ |
47
|
|
|
[''], |
48
|
|
|
[true], |
49
|
|
|
[false], |
50
|
|
|
[null], |
51
|
|
|
[2], |
52
|
|
|
[2.5], |
53
|
|
|
['{str'], |
54
|
|
|
['rand{'], |
55
|
|
|
['rand{str'], |
56
|
|
|
['rand}str'], |
57
|
|
|
['rand(str'], |
58
|
|
|
['rand)str'], |
59
|
|
|
['rand/str'], |
60
|
|
|
['rand\\str'], |
61
|
|
|
['rand@str'], |
62
|
|
|
['rand:str'], |
63
|
|
|
[new \stdClass()], |
64
|
|
|
[['array']], |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testConstructorThrowsExceptionWhenNotMultiPuttableCacheIsUsed() |
69
|
|
|
{ |
70
|
|
|
/** @var NotMultiPuttableCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
71
|
|
|
$doctrineCache = $this->createMock(NotMultiPuttableCache::class); |
72
|
|
|
|
73
|
|
|
$this->expectException(CacheException::class); |
74
|
|
|
new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function testConstructorThrowsExceptionWhenNotClearableCacheIsUsed() |
78
|
|
|
{ |
79
|
|
|
/** @var NotClearableCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
80
|
|
|
$doctrineCache = $this->createMock(NotClearableCache::class); |
81
|
|
|
|
82
|
|
|
$this->expectException(CacheException::class); |
83
|
|
|
new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testConstructorThrowsExceptionWhenNotMultiGettableCacheIsUsed() |
87
|
|
|
{ |
88
|
|
|
/** @var NotMultiGettableCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
89
|
|
|
$doctrineCache = $this->createMock(NotMultiGettableCache::class); |
90
|
|
|
|
91
|
|
|
$this->expectException(CacheException::class); |
92
|
|
|
new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
View Code Duplication |
public function testGetProxiesToDoctrineFetch() |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
$key = uniqid('key', true); |
98
|
|
|
$value = uniqid('value', true); |
99
|
|
|
|
100
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
101
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
102
|
|
|
$doctrineCache->expects(self::once())->method('fetch')->with($key)->willReturn($value); |
|
|
|
|
103
|
|
|
|
104
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
105
|
|
|
self::assertSame($value, $psrCache->get($key)); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function testGetWithNotExistingKey() |
109
|
|
|
{ |
110
|
|
|
$key = uniqid('key', true); |
111
|
|
|
$value = uniqid('value', true); |
112
|
|
|
|
113
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
114
|
|
|
$psrCache->set($key, $value); |
115
|
|
|
|
116
|
|
|
$default = uniqid('default', true); |
117
|
|
|
self::assertSame($value, $psrCache->get($key, $default)); |
118
|
|
|
|
119
|
|
|
$anotherKey = uniqid('key', true); |
120
|
|
|
self::assertSame($default, $psrCache->get($anotherKey, $default)); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
View Code Duplication |
public function testGetWithFalseValueStoredInCache() |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
$key = uniqid('key', true); |
126
|
|
|
|
127
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
128
|
|
|
$psrCache->set($key, false); |
129
|
|
|
|
130
|
|
|
self::assertFalse($psrCache->get($key, uniqid('default', true))); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function testSetProxiesToDoctrineSave() |
134
|
|
|
{ |
135
|
|
|
$key = uniqid('key', true); |
136
|
|
|
$value = uniqid('value', true); |
137
|
|
|
$ttl = random_int(1000, 9999); |
138
|
|
|
|
139
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
140
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
141
|
|
|
$doctrineCache->expects(self::once())->method('save')->with($key, $value, $ttl)->willReturn(true); |
|
|
|
|
142
|
|
|
|
143
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
144
|
|
|
self::assertTrue($psrCache->set($key, $value, $ttl)); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function testSetWithDateIntervalTTL() |
148
|
|
|
{ |
149
|
|
|
$key = uniqid('key', true); |
150
|
|
|
$value = uniqid('value', true); |
151
|
|
|
$ttl_date = \DateInterval::createFromDateString('1 day'); |
152
|
|
|
|
153
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
154
|
|
|
|
155
|
|
|
// This does not test if ttl is correctly set to 86400 sec. |
156
|
|
|
self::assertTrue($psrCache->set($key, $value, $ttl_date)); |
157
|
|
|
self::assertSame($psrCache->get($key), $value); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function testSetWithNonPositiveTTL() |
161
|
|
|
{ |
162
|
|
|
$key = uniqid('key', true); |
163
|
|
|
$value = uniqid('value', true); |
164
|
|
|
$ttl = random_int(1000, 9999); |
165
|
|
|
|
166
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
167
|
|
|
|
168
|
|
|
$psrCache->set($key, $value, $ttl); |
169
|
|
|
self::assertSame($psrCache->get($key), $value); |
170
|
|
|
|
171
|
|
|
$psrCache->set($key, $value, -1); |
172
|
|
|
self::assertNull($psrCache->get($key), null); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param mixed $ttl |
177
|
|
|
* @dataProvider invalidTTLs |
178
|
|
|
*/ |
179
|
|
View Code Duplication |
public function testSetWithInvalidTTL($ttl) |
|
|
|
|
180
|
|
|
{ |
181
|
|
|
$key = uniqid('key', true); |
182
|
|
|
$value = uniqid('value', true); |
183
|
|
|
|
184
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
185
|
|
|
|
186
|
|
|
$this->expectException(InvalidArgumentException::class); |
187
|
|
|
$psrCache->set($key, $value, $ttl); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
View Code Duplication |
public function testDeleteProxiesToDoctrineDelete() |
|
|
|
|
191
|
|
|
{ |
192
|
|
|
$key = uniqid('key', true); |
193
|
|
|
|
194
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
195
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
196
|
|
|
$doctrineCache->expects(self::once())->method('delete')->with($key)->willReturn(true); |
|
|
|
|
197
|
|
|
|
198
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
199
|
|
|
self::assertTrue($psrCache->delete($key)); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function testClearProxiesToDeleteAll() |
203
|
|
|
{ |
204
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
205
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
206
|
|
|
$doctrineCache->expects(self::once())->method('deleteAll')->with()->willReturn(true); |
|
|
|
|
207
|
|
|
|
208
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
209
|
|
|
self::assertTrue($psrCache->clear()); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function testGetMultipleProxiesToFetchMultiple() |
213
|
|
|
{ |
214
|
|
|
$values = [ |
215
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
216
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
217
|
|
|
]; |
218
|
|
|
$keys = array_keys($values); |
219
|
|
|
|
220
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
221
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
222
|
|
|
$doctrineCache->expects(self::once())->method('fetchMultiple')->with($keys)->willReturn($values); |
|
|
|
|
223
|
|
|
|
224
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
225
|
|
|
self::assertSame($values, $psrCache->getMultiple($keys)); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function testGetMultipleWithPartialKeys() |
229
|
|
|
{ |
230
|
|
|
$values = [ |
231
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
232
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
233
|
|
|
]; |
234
|
|
|
$keys = array_keys($values); |
235
|
|
|
|
236
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
237
|
|
|
$psrCache->setMultiple($values); |
238
|
|
|
|
239
|
|
|
$default = uniqid('default', true); |
240
|
|
|
$invalid_key = uniqid('key3', true); |
241
|
|
|
$keys[] = $invalid_key; |
242
|
|
|
$values[$invalid_key] = $default; |
243
|
|
|
|
244
|
|
|
self::assertSame($values, $psrCache->getMultiple($keys, $default)); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @param mixed $key |
249
|
|
|
* @dataProvider invalidKeys |
250
|
|
|
*/ |
251
|
|
|
public function testGetMultipleThrowsExceptionWithInvalidKeys($key) |
252
|
|
|
{ |
253
|
|
|
$this->expectException(InvalidArgumentException::class); |
254
|
|
|
|
255
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
256
|
|
|
$psrCache->getMultiple([$key]); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @param mixed $key |
261
|
|
|
* @dataProvider validKeys |
262
|
|
|
*/ |
263
|
|
View Code Duplication |
public function testGetMultipleAcceptsTraversable($key) |
|
|
|
|
264
|
|
|
{ |
265
|
|
|
$values = [ |
266
|
|
|
$key => uniqid('value', true), |
267
|
|
|
]; |
268
|
|
|
|
269
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
270
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
271
|
|
|
$doctrineCache->expects(self::once())->method('fetchMultiple')->with(array_keys($values))->willReturn($values); |
|
|
|
|
272
|
|
|
|
273
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
274
|
|
|
$psrCache->getMultiple(new \ArrayObject(array_keys($values))); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function testGetMultipleAcceptsGenerator() |
278
|
|
|
{ |
279
|
|
|
$values = [ |
280
|
|
|
uniqid('key0', true) => uniqid('value0', true), |
281
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
282
|
|
|
]; |
283
|
|
|
|
284
|
|
|
$generator = function () use ($values) { |
285
|
|
|
/** @noinspection ForeachOnArrayComponentsInspection */ |
286
|
|
|
foreach (array_keys($values) as $k) { |
287
|
|
|
yield $k; |
288
|
|
|
} |
289
|
|
|
}; |
290
|
|
|
|
291
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
292
|
|
|
$psrCache->setMultiple($values); |
293
|
|
|
|
294
|
|
|
self::assertSame($values, $psrCache->getMultiple($generator())); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
View Code Duplication |
public function testGetMultipleThrowsExceptionWhenNotArrayOrTraversable() |
|
|
|
|
298
|
|
|
{ |
299
|
|
|
$this->expectException(InvalidArgumentException::class); |
300
|
|
|
|
301
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
302
|
|
|
$psrCache->getMultiple(uniqid('string', true)); |
|
|
|
|
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
public function testSetMultipleProxiesToSaveMultiple() |
306
|
|
|
{ |
307
|
|
|
$values = [ |
308
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
309
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
310
|
|
|
]; |
311
|
|
|
|
312
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
313
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
314
|
|
|
$doctrineCache->expects(self::once())->method('saveMultiple')->with($values)->willReturn(true); |
|
|
|
|
315
|
|
|
|
316
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
317
|
|
|
self::assertTrue($psrCache->setMultiple($values)); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
public function testSetMultipleWithDateIntervalTTL() |
321
|
|
|
{ |
322
|
|
|
$values = [ |
323
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
324
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
325
|
|
|
]; |
326
|
|
|
$keys = array_keys($values); |
327
|
|
|
$ttl_date = \DateInterval::createFromDateString('1 day'); |
328
|
|
|
|
329
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
330
|
|
|
|
331
|
|
|
// This does not test if ttl is correctly set to 86400 sec. |
332
|
|
|
self::assertTrue($psrCache->setMultiple($values, $ttl_date)); |
333
|
|
|
self::assertSame($values, $psrCache->getMultiple($keys)); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
public function testSetMultipleWithNonPositiveTTL() |
337
|
|
|
{ |
338
|
|
|
$values = [ |
339
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
340
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
341
|
|
|
]; |
342
|
|
|
$keys = array_keys($values); |
343
|
|
|
|
344
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
345
|
|
|
$psrCache->setMultiple($values); |
346
|
|
|
|
347
|
|
|
$volatile = [$keys[0] => uniqid('value3', true)]; |
348
|
|
|
$psrCache->setMultiple($volatile, -1); |
349
|
|
|
|
350
|
|
|
self::assertNull($psrCache->get($keys[0])); |
351
|
|
|
self::assertNotNull($psrCache->get($keys[1])); |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* @param mixed $ttl |
356
|
|
|
* @dataProvider invalidTTLs |
357
|
|
|
*/ |
358
|
|
|
public function testSetMultipleWithInvalidTTL($ttl) |
359
|
|
|
{ |
360
|
|
|
$values = [ |
361
|
|
|
uniqid('key1', true) => uniqid('value1', true), |
362
|
|
|
uniqid('key2', true) => uniqid('value2', true), |
363
|
|
|
]; |
364
|
|
|
|
365
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
366
|
|
|
|
367
|
|
|
$this->expectException(InvalidArgumentException::class); |
368
|
|
|
$psrCache->setMultiple($values, $ttl); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
View Code Duplication |
public function testSetMultipleThrowsExceptionWhenNotArrayOrTraversable() |
|
|
|
|
372
|
|
|
{ |
373
|
|
|
$this->expectException(InvalidArgumentException::class); |
374
|
|
|
|
375
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
376
|
|
|
$psrCache->setMultiple(uniqid('string', true)); |
|
|
|
|
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
public function testSetMultipleAcceptsGenerator() |
380
|
|
|
{ |
381
|
|
|
$key0 = uniqid('key0', true); |
382
|
|
|
$key1 = uniqid('key1', true); |
383
|
|
|
$values = [ |
384
|
|
|
$key0 => uniqid('value0', true), |
385
|
|
|
$key1 => uniqid('value1', true), |
386
|
|
|
]; |
387
|
|
|
|
388
|
|
|
$generator = function () use ($values) { |
389
|
|
|
foreach ($values as $k => $v) { |
390
|
|
|
yield $k => $v; |
391
|
|
|
} |
392
|
|
|
}; |
393
|
|
|
|
394
|
|
|
$psrCache = new SimpleCacheAdapter(new ArrayCache()); |
395
|
|
|
$psrCache->setMultiple($generator()); |
396
|
|
|
|
397
|
|
|
self::assertSame($values[$key0], $psrCache->get($key0)); |
398
|
|
|
self::assertSame($values[$key1], $psrCache->get($key1)); |
399
|
|
|
} |
400
|
|
|
|
401
|
|
View Code Duplication |
public function testDeleteMultipleReturnsTrueWhenAllDeletesSucceed() |
|
|
|
|
402
|
|
|
{ |
403
|
|
|
$keys = [ |
404
|
|
|
uniqid('key1', true), |
405
|
|
|
uniqid('key2', true), |
406
|
|
|
]; |
407
|
|
|
|
408
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
409
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
410
|
|
|
$doctrineCache->expects(self::at(0))->method('delete')->with($keys[0])->willReturn(true); |
|
|
|
|
411
|
|
|
$doctrineCache->expects(self::at(1))->method('delete')->with($keys[1])->willReturn(true); |
412
|
|
|
|
413
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
414
|
|
|
self::assertTrue($psrCache->deleteMultiple($keys)); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
View Code Duplication |
public function testDeleteMultipleReturnsFalseWhenOneDeleteFails() |
|
|
|
|
418
|
|
|
{ |
419
|
|
|
$keys = [ |
420
|
|
|
uniqid('key1', true), |
421
|
|
|
uniqid('key2', true), |
422
|
|
|
]; |
423
|
|
|
|
424
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
425
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
426
|
|
|
$doctrineCache->expects(self::at(0))->method('delete')->with($keys[0])->willReturn(false); |
|
|
|
|
427
|
|
|
$doctrineCache->expects(self::at(1))->method('delete')->with($keys[1])->willReturn(true); |
428
|
|
|
|
429
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
430
|
|
|
self::assertFalse($psrCache->deleteMultiple($keys)); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
View Code Duplication |
public function testHasProxiesToDoctrineContains() |
|
|
|
|
434
|
|
|
{ |
435
|
|
|
$key = uniqid('key', true); |
436
|
|
|
|
437
|
|
|
/** @var FullyImplementedCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */ |
438
|
|
|
$doctrineCache = $this->createMock(FullyImplementedCache::class); |
439
|
|
|
$doctrineCache->expects(self::once())->method('contains')->with($key)->willReturn(true); |
|
|
|
|
440
|
|
|
|
441
|
|
|
$psrCache = new SimpleCacheAdapter($doctrineCache); |
|
|
|
|
442
|
|
|
self::assertTrue($psrCache->has($key)); |
443
|
|
|
} |
444
|
|
|
} |
445
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.