Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/Knp/Menu/Matcher/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class Matcher implements MatcherInterface
{
/**
* @var \SplObjectStorage<ItemInterface, bool>
* @var \WeakMap<ItemInterface, bool>
*/
private \SplObjectStorage $cache;
private \WeakMap $cache;

/**
* @var iterable|VoterInterface[]
Expand All @@ -26,7 +26,7 @@ class Matcher implements MatcherInterface
public function __construct($voters = [])
{
$this->voters = $voters;
$this->cache = new \SplObjectStorage();
$this->cache = new \WeakMap();
}

public function isCurrent(ItemInterface $item): bool
Expand All @@ -36,7 +36,7 @@ public function isCurrent(ItemInterface $item): bool
return $current;
}

if ($this->cache->contains($item)) {
if ($this->cache->offsetExists($item)) {
return $this->cache[$item];
}

Expand Down Expand Up @@ -71,6 +71,6 @@ public function isAncestor(ItemInterface $item, ?int $depth = null): bool

public function clear(): void
{
$this->cache = new \SplObjectStorage();
$this->cache = new \WeakMap();
}
}