Coding standards

As requested by @fabpot
This commit is contained in:
Drak 2013-04-06 17:58:08 +01:00
parent 2583c2614f
commit 1f521d8d62
18 changed files with 56 additions and 56 deletions

View File

@ -4,7 +4,7 @@ CHANGELOG
2.3.0 2.3.0
* `UploadedFile::isValid` now returns false if the file was not uploaded via HTTP (in a non-test mode) * `UploadedFile::isValid` now returns false if the file was not uploaded via HTTP (in a non-test mode)
* addded control for session start on demand. * added control for session start on demand.
2.2.0 2.2.0
----- -----

View File

@ -49,7 +49,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
/** /**
* Constructor. * Constructor.
* *
* @param SessionStorageInterface $storage A SessionStorageInterface instance. * @param SessionStorageInterface $storage A SessionStorageInterface instance
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag)
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
*/ */

View File

@ -42,7 +42,7 @@ interface SessionBagInterface
/** /**
* Clears out data from bag. * Clears out data from bag.
* *
* @return mixed Whatever data was contained. * @return mixed Whatever data was contained
*/ */
public function clear(); public function clear();
} }

View File

@ -23,9 +23,9 @@ interface SessionInterface
/** /**
* Starts the session storage. * Starts the session storage.
* *
* @return Boolean True if session started. * @return Boolean True if session started
* *
* @throws \RuntimeException If session fails to start. * @throws \RuntimeException If session fails to start
* *
* @api * @api
*/ */
@ -34,7 +34,7 @@ interface SessionInterface
/** /**
* Returns the session ID. * Returns the session ID.
* *
* @return string The session ID. * @return string The session ID
* *
* @api * @api
*/ */
@ -52,7 +52,7 @@ interface SessionInterface
/** /**
* Returns the session name. * Returns the session name.
* *
* @return mixed The session name. * @return mixed The session name
* *
* @api * @api
*/ */
@ -76,9 +76,9 @@ interface SessionInterface
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
* will leave the system settings unchanged, 0 sets the cookie * will leave the system settings unchanged, 0 sets the cookie
* to expire with browser session. Time is in seconds, and is * to expire with browser session. Time is in seconds, and is
* not a Unix timestamp. * not a Unix timestamp
* *
* @return Boolean True if session invalidated, false if error. * @return Boolean True if session invalidated, false if error
* *
* @api * @api
*/ */
@ -92,9 +92,9 @@ interface SessionInterface
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
* will leave the system settings unchanged, 0 sets the cookie * will leave the system settings unchanged, 0 sets the cookie
* to expire with browser session. Time is in seconds, and is * to expire with browser session. Time is in seconds, and is
* not a Unix timestamp. * not a Unix timestamp
* *
* @return Boolean True if session migrated, false if error. * @return Boolean True if session migrated, false if error
* *
* @api * @api
*/ */

View File

@ -29,7 +29,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
private $ttl; private $ttl;
/** /**
* @var string Key prefix for shared environments. * @var string Key prefix for shared environments
*/ */
private $prefix; private $prefix;

View File

@ -34,7 +34,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
private $ttl; private $ttl;
/** /**
* @var string Key prefix for shared environments. * @var string Key prefix for shared environments
*/ */
private $prefix; private $prefix;

View File

@ -52,11 +52,11 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
public function __construct($mongo, array $options) public function __construct($mongo, array $options)
{ {
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) { if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
throw new \InvalidArgumentException('MongoClient or Mongo instance required'); throw new \InvalidArgumentException('MongoClient or Mongo instance required.');
} }
if (!isset($options['database']) || !isset($options['collection'])) { if (!isset($options['database']) || !isset($options['collection'])) {
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler'); throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler.');
} }
$this->mongo = $mongo; $this->mongo = $mongo;

View File

