public function replace($key, $value)
    {
        $currentValue = $this->get($key);

        if ($this->containsKey($key)) {
            $this[$key] = $value;
        }

        return $currentValue;
    }
public function replace($key, $value)
    {
        $currentValue = $this->get($key);

        if ($this->containsKey($key)) {
            $this[$key] = $value;
        }

        return $currentValue;
    }
public function replace ( $ key , $ value ) { $ currentValue = $ this -> get ( $ key ) ; if ( $ this -> containsKey ( $ key ) ) { $ this [ $ key ] = $ value ; } return $ currentValue ; }
Replaces the entry for the specified key only if it is currently mapped
to some value.

@param mixed $key The key to replace.
@param mixed $value The value to set at `$key`.

@return mixed|null the previous value associated with key, or `null` if
there was no mapping for `$key`.
Replaces the entry for the specified key only if it is currently mapped to some value .