Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Fix ArrayAdapter::freeze() return type #52040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function generateItems(array $keys, float $now, \Closure $f): \Generator
}
}

private function freeze($value, string $key): string|int|float|bool|array|null
private function freeze($value, string $key): string|int|float|bool|array|\UnitEnum|null
{
if (null === $value) {
return 'N;';
Expand Down
11 changes: 11 additions & 0 deletions 11 src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Tests\Fixtures\TestEnum;

/**
* @group time-sensitive
Expand Down Expand Up @@ -91,4 +92,14 @@ public function testMaxItems()
$this->assertTrue($cache->hasItem('buz'));
$this->assertTrue($cache->hasItem('foo'));
}

public function testEnum()
{
$cache = new ArrayAdapter();
$item = $cache->getItem('foo');
$item->set(TestEnum::Foo);
$cache->save($item);

$this->assertSame(TestEnum::Foo, $cache->getItem('foo')->get());
}
}
17 changes: 17 additions & 0 deletions 17 src/Symfony/Component/Cache/Tests/Fixtures/TestEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Cache\Tests\Fixtures;

enum TestEnum
{
case Foo;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.