'bar' => array( 'baz' => 'foo bar', ), ), 'bar' => array( 'foo', 'bar', ), 'simple' => 'string', ), '::removeArrayValueForPath() removes a key'); $t->is(sfToolkit::removeArrayValueForPath($arr, 'barfoo'), null, '::removeArrayValueForPath() returns null if the key does not exist'); $t->is(sfToolkit::removeArrayValueForPath($arr, 'barfoo', 'bar'), 'bar', '::removeArrayValueForPath() takes the default value as a third argument'); $t->is(sfToolkit::removeArrayValueForPath($arr, 'foo[bar][baz][booze]'), null, '::removeArrayValueForPath() is not fooled by php mistaking strings and array'); $t->is(sfToolkit::removeArrayValueForPath($arr, 'foo[simple][bad]'), null, '::removeArrayValueForPath() is not fooled by php mistaking strings and array'); $t->is(sfToolkit::removeArrayValueForPath($arr, 'foo[bar][baz]'), 'foo bar', '::removeArrayValueForPath() works with deep paths'); $t->is($arr, array( 'foo' => array( 'bar' => array( ), ), 'bar' => array( 'foo', 'bar', ), 'simple' => 'string', ), '::removeArrayValueForPath() works with deep paths'); // ::addIncludePath() $t->diag('::addIncludePath()'); $path = get_include_path();
public function remove($name, $default = null, $ns = null) { if (!$ns) { $ns = $this->default_namespace; } $retval = $default; if (isset($this->parameters[$ns]) && array_key_exists($name, $this->parameters[$ns])) { $retval = $this->parameters[$ns][$name]; unset($this->parameters[$ns][$name]); } else { $retval = sfToolkit::removeArrayValueForPath($this->parameters[$ns], $name, $default); } return $retval; }
/** * Remove a parameter. * * @param string $name A parameter name * @param mixed $default A default parameter value * * @return string A parameter value, if the parameter was removed, otherwise null */ public function remove($name, $default = null) { $retval = $default; if (array_key_exists($name, $this->parameters)) { $retval = $this->parameters[$name]; unset($this->parameters[$name]); } else { $retval = sfToolkit::removeArrayValueForPath($this->parameters, $name, $default); } return $retval; }