👩💻 Join our community of thousands of amazing developers!
Anonymous classes in PHP let you create a class on the fly without having to define a new class. They are especially useful when you want to create a class that is only used once. In my previous article, we checked out a memoize helper function that uses anonymous classes to cache the result of a function call. function memoize($target) { static $memo = new WeakMap; return new class ($target, $memo) { function __construct( protected $target, protected &$...