[HttpFoundation] Fixed a typo and updated the phpdoc for the session

This commit is contained in:
Christophe Coevoet 2012-02-12 01:54:16 +01:00
parent 0550bef14d
commit 5808773b51
12 changed files with 81 additions and 107 deletions

View File

@ -65,6 +65,8 @@ interface AttributeBagInterface extends SessionBagInterface
* Removes an attribute. * Removes an attribute.
* *
* @param string $name * @param string $name
*
* @return mixed The removed value
*/ */
function remove($name); function remove($name);
} }

View File

@ -37,7 +37,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/** /**
* Constructor. * Constructor.
* *
* @param type $storageKey The key used to store flashes in the session. * @param string $storageKey The key used to store flashes in the session.
*/ */
public function __construct($storageKey = '_sf2_flashes') public function __construct($storageKey = '_sf2_flashes')
{ {

View File

@ -37,7 +37,7 @@ class FlashBag implements FlashBagInterface
/** /**
* Constructor. * Constructor.
* *
* @param type $storageKey The key used to store flashes in the session. * @param string $storageKey The key used to store flashes in the session.
*/ */
public function __construct($storageKey = '_sf2_flashes') public function __construct($storageKey = '_sf2_flashes')
{ {

View File

@ -50,11 +50,7 @@ class Session implements SessionInterface
} }
/** /**
* Starts the session storage. * {@inheritdoc}
*
* @return boolean True if session started.
*
* @api
*/ */
public function start() public function start()
{ {
@ -62,13 +58,7 @@ class Session implements SessionInterface
} }
/** /**
* Checks if an attribute is defined. * {@inheritdoc}
*
* @param string $name The attribute name
*
* @return Boolean true if the attribute is defined, false otherwise
*
* @api
*/ */
public function has($name) public function has($name)
{ {
@ -76,14 +66,7 @@ class Session implements SessionInterface
} }
/** /**
* Returns an attribute. * {@inheritdoc}
*
* @param string $name The attribute name
* @param mixed $default The default value
*
* @return mixed
*
* @api
*/ */
public function get($name, $default = null) public function get($name, $default = null)
{ {
@ -91,12 +74,7 @@ class Session implements SessionInterface
} }
/** /**
* Sets an attribute. * {@inheritdoc}
*
* @param string $name
* @param mixed $value
*
* @api
*/ */
public function set($name, $value) public function set($name, $value)
{ {
@ -104,11 +82,7 @@ class Session implements SessionInterface
} }
/** /**
* Returns attributes. * {@inheritdoc}
*
* @return array Attributes
*
* @api
*/ */
public function all() public function all()
{ {
@ -116,11 +90,7 @@ class Session implements SessionInterface
} }
/** /**
* Sets attributes. * {@inheritdoc}
*
* @param array $attributes Attributes
*
* @api
*/ */
public function replace(array $attributes) public function replace(array $attributes)
{ {
@ -128,11 +98,7 @@ class Session implements SessionInterface
} }
/** /**
* Removes an attribute. * {@inheritdoc}
*
* @param string $name
*
* @api
*/ */
public function remove($name) public function remove($name)
{ {
@ -140,9 +106,7 @@ class Session implements SessionInterface
} }
/** /**
* Clears all attributes. * {@inheritdoc}
*
* @api
*/ */
public function clear() public function clear()
{ {
@ -150,14 +114,7 @@ class Session implements SessionInterface
} }
/** /**
* Invalidates the current session. * {@inheritdoc}
*
* Clears all session attributes and flashes and regenerates the
* session and deletes the old session from persistence.
*
* @return boolean True if session invalidated, false if error.
*
* @api
*/ */
public function invalidate() public function invalidate()
{ {
@ -167,14 +124,7 @@ class Session implements SessionInterface
} }
/** /**
* Migrates the current session to a new session id while maintaining all * {@inheritdoc}
* session attributes.
*
* @param boolean $destroy Whether to delete the old session or leave it to garbage collection.
*
* @return boolean True if session migrated, false if error
*
* @api
*/ */
public function migrate($destroy = false) public function migrate($destroy = false)
{ {
@ -204,7 +154,7 @@ class Session implements SessionInterface
/** /**
* Implements the \Serialize interface. * Implements the \Serialize interface.
* *
* @return SessionStorageInterface * @return string
*/ */
public function serialize() public function serialize()
{ {
@ -214,6 +164,8 @@ class Session implements SessionInterface
/** /**
* Implements the \Serialize interface. * Implements the \Serialize interface.
* *
* @param string $serialized
*
* @throws \InvalidArgumentException If the passed string does not unserialize to an instance of SessionStorageInterface * @throws \InvalidArgumentException If the passed string does not unserialize to an instance of SessionStorageInterface
*/ */
public function unserialize($serialized) public function unserialize($serialized)
@ -261,6 +213,8 @@ class Session implements SessionInterface
// the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3) // the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)
/** /**
* @return array
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function getFlashes() public function getFlashes()
@ -269,6 +223,8 @@ class Session implements SessionInterface
} }
/** /**
* @param array $values
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function setFlashes($values) public function setFlashes($values)
@ -277,6 +233,11 @@ class Session implements SessionInterface
} }
/** /**
* @param string $name
* @param string $default
*
* @return string
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function getFlash($name, $default = null) public function getFlash($name, $default = null)
@ -285,6 +246,9 @@ class Session implements SessionInterface
} }
/** /**
* @param string $name
* @param string $value
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function setFlash($name, $value) public function setFlash($name, $value)
@ -293,6 +257,10 @@ class Session implements SessionInterface
} }
/** /**
* @param string $name
*
* @return Boolean
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function hasFlash($name) public function hasFlash($name)
@ -301,6 +269,8 @@ class Session implements SessionInterface
} }
/** /**
* @param string $name
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function removeFlash($name) public function removeFlash($name)
@ -309,6 +279,8 @@ class Session implements SessionInterface
} }
/** /**
* @return array
*
* @deprecated since 2.1, will be removed from 2.3 * @deprecated since 2.1, will be removed from 2.3
*/ */
public function clearFlashes() public function clearFlashes()

View File

@ -21,14 +21,23 @@ interface SessionInterface extends \Serializable
/** /**
* Starts the session storage. * Starts the session storage.
* *
* @return Boolean True if session started.
*
* @throws \RuntimeException If session fails to start. * @throws \RuntimeException If session fails to start.
*
* @api
*/ */
function start(); function start();
/** /**
* Invalidates the current session. * Invalidates the current session.
* *
* @return boolean True if session invalidated, false if error. * Clears all session attributes and flashes and regenerates the
* session and deletes the old session from persistence.
*
* @return Boolean True if session invalidated, false if error.
*
* @api
*/ */
function invalidate(); function invalidate();
@ -36,9 +45,9 @@ interface SessionInterface extends \Serializable
* Migrates the current session to a new session id while maintaining all * Migrates the current session to a new session id while maintaining all
* session attributes. * session attributes.
* *
* @param boolean $destroy Whether to delete the old session or leave it to garbage collection. * @param Boolean $destroy Whether to delete the old session or leave it to garbage collection.
* *
* @return boolean True if session migrated, false if error. * @return Boolean True if session migrated, false if error.
* *
* @api * @api
*/ */
@ -59,6 +68,8 @@ interface SessionInterface extends \Serializable
* @param string $name The attribute name * @param string $name The attribute name
* *
* @return Boolean true if the attribute is defined, false otherwise * @return Boolean true if the attribute is defined, false otherwise
*
* @api
*/ */
function has($name); function has($name);
@ -69,6 +80,8 @@ interface SessionInterface extends \Serializable
* @param mixed $default The default value if not found. * @param mixed $default The default value if not found.
* *
* @return mixed * @return mixed
*
* @api
*/ */
function get($name, $default = null); function get($name, $default = null);
@ -77,6 +90,8 @@ interface SessionInterface extends \Serializable
* *
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
*
* @api
*/ */
function set($name, $value); function set($name, $value);
@ -84,6 +99,8 @@ interface SessionInterface extends \Serializable
* Returns attributes. * Returns attributes.
* *
* @return array Attributes * @return array Attributes
*
* @api
*/ */
function all(); function all();
@ -98,11 +115,17 @@ interface SessionInterface extends \Serializable
* Removes an attribute. * Removes an attribute.
* *
* @param string $name * @param string $name
*
* @return mixed The removed value
*
* @api
*/ */
function remove($name); function remove($name);
/** /**
* Clears all attributes. * Clears all attributes.
*
* @api
*/ */
function clear(); function clear();
} }

View File

@ -128,16 +128,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface
} }
/** /**
* Regenerates the session. * {@inheritdoc}
*
* This method will regenerate the session ID and optionally
* destroy the old ID. Session regeneration should be done
* periodically and for example, should be done when converting
* an anonymous session to a logged in user session.
*
* @param boolean $destroy
*
* @return boolean Returns true on success or false on failure.
*/ */
public function regenerate($destroy = false) public function regenerate($destroy = false)
{ {
@ -171,9 +162,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface
} }
/** /**
* Register a SessionBagInterface for use. * {@inheritdoc}
*
* @param SessionBagInterface $bag
*/ */
public function registerBag(SessionBagInterface $bag) public function registerBag(SessionBagInterface $bag)
{ {
@ -181,13 +170,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface
} }
/** /**
* Gets a bag by name. * {@inheritdoc}
*
* @param string $name
*
* @return SessionBagInterface
*
* @throws \InvalidArgumentException
*/ */
public function getBag($name) public function getBag($name)
{ {
@ -323,6 +306,8 @@ abstract class AbstractSessionStorage implements SessionStorageInterface
* are set to (either PHP's internal, custom set with session_set_save_handler()). * are set to (either PHP's internal, custom set with session_set_save_handler()).
* PHP takes the return value from the sessionRead() handler, unserializes it * PHP takes the return value from the sessionRead() handler, unserializes it
* and populates $_SESSION with the result automatically. * and populates $_SESSION with the result automatically.
*
* @param array|null $session
*/ */
protected function loadSession(array &$session = null) protected function loadSession(array &$session = null)
{ {

View File

@ -21,7 +21,7 @@ class MemcacheSessionStorage extends AbstractSessionStorage implements SessionSa
/** /**
* Memcache driver. * Memcache driver.
* *
* @var Memcache * @var \Memcache
*/ */
private $memcache; private $memcache;
@ -63,7 +63,7 @@ class MemcacheSessionStorage extends AbstractSessionStorage implements SessionSa
} }
$memcacheOptions['expiretime'] = isset($memcacheOptions['expiretime']) ? (int)$memcacheOptions['expiretime'] : 86400; $memcacheOptions['expiretime'] = isset($memcacheOptions['expiretime']) ? (int)$memcacheOptions['expiretime'] : 86400;
$this->prefix = isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s'; $this->prefix = isset($memcacheOptions['prefix']) ? $memcacheOptions['prefix'] : 'sf2s';
$this->memcacheOptions = $memcacheOptions; $this->memcacheOptions = $memcacheOptions;

View File

@ -21,7 +21,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
/** /**
* Memcached driver. * Memcached driver.
* *
* @var Memcached * @var \Memcached
*/ */
private $memcached; private $memcached;
@ -41,7 +41,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
* *
* @see AbstractSessionStorage::__construct() * @see AbstractSessionStorage::__construct()
*/ */
public function __construct(\Memcached $memcache, array $memcachedOptions = array(), array $options = array()) public function __construct(\Memcached $memcached, array $memcachedOptions = array(), array $options = array())
{ {
$this->memcached = $memcached; $this->memcached = $memcached;
@ -57,7 +57,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
$memcachedOptions['expiretime'] = isset($memcachedOptions['expiretime']) ? (int)$memcachedOptions['expiretime'] : 86400; $memcachedOptions['expiretime'] = isset($memcachedOptions['expiretime']) ? (int)$memcachedOptions['expiretime'] : 86400;
$this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOption['prefix'] : 'sf2s'); $this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s');
$this->memcacheOptions = $memcachedOptions; $this->memcacheOptions = $memcachedOptions;
@ -77,9 +77,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
} }
/** /**
* Close session. * {@inheritdoc}
*
* @return boolean
*/ */
public function closeSession() public function closeSession()
{ {

View File

@ -33,7 +33,7 @@ class MockArraySessionStorage extends AbstractSessionStorage
/** /**
* @var array * @var array
*/ */
private $sessionData = array(); protected $sessionData = array();
public function setSessionData(array $array) public function setSessionData(array $array)
{ {

View File

@ -31,9 +31,7 @@ class NullSessionStorage extends AbstractSessionStorage implements SessionSaveHa
} }
/** /**
* Close session. * {@inheritdoc}
*
* @return boolean
*/ */
public function closeSession() public function closeSession()
{ {

View File

@ -65,7 +65,7 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function openSession($path = null, $name = null) public function openSession($path, $name)
{ {
return true; return true;
} }
@ -80,8 +80,6 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws \RuntimeException If the session cannot be destroyed
*/ */
public function destroySession($id) public function destroySession($id)
{ {
@ -105,8 +103,6 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws \RuntimeException If any old sessions cannot be cleaned
*/ */
public function gcSession($lifetime) public function gcSession($lifetime)
{ {
@ -130,8 +126,6 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws \RuntimeException If the session cannot be read
*/ */
public function readSession($id) public function readSession($id)
{ {
@ -166,8 +160,6 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws \RuntimeException If the session data cannot be written
*/ */
public function writeSession($id, $data) public function writeSession($id, $data)
{ {

View File

@ -79,7 +79,11 @@ interface SessionStorageInterface
/** /**
* Gets a SessionBagInterface by name. * Gets a SessionBagInterface by name.
* *
* @param string $name
*
* @return SessionBagInterface * @return SessionBagInterface
*
* @throws \InvalidArgumentException If the bag does not exist
*/ */
function getBag($name); function getBag($name);