[HttpFoundation] tagged public @api

This commit is contained in:
Fabien Potencier 2011-07-20 10:06:02 +02:00
parent 311d691670
commit 7dcbcbe69d
16 changed files with 464 additions and 0 deletions

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* Represents a cookie
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @api
*/
class Cookie
{
@ -36,6 +38,8 @@ class Cookie
* @param string $domain The domain that the cookie is available to
* @param Boolean $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client
* @param Boolean $httpOnly Whether the cookie will be made accessible only through the HTTP protocol
*
* @api
*/
public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
{
@ -109,6 +113,8 @@ class Cookie
* Gets the name of the cookie.
*
* @return string
*
* @api
*/
public function getName()
{
@ -119,6 +125,8 @@ class Cookie
* Gets the value of the cookie.
*
* @return string
*
* @api
*/
public function getValue()
{
@ -129,6 +137,8 @@ class Cookie
* Gets the domain that the cookie is available to.
*
* @return string
*
* @api
*/
public function getDomain()
{
@ -139,6 +149,8 @@ class Cookie
* Gets the time the cookie expires.
*
* @return integer
*
* @api
*/
public function getExpiresTime()
{
@ -149,6 +161,8 @@ class Cookie
* Gets the path on the server in which the cookie will be available on.
*
* @return string
*
* @api
*/
public function getPath()
{
@ -159,6 +173,8 @@ class Cookie
* Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
*
* @return Boolean
*
* @api
*/
public function isSecure()
{
@ -169,6 +185,8 @@ class Cookie
* Checks whether the cookie will be made accessible only through the HTTP protocol.
*
* @return Boolean
*
* @api
*/
public function isHttpOnly()
{
@ -179,6 +197,8 @@ class Cookie
* Whether this cookie is about to be cleared
*
* @return Boolean
*
* @api
*/
public function isCleared()
{

View File

@ -19,6 +19,8 @@ use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
* A file in the file system.
*
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
*
* @api
*/
class File extends \SplFileInfo
{
@ -446,6 +448,8 @@ class File extends \SplFileInfo
* @param string $path The path to the file
*
* @throws FileNotFoundException If the given path is not a file
*
* @api
*/
public function __construct($path)
{
@ -462,6 +466,8 @@ class File extends \SplFileInfo
* If the mime type is unknown, returns null.
*
* @return string|null The guessed extension or null if it cannot be guessed
*
* @api
*/
public function guessExtension()
{
@ -478,6 +484,8 @@ class File extends \SplFileInfo
* is available on the current operating system.
*
* @return string|null The guessed mime type (i.e. "application/pdf")
*
* @api
*/
public function getMimeType()
{
@ -492,6 +500,8 @@ class File extends \SplFileInfo
* \SplFileInfo::getExtension() is not available before PHP 5.3.6
*
* @return string The extension
*
* @api
*/
public function getExtension()
{
@ -507,6 +517,8 @@ class File extends \SplFileInfo
* @return File A File object representing the new file
*
* @throws FileException if the target file could not be created
*
* @api
*/
public function move($directory, $name = null)
{

View File

@ -20,6 +20,8 @@ use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class UploadedFile extends File
{
@ -83,6 +85,8 @@ class UploadedFile extends File
*
* @throws FileException If file_uploads is disabled
* @throws FileNotFoundException If the file does not exist
*
* @api
*/
public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false)
{
@ -108,6 +112,8 @@ class UploadedFile extends File
* Then is should not be considered as a safe value.
*
* @return string|null The original name
*
* @api
*/
public function getClientOriginalName()
{
@ -121,6 +127,8 @@ class UploadedFile extends File
* Then is should not be considered as a safe value.
*
* @return string|null The mime type
*
* @api
*/
public function getClientMimeType()
{
@ -134,6 +142,8 @@ class UploadedFile extends File
* Then is should not be considered as a safe value.
*
* @return integer|null The file size
*
* @api
*/
public function getClientSize()
{
@ -147,6 +157,8 @@ class UploadedFile extends File
* Otherwise one of the other UPLOAD_ERR_XXX constants is returned.
*
* @return integer The upload error
*
* @api
*/
public function getError()
{
@ -157,6 +169,8 @@ class UploadedFile extends File
* Returns whether the file was uploaded successfully.
*
* @return Boolean True if no error occurred during uploading
*
* @api
*/
public function isValid()
{
@ -172,6 +186,8 @@ class UploadedFile extends File
* @return File A File object representing the new file
*
* @throws FileException if the file has not been uploaded via Http
*
* @api
*/
public function move($directory, $name = null)
{

View File

@ -18,6 +18,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
*
* @api
*/
class FileBag extends ParameterBag
{
@ -27,6 +29,8 @@ class FileBag extends ParameterBag
* Constructor.
*
* @param array $parameters An array of HTTP files
*
* @api
*/
public function __construct(array $parameters = array())
{
@ -36,6 +40,8 @@ class FileBag extends ParameterBag
/**
* (non-PHPdoc)
* @see Symfony\Component\HttpFoundation\ParameterBag::replace()
*
* @api
*/
public function replace(array $files = array())
{
@ -46,6 +52,8 @@ class FileBag extends ParameterBag
/**
* (non-PHPdoc)
* @see Symfony\Component\HttpFoundation\ParameterBag::set()
*
* @api
*/
public function set($key, $value)
{
@ -57,6 +65,8 @@ class FileBag extends ParameterBag
/**
* (non-PHPdoc)
* @see Symfony\Component\HttpFoundation\ParameterBag::add()
*
* @api
*/
public function add(array $files = array())
{

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* HeaderBag is a container for HTTP headers.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class HeaderBag
{
@ -25,6 +27,8 @@ class HeaderBag
* Constructor.
*
* @param array $headers An array of HTTP headers
*
* @api
*/
public function __construct(array $headers = array())
{
@ -66,6 +70,8 @@ class HeaderBag
* Returns the headers.
*
* @return array An array of headers
*
* @api
*/
public function all()
{
@ -76,6 +82,8 @@ class HeaderBag
* Returns the parameter keys.
*
* @return array An array of parameter keys
*
* @api
*/
public function keys()
{
@ -86,6 +94,8 @@ class HeaderBag
* Replaces the current HTTP headers by a new set.
*
* @param array $headers An array of HTTP headers
*
* @api
*/
public function replace(array $headers = array())
{
@ -97,6 +107,8 @@ class HeaderBag
* Adds new headers the current HTTP headers set.
*
* @param array $headers An array of HTTP headers
*
* @api
*/
public function add(array $headers)
{
@ -113,6 +125,8 @@ class HeaderBag
* @param Boolean $first Whether to return the first value or all header values
*
* @return string|array The first header value if $first is true, an array of values otherwise
*
* @api
*/
public function get($key, $default = null, $first = true)
{
@ -139,6 +153,8 @@ class HeaderBag
* @param string $key The key
* @param string|array $values The value or an array of values
* @param Boolean $replace Whether to replace the actual value of not (true by default)
*
* @api
*/
public function set($key, $values, $replace = true)
{
@ -163,6 +179,8 @@ class HeaderBag
* @param string $key The HTTP header
*
* @return Boolean true if the parameter exists, false otherwise
*
* @api
*/
public function has($key)
{
@ -176,6 +194,8 @@ class HeaderBag
* @param string $value The HTTP value
*
* @return Boolean true if the value is contained in the header, false otherwise
*
* @api
*/
public function contains($key, $value)
{
@ -186,6 +206,8 @@ class HeaderBag
* Removes a header.
*
* @param string $key The HTTP header name
*
* @api
*/
public function remove($key)
{
@ -205,6 +227,8 @@ class HeaderBag
* @param \DateTime $default The default value
*
* @return \DateTime The filtered value
*
* @api
*/
public function getDate($key, \DateTime $default = null)
{

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* ParameterBag is a container for key/value pairs.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class ParameterBag
{
@ -24,6 +26,8 @@ class ParameterBag
* Constructor.
*
* @param array $parameters An array of parameters
*
* @api
*/
public function __construct(array $parameters = array())
{
@ -34,6 +38,8 @@ class ParameterBag
* Returns the parameters.
*
* @return array An array of parameters
*
* @api
*/
public function all()
{
@ -44,6 +50,8 @@ class ParameterBag
* Returns the parameter keys.
*
* @return array An array of parameter keys
*
* @api
*/
public function keys()
{
@ -54,6 +62,8 @@ class ParameterBag
* Replaces the current parameters by a new set.
*
* @param array $parameters An array of parameters
*
* @api
*/
public function replace(array $parameters = array())
{
@ -64,6 +74,8 @@ class ParameterBag
* Adds parameters.
*
* @param array $parameters An array of parameters
*
* @api
*/
public function add(array $parameters = array())
{
@ -76,6 +88,8 @@ class ParameterBag
* @param string $path The key
* @param mixed $default The default value
* @param boolean $deep
*
* @api
*/
public function get($path, $default = null, $deep = false)
{
@ -131,6 +145,8 @@ class ParameterBag
*
* @param string $key The key
* @param mixed $value The value
*
* @api
*/
public function set($key, $value)
{
@ -143,6 +159,8 @@ class ParameterBag
* @param string $key The key
*
* @return Boolean true if the parameter exists, false otherwise
*
* @api
*/
public function has($key)
{
@ -153,6 +171,8 @@ class ParameterBag
* Removes a parameter.
*
* @param string $key The key
*
* @api
*/
public function remove($key)
{
@ -167,6 +187,8 @@ class ParameterBag
* @param boolean $deep
*
* @return string The filtered value
*
* @api
*/
public function getAlpha($key, $default = '', $deep = false)
{
@ -181,6 +203,8 @@ class ParameterBag
* @param boolean $deep
*
* @return string The filtered value
*
* @api
*/
public function getAlnum($key, $default = '', $deep = false)
{
@ -195,6 +219,8 @@ class ParameterBag
* @param boolean $deep
*
* @return string The filtered value
*
* @api
*/
public function getDigits($key, $default = '', $deep = false)
{
@ -209,6 +235,8 @@ class ParameterBag
* @param boolean $deep
*
* @return string The filtered value
*
* @api
*/
public function getInt($key, $default = 0, $deep = false)
{

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* RedirectResponse represents an HTTP response doing a redirect.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class RedirectResponse extends Response
{
@ -25,6 +27,8 @@ class RedirectResponse extends Response
* @param integer $status The status code (302 by default)
*
* @see http://tools.ietf.org/html/rfc2616#section-10.3
*
* @api
*/
public function __construct($url, $status = 302)
{

View File

@ -17,6 +17,8 @@ use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage;
* Request represents an HTTP request.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class Request
{
@ -24,36 +26,50 @@ class Request
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $attributes;
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $request;
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $query;
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $server;
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $files;
/**
* @var \Symfony\Component\HttpFoundation\ParameterBag
*
* @api
*/
public $cookies;
/**
* @var \Symfony\Component\HttpFoundation\HeaderBag
*
* @api
*/
public $headers;
@ -81,6 +97,8 @@ class Request
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string $content The raw body data
*
* @api
*/
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
@ -99,6 +117,8 @@ class Request
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string $content The raw body data
*
* @api
*/
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
@ -126,6 +146,8 @@ class Request
* Creates a new request with values from PHP's super globals.
*
* @return Request A new request
*
* @api
*/
static public function createFromGlobals()
{
@ -153,6 +175,8 @@ class Request
* @param string $content The raw body data
*
* @return Request A Request instance
*
* @api
*/
static public function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
{
@ -235,6 +259,8 @@ class Request
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
*
* @api
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{
@ -305,6 +331,8 @@ class Request
* Overrides the PHP global variables according to this request instance.
*
* It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE, and $_FILES.
*
* @api
*/
public function overrideGlobals()
{
@ -333,6 +361,8 @@ class Request
*
* You should only call this method if your application
* is hosted behind a reverse proxy that you manage.
*
* @api
*/
static public function trustProxyData()
{
@ -364,6 +394,8 @@ class Request
* Gets the Session.
*
* @return Session|null The session
*
* @api
*/
public function getSession()
{
@ -375,6 +407,8 @@ class Request
* previous requests.
*
* @return boolean
*
* @api
*/
public function hasPreviousSession()
{
@ -386,6 +420,8 @@ class Request
* Whether the request contains a Session object.
*
* @return boolean
*
* @api
*/
public function hasSession()
{
@ -396,6 +432,8 @@ class Request
* Sets the Session.
*
* @param Session $session The Session
*
* @api
*/
public function setSession(Session $session)
{
@ -408,6 +446,8 @@ class Request
* @param Boolean $proxy Whether the current request has been made behind a proxy or not
*
* @return string The client IP address
*
* @api
*/
public function getClientIp($proxy = false)
{
@ -426,6 +466,8 @@ class Request
* Returns current script name.
*
* @return string
*
* @api
*/
public function getScriptName()
{
@ -444,6 +486,8 @@ class Request
* * http://localhost/mysite/about?var=1 returns '/about'
*
* @return string
*
* @api
*/
public function getPathInfo()
{
@ -464,6 +508,8 @@ class Request
* * http://localhost/web/index.php return '/web'
*
* @return string
*
* @api
*/
public function getBasePath()
{
@ -483,6 +529,8 @@ class Request
* script filename (e.g. index.php) if one exists.
*
* @return string
*
* @api
*/
public function getBaseUrl()
{
@ -497,6 +545,8 @@ class Request
* Gets the request's scheme.
*
* @return string
*
* @api
*/
public function getScheme()
{
@ -507,6 +557,8 @@ class Request
* Returns the port on which the request is made.
*
* @return string
*
* @api
*/
public function getPort()
{
@ -519,6 +571,8 @@ class Request
* The port name will be appended to the host if it's non-standard.
*
* @return string
*
* @api
*/
public function getHttpHost()
{
@ -536,6 +590,8 @@ class Request
* Returns the requested URI.
*
* @return string
*
* @api
*/
public function getRequestUri()
{
@ -552,6 +608,8 @@ class Request
* @return string A normalized URI for the Request
*
* @see getQueryString()
*
* @api
*/
public function getUri()
{
@ -569,6 +627,8 @@ class Request
* @param string $path A path to use instead of the current one
*
* @return string The normalized URI for the path
*
* @api
*/
public function getUriForPath($path)
{
@ -582,6 +642,8 @@ class Request
* and have consistent escaping.
*
* @return string A normalized query string for the Request
*
* @api
*/
public function getQueryString()
{
@ -611,6 +673,8 @@ class Request
* Checks whether the request is secure or not.
*
* @return Boolean
*
* @api
*/
public function isSecure()
{
@ -627,6 +691,8 @@ class Request
* Returns the host name.
*
* @return string
*
* @api
*/
public function getHost()
{
@ -652,6 +718,8 @@ class Request
* Sets the request method.
*
* @param string $method
*
* @api
*/
public function setMethod($method)
{
@ -665,6 +733,8 @@ class Request
* The method is always an uppercased string.
*
* @return string The request method
*
* @api
*/
public function getMethod()
{
@ -684,6 +754,8 @@ class Request
* @param string $format The format
*
* @return string The associated mime type (null if not found)
*
* @api
*/
public function getMimeType($format)
{
@ -700,6 +772,8 @@ class Request
* @param string $mimeType The associated mime type
*
* @return string The format (null if not found)
*
* @api
*/
public function getFormat($mimeType)
{
@ -725,6 +799,8 @@ class Request
*
* @param string $format The format
* @param string|array $mimeTypes The associated mime types (the preferred one must be the first as it will be used as the content type)
*
* @api
*/
public function setFormat($format, $mimeTypes)
{
@ -747,6 +823,8 @@ class Request
* @param string $default The default format
*
* @return string The request format
*
* @api
*/
public function getRequestFormat($default = 'html')
{
@ -757,6 +835,13 @@ class Request
return $this->format;
}
/**
* Sets the request format.
*
* @param string $format The request format.
*
* @api
*/
public function setRequestFormat($format)
{
$this->format = $format;
@ -766,6 +851,8 @@ class Request
* Checks whether the method is safe or not.
*
* @return Boolean
*
* @api
*/
public function isMethodSafe()
{
@ -819,6 +906,8 @@ class Request
* @param array $locales An array of ordered available locales
*
* @return string The preferred locale
*
* @api
*/
public function getPreferredLanguage(array $locales = null)
{
@ -841,6 +930,8 @@ class Request
* Gets a list of languages acceptable by the client browser.
*
* @return array Languages ordered in the user browser preferences
*
* @api
*/
public function getLanguages()
{
@ -881,6 +972,8 @@ class Request
* Gets a list of charsets acceptable by the client browser.
*
* @return array List of charsets in preferable order
*
* @api
*/
public function getCharsets()
{
@ -895,6 +988,8 @@ class Request
* Gets a list of content types acceptable by the client browser
*
* @return array List of content types in preferable order
*
* @api
*/
public function getAcceptableContentTypes()
{
@ -912,6 +1007,8 @@ class Request
* It is known to work with Prototype, Mootools, jQuery.
*
* @return Boolean true if the request is an XMLHttpRequest, false otherwise
*
* @api
*/
public function isXmlHttpRequest()
{

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* RequestMatcher compares a pre-defined set of checks against a Request instance.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class RequestMatcher implements RequestMatcherInterface
{
@ -86,6 +88,8 @@ class RequestMatcher implements RequestMatcherInterface
/**
* {@inheritdoc}
*
* @api
*/
public function matches(Request $request)
{

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* RequestMatcherInterface is an interface for strategies to match a Request.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
interface RequestMatcherInterface
{
@ -24,6 +26,8 @@ interface RequestMatcherInterface
* @param Request $request The request to check for a match
*
* @return Boolean true if the request matches, false otherwise
*
* @api
*/
function matches(Request $request);
}

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* Response represents an HTTP response.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class Response
{
@ -79,6 +81,8 @@ class Response
* @param string $content The response content
* @param integer $status The response status code
* @param array $headers An array of response headers
*
* @api
*/
public function __construct($content = '', $status = 200, $headers = array())
{
@ -181,6 +185,8 @@ class Response
/**
* Sends HTTP headers and content.
*
* @api
*/
public function send()
{
@ -198,6 +204,8 @@ class Response
* Valid types are strings, numbers, and objects that implement a __toString() method.
*
* @param mixed $content
*
* @api
*/
public function setContent($content)
{
@ -212,6 +220,8 @@ class Response
* Gets the current response content
*
* @return string Content
*
* @api
*/
public function getContent()
{
@ -222,6 +232,8 @@ class Response
* Sets the HTTP protocol version (1.0 or 1.1).
*
* @param string $version The HTTP protocol version
*
* @api
*/
public function setProtocolVersion($version)
{
@ -232,6 +244,8 @@ class Response
* Gets the HTTP protocol version.
*
* @return string The HTTP protocol version
*
* @api
*/
public function getProtocolVersion()
{
@ -245,6 +259,8 @@ class Response
* @param string $text HTTP status text
*
* @throws \InvalidArgumentException When the HTTP status code is not valid
*
* @api
*/
public function setStatusCode($code, $text = null)
{
@ -260,6 +276,8 @@ class Response
* Retrieves status code for the current web response.
*
* @return string Status code
*
* @api
*/
public function getStatusCode()
{
@ -270,6 +288,8 @@ class Response
* Sets response charset.
*
* @param string $charset Character set
*
* @api
*/
public function setCharset($charset)
{
@ -280,6 +300,8 @@ class Response
* Retrieves the response charset.
*
* @return string Character set
*
* @api
*/
public function getCharset()
{
@ -296,6 +318,8 @@ class Response
* validator (Last-Modified, ETag) are considered uncacheable.
*
* @return Boolean true if the response is worth caching, false otherwise
*
* @api
*/
public function isCacheable()
{
@ -318,6 +342,8 @@ class Response
* indicator or Expiration header and the calculated age is less than the freshness lifetime.
*
* @return Boolean true if the response is fresh, false otherwise
*
* @api
*/
public function isFresh()
{
@ -329,6 +355,8 @@ class Response
* the response with the origin server using a conditional GET request.
*
* @return Boolean true if the response is validateable, false otherwise
*
* @api
*/
public function isValidateable()
{
@ -339,6 +367,8 @@ class Response
* Marks the response as "private".
*
* It makes the response ineligible for serving other clients.
*
* @api
*/
public function setPrivate()
{
@ -350,6 +380,8 @@ class Response
* Marks the response as "public".
*
* It makes the response eligible for serving other clients.
*
* @api
*/
public function setPublic()
{
@ -366,6 +398,8 @@ class Response
* greater than the value provided by the origin.
*
* @return Boolean true if the response must be revalidated by a cache, false otherwise
*
* @api
*/
public function mustRevalidate()
{
@ -378,6 +412,8 @@ class Response
* @return \DateTime A \DateTime instance
*
* @throws \RuntimeException when the header is not parseable
*
* @api
*/
public function getDate()
{
@ -388,6 +424,8 @@ class Response
* Sets the Date header.
*
* @param \DateTime $date A \DateTime instance
*
* @api
*/
public function setDate(\DateTime $date)
{
@ -411,6 +449,8 @@ class Response
/**
* Marks the response stale by setting the Age header to be equal to the maximum age of the response.
*
* @api
*/
public function expire()
{
@ -423,6 +463,8 @@ class Response
* Returns the value of the Expires header as a DateTime instance.
*
* @return \DateTime A DateTime instance
*
* @api
*/
public function getExpires()
{
@ -435,6 +477,8 @@ class Response
* If passed a null value, it removes the header.
*
* @param \DateTime $date A \DateTime instance
*
* @api
*/
public function setExpires(\DateTime $date = null)
{
@ -455,6 +499,8 @@ class Response
* back on an expires header. It returns null when no maximum age can be established.
*
* @return integer|null Number of seconds
*
* @api
*/
public function getMaxAge()
{
@ -479,6 +525,8 @@ class Response
* This methods sets the Cache-Control max-age directive.
*
* @param integer $value A number of seconds
*
* @api
*/
public function setMaxAge($value)
{
@ -491,6 +539,8 @@ class Response
* This methods sets the Cache-Control s-maxage directive.
*
* @param integer $value A number of seconds
*
* @api
*/
public function setSharedMaxAge($value)
{
@ -507,6 +557,8 @@ class Response
* revalidating with the origin.
*
* @return integer The TTL in seconds
*
* @api
*/
public function getTtl()
{
@ -523,6 +575,8 @@ class Response
* This method adjusts the Cache-Control/s-maxage directive.
*
* @param integer $seconds The number of seconds
*
* @api
*/
public function setTtl($seconds)
{
@ -535,6 +589,8 @@ class Response
* This method adjusts the Cache-Control/max-age directive.
*
* @param integer $seconds The number of seconds
*
* @api
*/
public function setClientTtl($seconds)
{
@ -545,6 +601,8 @@ class Response
* Returns the Last-Modified HTTP header as a DateTime instance.
*
* @return \DateTime A DateTime instance
*
* @api
*/
public function getLastModified()
{
@ -557,6 +615,8 @@ class Response
* If passed a null value, it removes the header.
*
* @param \DateTime $date A \DateTime instance
*
* @api
*/
public function setLastModified(\DateTime $date = null)
{
@ -573,6 +633,8 @@ class Response
* Returns the literal value of ETag HTTP header.
*
* @return string The ETag HTTP header
*
* @api
*/
public function getEtag()
{
@ -584,6 +646,8 @@ class Response
*
* @param string $etag The ETag unique identifier
* @param Boolean $weak Whether you want a weak ETag or not
*
* @api
*/
public function setEtag($etag = null, $weak = false)
{
@ -604,6 +668,8 @@ class Response
* Available options are: etag, last_modified, max_age, s_maxage, private, and public.
*
* @param array $options An array of cache options
*
* @api
*/
public function setCache(array $options)
{
@ -651,6 +717,8 @@ class Response
* that MUST NOT be included in 304 responses.
*
* @see http://tools.ietf.org/html/rfc2616#section-10.3.5
*
* @api
*/
public function setNotModified()
{
@ -667,6 +735,8 @@ class Response
* Returns true if the response includes a Vary header.
*
* @return true if the response includes a Vary header, false otherwise
*
* @api
*/
public function hasVary()
{
@ -677,6 +747,8 @@ class Response
* Returns an array of header names given in the Vary header.
*
* @return array An array of Vary names
*
* @api
*/
public function getVary()
{
@ -692,6 +764,8 @@ class Response
*
* @param string|array $headers
* @param Boolean $replace Whether to replace the actual value of not (true by default)
*
* @api
*/
public function setVary($headers, $replace = true)
{
@ -708,6 +782,8 @@ class Response
* @param Request $request A Request instance
*
* @return Boolean true if the Response validators matches the Request, false otherwise
*
* @api
*/
public function isNotModified(Request $request)
{
@ -727,56 +803,89 @@ class Response
}
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
/**
* @api
*/
public function isInvalid()
{
return $this->statusCode < 100 || $this->statusCode >= 600;
}
/**
* @api
*/
public function isInformational()
{
return $this->statusCode >= 100 && $this->statusCode < 200;
}
/**
* @api
*/
public function isSuccessful()
{
return $this->statusCode >= 200 && $this->statusCode < 300;
}
/**
* @api
*/
public function isRedirection()
{
return $this->statusCode >= 300 && $this->statusCode < 400;
}
/**
* @api
*/
public function isClientError()
{
return $this->statusCode >= 400 && $this->statusCode < 500;
}
/**
* @api
*/
public function isServerError()
{
return $this->statusCode >= 500 && $this->statusCode < 600;
}
/**
* @api
*/
public function isOk()
{
return 200 === $this->statusCode;
}
/**
* @api
*/
public function isForbidden()
{
return 403 === $this->statusCode;
}
/**
* @api
*/
public function isNotFound()
{
return 404 === $this->statusCode;
}
/**
* @api
*/
public function isRedirect($location = null)
{
return in_array($this->statusCode, array(201, 301, 302, 303, 307)) && (null === $location ?: $location == $this->headers->get('Location'));
}
/**
* @api
*/
public function isEmpty()
{
return in_array($this->statusCode, array(201, 204, 304));

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation;
* ResponseHeaderBag is a container for Response HTTP headers.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class ResponseHeaderBag extends HeaderBag
{
@ -28,6 +30,8 @@ class ResponseHeaderBag extends HeaderBag
* Constructor.
*
* @param array $headers An array of HTTP headers
*
* @api
*/
public function __construct(array $headers = array())
{
@ -53,6 +57,8 @@ class ResponseHeaderBag extends HeaderBag
/**
* {@inheritdoc}
*
* @api
*/
public function replace(array $headers = array())
{
@ -65,6 +71,8 @@ class ResponseHeaderBag extends HeaderBag
/**
* {@inheritdoc}
*
* @api
*/
public function set($key, $values, $replace = true)
{
@ -80,6 +88,8 @@ class ResponseHeaderBag extends HeaderBag
/**
* {@inheritdoc}
*
* @api
*/
public function remove($key)
{
@ -111,6 +121,8 @@ class ResponseHeaderBag extends HeaderBag
*
* @param Cookie $cookie
* @return void
*
* @api
*/
public function setCookie(Cookie $cookie)
{
@ -124,6 +136,8 @@ class ResponseHeaderBag extends HeaderBag
* @param string $path
* @param string $domain
* @return void
*
* @api
*/
public function removeCookie($name, $path = null, $domain = null)
{
@ -146,6 +160,8 @@ class ResponseHeaderBag extends HeaderBag
* @throws \InvalidArgumentException When the $format is invalid
*
* @return array
*
* @api
*/
public function getCookies($format = self::COOKIES_FLAT)
{
@ -176,6 +192,8 @@ class ResponseHeaderBag extends HeaderBag
* @param string $path
* @param string $domain
* @return void
*
* @api
*/
public function clearCookie($name, $path = null, $domain = null)
{

View File

@ -17,6 +17,8 @@ use Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface;
* Session.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class Session implements \Serializable
{
@ -48,6 +50,8 @@ class Session implements \Serializable
/**
* Starts the session storage.
*
* @api
*/
public function start()
{
@ -78,6 +82,8 @@ class Session implements \Serializable
* @param string $name The attribute name
*
* @return Boolean true if the attribute is defined, false otherwise
*
* @api
*/
public function has($name)
{
@ -91,6 +97,8 @@ class Session implements \Serializable
* @param mixed $default The default value
*
* @return mixed
*
* @api
*/
public function get($name, $default = null)
{
@ -102,6 +110,8 @@ class Session implements \Serializable
*
* @param string $name
* @param mixed $value
*
* @api
*/
public function set($name, $value)
{
@ -116,6 +126,8 @@ class Session implements \Serializable
* Returns attributes.
*
* @return array Attributes
*
* @api
*/
public function all()
{
@ -126,6 +138,8 @@ class Session implements \Serializable
* Sets attributes.
*
* @param array $attributes Attributes
*
* @api
*/
public function replace(array $attributes)
{
@ -140,6 +154,8 @@ class Session implements \Serializable
* Removes an attribute.
*
* @param string $name
*
* @api
*/
public function remove($name)
{
@ -154,6 +170,8 @@ class Session implements \Serializable
/**
* Clears all attributes.
*
* @api
*/
public function clear()
{
@ -168,6 +186,8 @@ class Session implements \Serializable
/**
* Invalidates the current session.
*
* @api
*/
public function invalidate()
{
@ -178,6 +198,8 @@ class Session implements \Serializable
/**
* Migrates the current session to a new session id while maintaining all
* session attributes.
*
* @api
*/
public function migrate()
{
@ -188,6 +210,8 @@ class Session implements \Serializable
* Returns the session ID
*
* @return mixed The session ID
*
* @api
*/
public function getId()
{

View File

@ -18,6 +18,8 @@ namespace Symfony\Component\HttpFoundation\SessionStorage;
* as it is not "available" when running tests on the command line.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class FilesystemSessionStorage extends NativeSessionStorage
{
@ -25,6 +27,9 @@ class FilesystemSessionStorage extends NativeSessionStorage
private $data;
private $started;
/**
* Constructor.
*/
public function __construct($path, array $options = array())
{
$this->path = $path;
@ -33,6 +38,11 @@ class FilesystemSessionStorage extends NativeSessionStorage
parent::__construct($options);
}
/**
* Starts the session.
*
* @api
*/
public function start()
{
if ($this->started) {
@ -61,6 +71,15 @@ class FilesystemSessionStorage extends NativeSessionStorage
$this->started = true;
}
/**
* Returns the session ID
*
* @return mixed The session ID
*
* @throws \RuntimeException If the session was not started yet
*
* @api
*/
public function getId()
{
if (!$this->started) {
@ -70,11 +89,37 @@ class FilesystemSessionStorage extends NativeSessionStorage
return session_id();
}
/**
* Reads data from this storage.
*
* The preferred format for a key is directory style so naming conflicts can be avoided.
*
* @param string $key A unique key identifying your data
*
* @return mixed Data associated with the key
*
* @throws \RuntimeException If an error occurs while reading data from this storage
*
* @api
*/
public function read($key, $default = null)
{
return array_key_exists($key, $this->data) ? $this->data[$key] : $default;
}
/**
* Removes data from this storage.
*
* The preferred format for a key is directory style so naming conflicts can be avoided.
*
* @param string $key A unique key identifying your data
*
* @return mixed Data associated with the key
*
* @throws \RuntimeException If an error occurs while removing data from this storage
*
* @api
*/
public function remove($key)
{
$retval = $this->data[$key];
@ -84,6 +129,18 @@ class FilesystemSessionStorage extends NativeSessionStorage
return $retval;
}
/**
* Writes data to this storage.
*
* The preferred format for a key is directory style so naming conflicts can be avoided.
*
* @param string $key A unique key identifying your data
* @param mixed $data Data associated with your key
*
* @throws \RuntimeException If an error occurs while writing to this storage
*
* @api
*/
public function write($key, $data)
{
$this->data[$key] = $data;
@ -95,6 +152,17 @@ class FilesystemSessionStorage extends NativeSessionStorage
file_put_contents($this->path.'/'.session_id().'.session', serialize($this->data));
}
/**
* Regenerates id that represents this storage.
*
* @param Boolean $destroy Destroy session when regenerating?
*
* @return Boolean True if session regenerated, false if error
*
* @throws \RuntimeException If an error occurs while regenerating this storage
*
* @api
*/
public function regenerate($destroy = false)
{
if ($destroy) {

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\HttpFoundation\SessionStorage;
* NativeSessionStorage.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class NativeSessionStorage implements SessionStorageInterface
{
@ -58,6 +60,8 @@ class NativeSessionStorage implements SessionStorageInterface
/**
* Starts the session.
*
* @api
*/
public function start()
{
@ -87,6 +91,8 @@ class NativeSessionStorage implements SessionStorageInterface
/**
* {@inheritDoc}
*
* @api
*/
public function getId()
{
@ -106,6 +112,8 @@ class NativeSessionStorage implements SessionStorageInterface
* @param string $default Default value
*
* @return mixed Data associated with the key
*
* @api
*/
public function read($key, $default = null)
{
@ -120,6 +128,8 @@ class NativeSessionStorage implements SessionStorageInterface
* @param string $key A unique key identifying your data
*
* @return mixed Data associated with the key
*
* @api
*/
public function remove($key)
{
@ -141,6 +151,7 @@ class NativeSessionStorage implements SessionStorageInterface
* @param string $key A unique key identifying your data
* @param mixed $data Data associated with your key
*
* @api
*/
public function write($key, $data)
{
@ -154,6 +165,7 @@ class NativeSessionStorage implements SessionStorageInterface
*
* @return Boolean True if session regenerated, false if error
*
* @api
*/
public function regenerate($destroy = false)
{

View File

@ -15,11 +15,15 @@ namespace Symfony\Component\HttpFoundation\SessionStorage;
* SessionStorageInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
interface SessionStorageInterface
{
/**
* Starts the session.
*
* @api
*/
function start();
@ -29,6 +33,8 @@ interface SessionStorageInterface
* @return mixed The session ID
*
* @throws \RuntimeException If the session was not started yet
*
* @api
*/
function getId();
@ -42,6 +48,8 @@ interface SessionStorageInterface
* @return mixed Data associated with the key
*
* @throws \RuntimeException If an error occurs while reading data from this storage
*
* @api
*/
function read($key);
@ -55,6 +63,8 @@ interface SessionStorageInterface
* @return mixed Data associated with the key
*
* @throws \RuntimeException If an error occurs while removing data from this storage
*
* @api
*/
function remove($key);
@ -67,6 +77,8 @@ interface SessionStorageInterface
* @param mixed $data Data associated with your key
*
* @throws \RuntimeException If an error occurs while writing to this storage
*
* @api
*/
function write($key, $data);
@ -78,6 +90,8 @@ interface SessionStorageInterface
* @return Boolean True if session regenerated, false if error
*
* @throws \RuntimeException If an error occurs while regenerating this storage
*
* @api
*/
function regenerate($destroy = false);
}