Skip to content

Commit

Permalink
Revert "Allow Request::query() to return all query strings."
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 27, 2016
1 parent bfd8117 commit 6d9f2fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
18 changes: 7 additions & 11 deletions src/Network/Request.php
Expand Up @@ -584,9 +584,9 @@ public function __call($name, $params)
{
if (strpos($name, 'is') === 0) {
$type = strtolower(substr($name, 2));

array_unshift($params, $type);

return call_user_func_array([$this, 'is'], $params);
}
throw new BadMethodCallException(sprintf('Method %s does not exist', $name));
Expand Down Expand Up @@ -639,7 +639,7 @@ public function is($type)

return count(array_filter($result)) > 0;
}

$args = func_get_args();
array_shift($args);

Expand All @@ -651,7 +651,7 @@ public function is($type)
if ($args) {
return $this->_is($type, $args);
}

if (!isset($this->_detectorCache[$type])) {
$this->_detectorCache[$type] = $this->_is($type, $args);
}
Expand Down Expand Up @@ -1161,15 +1161,11 @@ protected function _parseAcceptWithQualifier($header)
* Provides a read accessor for `$this->query`. Allows you
* to use a syntax similar to `CakeSession` for reading URL query data.
*
* @param string|null $name Query string variable name or null to read all.
* @return string|array|null The value being read
* @param string $name Query string variable name
* @return mixed The value being read
*/
public function query($name = null)
public function query($name)
{
if ($name === null) {
return $this->query;
}

return Hash::get($this->query, $name);
}

Expand Down
8 changes: 2 additions & 6 deletions tests/TestCase/Network/RequestTest.php
Expand Up @@ -2000,10 +2000,9 @@ public function testEnvironmentDetection($name, $env, $expected)
*/
public function testQuery()
{
$array = [
$request = new Request([
'query' => ['foo' => 'bar', 'zero' => '0']
];
$request = new Request($array);
]);

$result = $request->query('foo');
$this->assertSame('bar', $result);
Expand All @@ -2013,9 +2012,6 @@ public function testQuery()

$result = $request->query('imaginary');
$this->assertNull($result);

$result = $request->query();
$this->assertSame($array['query'], $result);
}

/**
Expand Down

0 comments on commit 6d9f2fc

Please sign in to comment.