@ -24,10 +24,10 @@ class NativeFileSessionHandler extends NativeSessionHandler
* Constructor. * Constructor.
* *
* @param string $savePath Path of directory to save session files. * @param string $savePath Path of directory to save session files.
* Default null will leave setting as defined by PHP. * Default null will leave setting as defined by PHP
* '/path', 'N;/path', or 'N;octal-mode;/path * '/path', 'N;/path', or 'N;octal-mode;/path
* *
* @see http://php.net/session.configuration.php#ini.session.save-path for further details. * @see http://php.net/session.configuration.php#ini.session.save-path for further details
* *
* @throws \InvalidArgumentException On invalid $savePath * @throws \InvalidArgumentException On invalid $savePath
*/ */
@ -41,7 +41,7 @@ class NativeFileSessionHandler extends NativeSessionHandler
if ($count = substr_count($savePath, ';')) { if ($count = substr_count($savePath, ';')) {
if ($count > 2) { if ($count > 2) {
throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'.', $savePath));
} }
// characters after last ';' are the path // characters after last ';' are the path

View File

@ -20,12 +20,12 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
class PdoSessionHandler implements \SessionHandlerInterface class PdoSessionHandler implements \SessionHandlerInterface
{ {
/** /**
* @var \PDO PDO instance. * @var \PDO PDO instance
*/ */
private $pdo; private $pdo;
/** /**
* @var array Database options. * @var array Database options
*/ */
private $dbOptions; private $dbOptions;
@ -90,7 +90,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
$stmt->bindParam(':id', $id, \PDO::PARAM_STR); $stmt->bindParam(':id', $id, \PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s.', $e->getMessage()), 0, $e);
} }
return true; return true;
@ -113,7 +113,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
$stmt->bindValue(':time', time() - $lifetime, \PDO::PARAM_INT); $stmt->bindValue(':time', time() - $lifetime, \PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s.', $e->getMessage()), 0, $e);
} }
return true; return true;
@ -149,7 +149,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
return ''; return '';
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s.', $e->getMessage()), 0, $e);
} }
} }
@ -204,7 +204,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
} }
} }
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s.', $e->getMessage()), 0, $e);
} }
return true; return true;
@ -216,7 +216,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
* @param string $id * @param string $id
* @param string $data * @param string $data
* *
* @return boolean True. * @return boolean True
*/ */
private function createNewSession($id, $data = '') private function createNewSession($id, $data = '')
{ {

View File

@ -51,7 +51,7 @@ class MetadataBag implements SessionBagInterface
/** /**
* Constructor. * Constructor.
* *
* @param string $storageKey The key used to store bag in the session. * @param string $storageKey The key used to store bag in the session
*/ */
public function __construct($storageKey = '_sf2_meta') public function __construct($storageKey = '_sf2_meta')
{ {
@ -90,7 +90,7 @@ class MetadataBag implements SessionBagInterface
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
* will leave the system settings unchanged, 0 sets the cookie * will leave the system settings unchanged, 0 sets the cookie
* to expire with browser session. Time is in seconds, and is * to expire with browser session. Time is in seconds, and is
* not a Unix timestamp. * not a Unix timestamp
*/ */
public function stampNew($lifetime = null) public function stampNew($lifetime = null)
{ {

View File

@ -71,9 +71,9 @@ class MockArraySessionStorage implements SessionStorageInterface
/** /**
* Constructor. * Constructor.
* *
* @param string $name Session name. * @param string $name Session name
* @param MetadataBag $metaBag MetadataBag instance. * @param MetadataBag $metaBag MetadataBag instance
* @param integer $mode Session on demand mode. * @param integer $mode Session on demand mode
*/ */
public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND) public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND)
{ {
@ -167,7 +167,7 @@ class MockArraySessionStorage implements SessionStorageInterface
public function save() public function save()
{ {
if (!$this->started || $this->closed) { if (!$this->started || $this->closed) {
throw new \RuntimeException("Trying to save a session that was not started yet or was already closed"); throw new \RuntimeException("Trying to save a session that was not started yet or was already closed.");
} }
// nothing to do since we don't persist the session data // nothing to do since we don't persist the session data
$this->closed = false; $this->closed = false;
@ -204,13 +204,13 @@ class MockArraySessionStorage implements SessionStorageInterface
public function getBag($name) public function getBag($name)
{ {
if (!isset($this->bags[$name])) { if (!isset($this->bags[$name])) {
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered', $name)); throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
} }
if (!$this->started && self::START_ON_DEMAND === $this->mode) { if (!$this->started && self::START_ON_DEMAND === $this->mode) {
$this->start(); $this->start();
} elseif (!$this->started && self::NO_START_ON_DEMAND_STRICT === $this->mode) { } elseif (!$this->started && self::NO_START_ON_DEMAND_STRICT === $this->mode) {
throw new \RuntimeException('Cannot access session bags because the session has been started'); throw new \RuntimeException('Cannot access session bags because the session has not been started.');
} }
return $this->bags[$name]; return $this->bags[$name];

View File

@ -32,10 +32,10 @@ class MockFileSessionStorage extends MockArraySessionStorage
/** /**
* Constructor. * Constructor.
* *
* @param string $savePath Path of directory to save session files. * @param string $savePath Path of directory to save session files
* @param string $name Session name. * @param string $name Session name
* @param MetadataBag $metaBag MetadataBag instance. * @param MetadataBag $metaBag MetadataBag instance
* @param integer $mode Start on demand mode. * @param integer $mode Start on demand mode
*/ */
public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND) public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND)
{ {
@ -94,7 +94,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
public function save() public function save()
{ {
if (!$this->started) { if (!$this->started) {
throw new \RuntimeException("Trying to save a session that was not started yet or was already closed"); throw new \RuntimeException("Trying to save a session that was not started yet or was already closed.");
} }
file_put_contents($this->getFilePath(), serialize($this->data)); file_put_contents($this->getFilePath(), serialize($this->data));

View File

@ -102,10 +102,10 @@ class NativeSessionStorage implements SessionStorageInterface
* upload_progress.min-freq, "1" * upload_progress.min-freq, "1"
* url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset="
* *
* @param array $options Session configuration options. * @param array $options Session configuration options
* @param object $handler SessionHandlerInterface. * @param object $handler SessionHandlerInterface
* @param MetadataBag $metaBag MetadataBag. * @param MetadataBag $metaBag MetadataBag
* @param integer $mode Start on demand mode. * @param integer $mode Start on demand mode
*/ */
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND) public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND)
{ {
@ -157,7 +157,7 @@ class NativeSessionStorage implements SessionStorageInterface
// start the session // start the session
if (!session_start()) { if (!session_start()) {
throw new \RuntimeException('Failed to start the session'); throw new \RuntimeException('Failed to start the session.');
} }
$this->loadSession(); $this->loadSession();
@ -266,13 +266,13 @@ class NativeSessionStorage implements SessionStorageInterface
public function getBag($name) public function getBag($name)
{ {
if (!isset($this->bags[$name])) { if (!isset($this->bags[$name])) {
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered', $name)); throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
} }
if (!$this->started && self::START_ON_DEMAND === $this->mode) { if (!$this->started && self::START_ON_DEMAND === $this->mode) {
$this->start(); $this->start();
} elseif (!$this->started && self::NO_START_ON_DEMAND_STRICT === $this->mode) { } elseif (!$this->started && self::NO_START_ON_DEMAND_STRICT === $this->mode) {
throw new \RuntimeException('Cannot access session bags because the session has been started'); throw new \RuntimeException('Cannot access session bags because the session has not been started.');
} }
return $this->bags[$name]; return $this->bags[$name];
@ -316,7 +316,7 @@ class NativeSessionStorage implements SessionStorageInterface
* For convenience we omit 'session.' from the beginning of the keys. * For convenience we omit 'session.' from the beginning of the keys.
* Explicitly ignores other ini keys. * Explicitly ignores other ini keys.
* *
* @param array $options Session ini directives array(key => value). * @param array $options Session ini directives array(key => value)
* *
* @see http://php.net/session.configuration * @see http://php.net/session.configuration
*/ */
@ -354,7 +354,7 @@ class NativeSessionStorage implements SessionStorageInterface
* @see http://php.net/sessionhandlerinterface * @see http://php.net/sessionhandlerinterface
* @see http://php.net/sessionhandler * @see http://php.net/sessionhandler
* *
* @param object $saveHandler Default null means NativeProxy. * @param object $saveHandler Default null means NativeProxy
*/ */
public function setSaveHandler($saveHandler = null) public function setSaveHandler($saveHandler = null)
{ {

View File

@ -36,7 +36,7 @@ abstract class AbstractProxy
protected $saveHandlerName; protected $saveHandlerName;
/** /**
* Gets the session.save_handler name. * Gets the session.save_handler name
* *
* @return string * @return string
*/ */
@ -46,7 +46,7 @@ abstract class AbstractProxy
} }
/** /**
* Is this proxy handler and instance of \SessionHandlerInterface. * Is this proxy handler and instance of \SessionHandlerInterface
* *
* @return boolean * @return boolean
*/ */
@ -56,7 +56,7 @@ abstract class AbstractProxy
} }
/** /**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler
* *
* @return Boolean * @return Boolean
*/ */
@ -105,7 +105,7 @@ abstract class AbstractProxy
public function setId($id) public function setId($id)
{ {
if ($this->isActive()) { if ($this->isActive()) {
throw new \LogicException('Cannot change the ID of an active session'); throw new \LogicException('Cannot change the ID of an active session.');
} }
session_id($id); session_id($id);
@ -131,7 +131,7 @@ abstract class AbstractProxy
public function setName($name) public function setName($name)
{ {
if ($this->isActive()) { if ($this->isActive()) {
throw new \LogicException('Cannot change the name of an active session'); throw new \LogicException('Cannot change the name of an active session.');
} }
session_name($name); session_name($name);

View File

@ -32,7 +32,7 @@ class NativeProxy extends AbstractProxy
/** /**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
* *
* @return Boolean False. * @return Boolean False
*/ */
public function isWrapper() public function isWrapper()
{ {

View File

@ -107,7 +107,7 @@ class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \RuntimeException * @expectedException \RuntimeException
*/ */
public function testtStartOnDemandException() public function testStartOnDemandException()
{ {
$storage = new MockArraySessionStorage('MOCKSESSID', null, MockArraySessionStorage::NO_START_ON_DEMAND_STRICT); $storage = new MockArraySessionStorage('MOCKSESSID', null, MockArraySessionStorage::NO_START_ON_DEMAND_STRICT);
$storage->registerBag(new AttributeBag); $storage->registerBag(new AttributeBag);

View File

@ -127,7 +127,7 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \RuntimeException * @expectedException \RuntimeException
*/ */
public function testtStartOnDemandException() public function testStartOnDemandException()
{ {
$storage = new MockFileSessionStorage($this->sessionDir, 'MOCKSESSID', null, MockFileSessionStorage::NO_START_ON_DEMAND_STRICT); $storage = new MockFileSessionStorage($this->sessionDir, 'MOCKSESSID', null, MockFileSessionStorage::NO_START_ON_DEMAND_STRICT);
$storage->registerBag(new AttributeBag); $storage->registerBag(new AttributeBag);

View File

@ -159,7 +159,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \RuntimeException * @expectedException \RuntimeException
*/ */
public function testtStartOnDemandException() public function testStartOnDemandException()
{ {
$storage = new NativeSessionStorage(array(), null, null, NativeSessionStorage::NO_START_ON_DEMAND_STRICT); $storage = new NativeSessionStorage(array(), null, null, NativeSessionStorage::NO_START_ON_DEMAND_STRICT);
$storage->registerBag(new AttributeBag); $storage->registerBag(new AttributeBag);