👩💻 Join our community of thousands of amazing developers!
So, Caleb Porzio recently shared a little memoize function in PHP. What the function does is pretty straightforward. It caches the result of a function call and returns the cached result if the function is called again with the same arguments. Here’s the function. function memoize($target) { static $memo = new WeakMap; return new class ($target, $memo) { function __construct( protected $target, protected &$memo, ) {} function __call($met...