Parses a PHP style key value pair.

@param string      $key    Key to parse (e.g., "foo[a][b]")
@param string|null $value  Value to set
@param array       $result Result to modify by reference
492292
private function parsePhpValue($key, $value, array &$result)
    {
        $node =& $result;
        $keyBuffer = '';

        for ($i = 0, $t = strlen($key); $i < $t; $i++) {
            switch ($key[$i]) {
                case '[':
                    if ($keyBuffer) {
                        $this->prepareNode($node, $keyBuffer);
                        $node =& $node[$keyBuffer];
                        $keyBuffer = '';
                    }
                    break;
                case ']':
                    $k = $this->cleanKey($node, $keyBuffer);
                    $this->prepareNode($node, $k);
                    $node =& $node[$k];
                    $keyBuffer = '';
                    break;
                default:
                    $keyBuffer .= $key[$i];
                    break;
            }
        }

        if (isset($node)) {
            $this->duplicates = true;
            $node[] = $value;
        } else {
            $node = $value;
        }
    }
444083
public function set(string $key, $value = null)
    {
        return Arr::set($this->items, $key, \value($value));
    }
486256
protected function setSingleItem($key, $value = null, $load = true)
    {
        list($namespace, $group, $item) = $this->parseKey($key);

        $collection = $this->getCollection($group, $namespace);

        if ($load) {
            $this->load($group, $namespace, $collection);
        }

        if (is_null($item)) {
            $this->items[$collection] = $value;
        } else {
            Arr::set($this->items[$collection], $item, $value);
        }
    }
150643
public static function parse($value)
    {
        if (is_array($value)) {
            return static::fromArray((array)$value);
        } elseif (is_string($value)) {
            return static::fromString((string)$value);
        } else {
            return null;
        }
    }
213157
public function set($key, $value)
    {
        $keys = explode('.', $key);
        $key_string = '';
        foreach ($keys as $i => $_key) {
            $key_string = $key_string . ((is_numeric($_key) || $_key === '') ? "[{$_key}]" : "['{$_key}']");
        }
        $script = sprintf('$this->_params%s = $value;', $key_string);
        eval($script);
    }
1351642
public static function assign($key, $value = null) {

		if(true === is_array($key)) {
			static :: $variables = array_merge(static :: $variables, $key);
		}
		else {
			static :: $variables[$key] = $value;
		}
	}
989400
public function set($key, $value = null)
    {
        return self::setValue($this->data, $key, $value);
    }
1319475
protected function getValue( $key, $value = null )
	{
		if( is_null( $value ) && isset( $this->args[$key] )) {
			$value = $this->args[$key];
		}
		return $value;
	}
88877
public function set(string $key, $value)
    {
        if (!is_array($value)) {
            $value = [$value];
        }
        $this->data[$key] = $value;
    }
1362876
public static function getObjectWithKeyAndValue(array $array, $key, $value)
    {
        foreach ($array as $object) {
            if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) {
                return $object;
            }
        }

        return null;
    }
592501
private function addOutput(string $key, string $value = null)
    {
        if (!array_key_exists($key, $this->output)) {
            $this->output[$key] = [];
        }

        $this->output[$key][] = $value;
    }
104444
public static function parse($value)
    {
        $expression = Expression::getExpression();

        $return = preg_match(
            $expression,
            $value,
            $matches
        );

        if (!$return) {
            return null;
        }

        $parsed = new \stdClass();

        $parsed->key = $matches['key'];
        $parsed->mode = Globals::KEY_VARIABLE;

        if (isset($matches['function']) && !empty($matches['function'])) {
            $parsed->mode = Globals::KEY_FUNCTION;

            if (key_exists('parameters', $matches)  && strlen((string)$matches['parameters'])) {
                //Handles only one parameter
                $parsed->parameters = [$matches['parameters']];
            }
        } elseif (isset($matches['array'])  && !empty($matches['array'])) {
            $parsed->mode = Globals::KEY_ARRAY;
            //should exists
            $parsed->index = $matches['index'];
        }

        return $parsed;
    }
1295895
protected function parseKey($key, callable $callback, ?array $result = null)
    {
        $parts = is_array($key) ? $key : explode('.', trim($key, '.'));
        $result = $result ?: $this->toArray();

        while (!is_null($part = array_shift($parts))) {
            if ($part == '*') {
                array_walk($result, function (&$value) use ($parts, $callback) {
                    $value = $this->parseKey($parts, $callback, $value);
                });

                return $result;
            }

            if (!$return = $callback($part, $result)) {
                return $return;
            }

            $result = $result[$part];
        }

        return $return;
    }
849913
public function set($key, $value = null)
    {
        list($namespace, $group, $item) = $this->parseKey($key);

        $collection = $this->getCollection($group, $namespace);

        // We'll need to go ahead and lazy load each configuration groups even when
        // we're just setting a configuration item so that the set item does not
        // get overwritten if a different item in the group is requested later.
        $this->load($group, $namespace, $collection);

        if ($item === null) {
            $this->items[$collection] = $value;
        } else {
            array_set($this->items[$collection], $item, $value);
        }
    }
1193983
public function result($name = null, $value = null)
    {
        if ($name === null) {
            return $this->result;
        }
        if (array_key_exists($name, $this->result)) {
            if ($value === null) {
                return $this->result[$name];
            }
            $this->result[$name] = $value;
        }
    }
1267080
public function post($key = null, $value = null)
    {
        if (!is_null($this->except)) {
            $this->skip();
        }

        if (!is_null($key) && !string_has($key, '.') && is_null($value)) {
            $postValue = '';
            $key = $this->security->sanitize($key);
            $postValue = $this->security->sanitize($this->request['post'][$key]);
            $this->request['post'][$key] = $postValue;

            if (array_key_exists($key, $this->request['post'])) {
                return $this->request['post'][$key];
            }

            throw new InvalidArgumentException("Invalid key $key passed to ".__METHOD__);
        }

        /*
         | User can access post array element by passing
         | key as dot separator with index
         | ['user' => ['name' => 'foo']]
         |
         | $input->post('user.name'); // output: foo
         */
        if (!is_null($key) && string_has($key, '.') && is_null($value)) {
            $arr = ArrayAccessor::make($this->request['post']);

            return $arr->toString($this->security->sanitize($key));
        }

        $this->setPostValue($key, $value);

        if (is_null($key)) {
            $postArr = $this->security->sanitize($this->request['post']);

            return (!empty($postArr)) ? $postArr : null;
        }
    }
1000107
public function set(string $key, $value)
    {
        if (!is_array($value)) {
            $value = [$value];
        }
        $this->normSet($key, $value);
    }