public function set($key, $value)
    {
        if (is_array($key) && $value === null)
            $args = $key;
        else
            $args = func_get_args();

        $value = array_pop($args);
        
        $parent = null;
        $key = null;
        $ref = &$this->values;
        foreach ($args as $arg)
        {
            if (!is_scalar($arg))
                throw new \InvalidArgumentException("Keys must be scalar, not: " . WF::str($arg));

            if (!is_array($ref))
            {
                if ($parent !== null)
                    $parent[$key] = array();
                $ref = &$parent[$key];
            }
                
            if (!isset($ref[$arg]))
                $ref[$arg] = array();

            $parent = &$ref;
            $key = $arg;
            $ref = &$ref[$arg];
        }

        // Unwrap Dictionary objects
        $cl = is_object($value) ? get_class($value) : null;
        if ($cl === Dictionary::class)
            $ref = $value->getAll();
        else
            $ref = $value;

        return $this;
    }
public function set($key, $value)
    {
        if (is_array($key) && $value === null)
            $args = $key;
        else
            $args = func_get_args();

        $value = array_pop($args);
        
        $parent = null;
        $key = null;
        $ref = &$this->values;
        foreach ($args as $arg)
        {
            if (!is_scalar($arg))
                throw new \InvalidArgumentException("Keys must be scalar, not: " . WF::str($arg));

            if (!is_array($ref))
            {
                if ($parent !== null)
                    $parent[$key] = array();
                $ref = &$parent[$key];
            }
                
            if (!isset($ref[$arg]))
                $ref[$arg] = array();

            $parent = &$ref;
            $key = $arg;
            $ref = &$ref[$arg];
        }

        // Unwrap Dictionary objects
        $cl = is_object($value) ? get_class($value) : null;
        if ($cl === Dictionary::class)
            $ref = $value->getAll();
        else
            $ref = $value;

        return $this;
    }
public function set ( $ key , $ value ) { if ( is_array ( $ key ) && $ value === null ) $ args = $ key ; else $ args = func_get_args ( ) ; $ value = array_pop ( $ args ) ; $ parent = null ; $ key = null ; $ ref = & $ this -> values ; foreach ( $ args as $ arg ) { if ( ! is_scalar ( $ arg ) ) throw new \ InvalidArgumentException ( "Keys must be scalar, not: " . WF :: str ( $ arg ) ) ; if ( ! is_array ( $ ref ) ) { if ( $ parent !== null ) $ parent [ $ key ] = array ( ) ; $ ref = & $ parent [ $ key ] ; } if ( ! isset ( $ ref [ $ arg ] ) ) $ ref [ $ arg ] = array ( ) ; $ parent = & $ ref ; $ key = $ arg ; $ ref = & $ ref [ $ arg ] ; } // Unwrap Dictionary objects $ cl = is_object ( $ value ) ? get_class ( $ value ) : null ; if ( $ cl === Dictionary :: class ) $ ref = $ value -> getAll ( ) ; else $ ref = $ value ; return $ this ; }
Set a value in the dictionary

@param $key scalar The key to set. May be repeated to go deeper
@param $value mixed The value to set
@return Dictionary Provides fluent interface
Set a value in the dictionary