I'm trying to write a memoization function, and I just realized this solution does not work when the callback is not a simple string. For example, PHP can accept a callback in the form array($this,'memberFunc')
, which is not amenable to serialization.
Then I realized that we don't really want to hash/serialize the whole callback function/object anyway, we just need a unique ID for it so we can check for reference equality. I thought spl_object_hash
would do the trick, but it doesn't work on arrays.
Is there another way to generate a unique reference ID for a callable?