8000 minor #20172 [Cache] Accept only array in TagAwareAdapter::invalidate… · symfony/symfony@a5d134b · GitHub
[go: up one dir, main page]

Skip to content

Commit a5d134b

Browse files
committed
minor #20172 [Cache] Accept only array in TagAwareAdapter::invalidateTags() (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [Cache] Accept only array in TagAwareAdapter::invalidateTags() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Just to be sure that we won't suffer from some stupid incompatibility if a cache-tags PSR is published one day. See discussion: #19728 (comment) Commits ------- a08acc7 [Cache] Accept only array in TagAwareAdapter::invalidateTags()
2 parents eee1a44 + a08acc7 commit a5d134b

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ function ($deferred) {
6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function invalidateTags($tags)
70+
public function invalidateTags(array $tags)
7171
{
72-
if (!is_array($tags)) {
73-
$tags = array($tags);
74-
}
7572
foreach ($tags as $k => $tag) {
7673
if ('' !== $tag && is_string($tag)) {
7774
$tags[$k] = $tag.static::TAGS_PREFIX;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ interface TagAwareAdapterInterface extends AdapterInterface
2323
/**
2424
* Invalidates cached items using tags.
2525
*
26-
* @param string|string[] $tags A tag or an array of tags to invalidate
26+
* @param string[] $tags An array of tags to invalidate
2727
*
2828
* @return bool True on success
2929
*
3030
* @throws InvalidArgumentException When $tags is not valid
3131
*/
32-
public function invalidateTags($tags);
32+
public function invalidateTags(array $tags);
3333
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public function testInvalidateTags()
5555
$pool->save($i3->tag('foo')->tag('baz'));
5656
$pool->save($foo);
5757

58-
$pool->invalidateTags('bar');
58+
$pool->invalidateTags(array('bar'));
5959

6060
$this->assertFalse($pool->getItem('i0')->isHit());
6161
$this->assertTrue($pool->getItem('i1')->isHit());
6262
$this->assertFalse($pool->getItem('i2')->isHit());
6363
$this->assertTrue($pool->getItem('i3')->isHit());
6464
$this->assertTrue($pool->getItem('foo')->isHit());
6565

66-
$pool->invalidateTags('foo');
66+
$pool->invalidateTags(array('foo'));
6767

6868
$this->assertFalse($pool->getItem('i1')->isHit());
6969
$this->assertFalse($pool->getItem('i3')->isHit());
@@ -80,7 +80,7 @@ public function testTagsAreCleanedOnSave()
8080
$i = $pool->getItem('k');
8181
$pool->save($i->tag('bar'));
8282

83-
$pool->invalidateTags('foo');
83+
$pool->invalidateTags(array('foo'));
8484
$this->assertTrue($pool->getItem('k')->isHit());
8585
}
8686

@@ -93,7 +93,7 @@ public function testTagsAreCleanedOnDelete()
9393
$pool->deleteItem('k');
9494

9595
$pool->save($pool->getItem('k'));
96-
$pool->invalidateTags('foo');
96+
$pool->invalidateTags(array('foo'));
9797

9898
$this->assertTrue($pool->getItem('k')->isHit());
9999
}

0 commit comments

Comments
 (0)
0