File indexing completed on 2025-02-23 05:32:07
0001 <?php 0002 0003 namespace Psr\Http\Message; 0004 0005 /** 0006 * Representation of an outgoing, server-side response. 0007 * 0008 * Per the HTTP specification, this interface includes properties for 0009 * each of the following: 0010 * 0011 * - Protocol version 0012 * - Status code and reason phrase 0013 * - Headers 0014 * - Message body 0015 * 0016 * Responses are considered immutable; all methods that might change state MUST 0017 * be implemented such that they retain the internal state of the current 0018 * message and return an instance that contains the changed state. 0019 */ 0020 interface ResponseInterface extends MessageInterface 0021 { 0022 /** 0023 * Gets the response status code. 0024 * 0025 * The status code is a 3-digit integer result code of the server's attempt 0026 * to understand and satisfy the request. 0027 * 0028 * @return int Status code. 0029 */ 0030 public function getStatusCode(); 0031 0032 /** 0033 * Return an instance with the specified status code and, optionally, reason phrase. 0034 * 0035 * If no reason phrase is specified, implementations MAY choose to default 0036 * to the RFC 7231 or IANA recommended reason phrase for the response's 0037 * status code. 0038 * 0039 * This method MUST be implemented in such a way as to retain the 0040 * immutability of the message, and MUST return an instance that has the 0041 * updated status and reason phrase. 0042 * 0043 * @link http://tools.ietf.org/html/rfc7231#section-6 0044 * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 0045 * @param int $code The 3-digit integer result code to set. 0046 * @param string $reasonPhrase The reason phrase to use with the 0047 * provided status code; if none is provided, implementations MAY 0048 * use the defaults as suggested in the HTTP specification. 0049 * @return static 0050 * @throws \InvalidArgumentException For invalid status code arguments. 0051 */ 0052 public function withStatus($code, $reasonPhrase = ''); 0053 0054 /** 0055 * Gets the response reason phrase associated with the status code. 0056 * 0057 * Because a reason phrase is not a required element in a response 0058 * status line, the reason phrase value MAY be null. Implementations MAY 0059 * choose to return the default RFC 7231 recommended reason phrase (or those 0060 * listed in the IANA HTTP Status Code Registry) for the response's 0061 * status code. 0062 * 0063 * @link http://tools.ietf.org/html/rfc7231#section-6 0064 * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 0065 * @return string Reason phrase; must return an empty string if none present. 0066 */ 0067 public function getReasonPhrase(); 0068 }