Skip to content

Commit

Permalink
Merge pull request #23 from weierophinney/feature/parsed-body
Browse files Browse the repository at this point in the history
Body parameters are the parsed body.
  • Loading branch information
Paul M. Jones committed Feb 13, 2015
2 parents 7848b93 + 5946843 commit 4727540
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/ServerRequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,46 @@ public function getFileParams();
/**
* Retrieve any parameters provided in the request body.
*
* If the request body can be deserialized to an array, this method MAY be
* used to retrieve them.
* If the request Content-Type is application/x-www-form-urlencoded and the
* request method is POST, this method MUST return the contents of $_POST.
*
* @return array The deserialized body parameters, if any.
* Otherwise, this method may return any results of deserializing
* the request body content; as parsing returns structured content, the
* potential types MUST be arrays or objects only. A null value indicates
* the absence of body content.
*
* @return null|array|object The deserialized body parameters, if any.
* These will typically be an array or object.
*/
public function getBodyParams();
public function getParsedBody();

/**
* Create a new instance with the specified body parameters.
*
* These MAY be injected during instantiation from PHP's $_POST
* superglobal. The data IS NOT REQUIRED to come from $_POST, but MUST be
* an array. This method can be used during the request lifetime to inject
* parameters discovered and/or deserialized from the request body; as an
* example, if content negotiation determines that the request data is
* a JSON payload, this method could be used to inject the deserialized
* parameters.
* These MAY be injected during instantiation.
*
* If the request Content-Type is application/x-www-form-urlencoded and the
* request method is POST, use this method ONLY to inject the contents of
* $_POST.
*
* The data IS NOT REQUIRED to come from $_POST, but MUST be the results of
* deserializing the request body content. Deserialization/parsing returns
* structured data, and, as such, this method ONLY accepts arrays or objects,
* or a null value if nothing was available to parse.
*
* As an example, if content negotiation determines that the request data
* is a JSON payload, this method could be used to create a request
* instance with the deserialized parameters.
*
* This method MUST be implemented in such a way as to retain the
* immutability of the message, and MUST return a new instance that has the
* updated body parameters.
*
* @param array $params The deserialized body parameters.
* @param null|array|object $data The deserialized body data. This will
* typically be in an array or object.
* @return self
*/
public function withBodyParams(array $params);
public function withParsedBody($data);

/**
* Retrieve attributes derived from the request.
Expand Down

0 comments on commit 4727540

Please sign in to comment.