Skip to content

Conversation

@andrew-demb
Copy link
Contributor

https://www.php.net/manual/en/class.weakmap.php

Using WeakMap will avoid preserving objects in memory if they are presented only in cache

@andrew-demb
Copy link
Contributor Author

I'll push fixes ASAP

@garak garak requested a review from stof May 8, 2025 16:09
@garak garak requested a review from Copilot May 23, 2025 12:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request replaces the existing SplObjectStorage–based cache with a WeakMap to prevent objects from being retained in memory solely by the cache.

  • Swapped out SplObjectStorage for WeakMap in the Matcher class
  • Updated docblocks and constructor/clear logic to use WeakMap
  • Changed cache lookup from contains() to offsetExists()
Comments suppressed due to low confidence (1)

src/Knp/Menu/Matcher/Matcher.php:74

  • Add unit tests to verify that the WeakMap-based cache correctly stores and expires items, including behavior of the clear() method.
$this->cache = new \WeakMap();

@stof stof merged commit 6a9bf07 into KnpLabs:master Jun 13, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants