8000 [HttpFoundation] Add Request::isMethodIdempotent method by dunglas · Pull Request #19322 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Add Request::isMethodIdempotent method #19322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix comments
  • Loading branch information
dunglas committed Jul 10, 2016
commit a778d94e0ef215d539d27a50b702cc0f149ededd
14 changes: 3 additions & 11 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ public function isMethod($method)
}

/**
* Checks whether the method is safe or not.
* Checks whether or not the method is safe.
*
* @return bool
*/
Expand All @@ -1483,21 +1483,13 @@ public function isMethodSafe()
}

/**
* Checks whether the method is idempotent or not.
* Checks whether or not the method is idempotent.
*
* @return bool
*/
public function isMethodIdempotent()
{
return in_array($this->getMethod(), array(
self::METHOD_HEAD,
self::METHOD_GET,
self::METHOD_PUT,
self::METHOD_DELETE,
self::METHOD_TRACE,
self::METHOD_OPTIONS,
self::METHOD_PURGE,
));
return in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ public function getLongHostNames()
}

/**
* @dataProvider methodProvider
* @dataProvider methodIdempotentProvider
*/
public function testMethodIdempotent($method, $idempotent)
{
Expand All @@ -1962,19 +1962,19 @@ public function testMethodIdempotent($method, $idempotent)
$this->assertEquals($idempotent, $request->isMethodIdempotent());
}

public function methodProvider()
public function methodIdempotentProvider()
{
return array(
array(Request::METHOD_HEAD, true),
array(Request::METHOD_GET, true),
array(Request::METHOD_POST, false),
array(Request::METHOD_PUT, true),
array(Request::METHOD_PATCH, false),
array(Request::METHOD_DELETE, true),
array(Request::METHOD_PURGE, true),
array(Request::METHOD_OPTIONS, true),
array(Request::METHOD_TRACE, true),
array(Request::METHOD_CONNECT, false),
array('HEAD', true),
array('GET', true),
array('POST', false),
array('PUT', true),
array('PATCH', false),
array('DELETE', true),
array('PURGE', true),
array('OPTIONS', true),
array('TRACE', true),
array('CONNECT', false),
);
}
}
Expand Down
0