public ArrayMapEntryMemory putWithCallback(Object key, Memory value, Runnable onAdd) {
        int hashCode = hash((key == null) ? NULL : key);
        int index = hashIndex(hashCode, data.length);
        ArrayMapEntryMemory entry = data[index];

        while (entry != null) {
            if (entry.hashCode == hashCode && isEqualKey(key, entry.getKey())) {
                //Memory oldValue = entry.getValue();
                updateEntry(entry, value);
                return entry;
            }

            entry = entry.next;
        }

        entry = addMapping(index, hashCode, key, value);
        if (onAdd != null) {
            onAdd.run();
        }

        return entry;
    }
Puts a key-value mapping into this map.

@param key   the key to add
@param value the value to add
@return the value previously mapped to this key, null if none
jphp-runtime/src/php/runtime/memory/support/ArrayMemoryMap.java