Have you ever used PHP `WeakMap` or Fiber in your project?
TBH, I don't know about this just saw in the PHP doc..
www.php.net/manual/en/class.weakmap.php
www.php.net/manual/en/class.fiber.php
Have you ever used PHP `WeakMap` or Fiber in your project?
TBH, I don't know about this just saw in the PHP doc..
www.php.net/manual/en/class.weakmap.php
If you have not need to write any cooperative multi-tasking type operations since PHP8, such as thread pools or anything where you need fine grained control over async operations, you probably haven’t needed to consider the Fibers feature & Fiber class.
Weakmap is a lot more common. Good for storing data against an object key, which is cleaned up when the object is destructed.
Fibres are something that you probably wouldn't ever use yourself. They're effectively there for framework authors, but end devs are unlikely to ever need to touch them.
WeakMap and WeakReference are more useful - they're a great way to hold onto things that you might want to let get garbage collected.