Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d52c315

Browse files
committed
[Cache] Fix ArrayAdapter::freeze() return type
1 parent 21599a4 commit d52c315

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private function generateItems(array $keys, float $now, \Closure $f): \Generator
298298
}
299299
}
300300

301-
private function freeze($value, string $key): string|int|float|bool|array|null
301+
private function freeze($value, string $key): string|int|float|bool|array|\UnitEnum|null
302302
{
303303
if (null === $value) {
304304
return 'N;';

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\ArrayAdapter;
16+
use Symfony\Component\Cache\Tests\Fixtures\TestEnum;
1617

1718
/**
1819
* @group time-sensitive
@@ -91,4 +92,14 @@ public function testMaxItems()
9192
$this->assertTrue($cache->hasItem('buz'));
9293
$this->assertTrue($cache->hasItem('foo'));
9394
}
95+
96+
public function testEnum()
97+
{
98+
$cache = new ArrayAdapter();
99+
$item = $cache->getItem('foo');
100+
$item->set(TestEnum::Foo);
101+
$cache->save($item);
102+
103+
$this->assertSame(TestEnum::Foo, $cache->getItem('foo')->get());
104+
}
94105
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Tests\Fixtures;
13+
14+
enum TestEnum
15+
{
16+
case Foo;
17+
}

0 commit comments

Comments
 (0)