Coding standards
As requested by @fabpot
This commit is contained in:
parent
2583c2614f
commit
1f521d8d62
@ -4,7 +4,7 @@ CHANGELOG
|
||||
2.3.0
|
||||
|
||||
* `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
|
||||
-----
|
||||
|
@ -49,7 +49,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* 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 FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
|
||||
*/
|
||||
|
@ -42,7 +42,7 @@ interface SessionBagInterface
|
||||
/**
|
||||
* Clears out data from bag.
|
||||
*
|
||||
* @return mixed Whatever data was contained.
|
||||
* @return mixed Whatever data was contained
|
||||
*/
|
||||
public function clear();
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ interface SessionInterface
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@ -34,7 +34,7 @@ interface SessionInterface
|
||||
/**
|
||||
* Returns the session ID.
|
||||
*
|
||||
* @return string The session ID.
|
||||
* @return string The session ID
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
@ -52,7 +52,7 @@ interface SessionInterface
|
||||
/**
|
||||
* Returns the session name.
|
||||
*
|
||||
* @return mixed The session name.
|
||||
* @return mixed The session name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
@ -76,9 +76,9 @@ interface SessionInterface
|
||||
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
|
||||
* will leave the system settings unchanged, 0 sets the cookie
|
||||
* 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
|
||||
*/
|
||||
@ -92,9 +92,9 @@ interface SessionInterface
|
||||
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
|
||||
* will leave the system settings unchanged, 0 sets the cookie
|
||||
* 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
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
|
||||
private $ttl;
|
||||
|
||||
/**
|
||||
* @var string Key prefix for shared environments.
|
||||
* @var string Key prefix for shared environments
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
||||
private $ttl;
|
||||
|
||||
/**
|
||||
* @var string Key prefix for shared environments.
|
||||
* @var string Key prefix for shared environments
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
|
@ -52,11 +52,11 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
||||
public function __construct($mongo, array $options)
|
||||
{
|
||||
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'])) {
|
||||
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;
|
||||
|
@ -24,10 +24,10 @@ class NativeFileSessionHandler extends NativeSessionHandler
|
||||
* Constructor.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@ -41,7 +41,7 @@ class NativeFileSessionHandler extends NativeSessionHandler
|
||||
|
||||
if ($count = substr_count($savePath, ';')) {
|
||||
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
|
||||
|
@ -20,12 +20,12 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
class PdoSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var \PDO PDO instance.
|
||||
* @var \PDO PDO instance
|
||||
*/
|
||||
private $pdo;
|
||||
|
||||
/**
|
||||
* @var array Database options.
|
||||
* @var array Database options
|
||||
*/
|
||||
private $dbOptions;
|
||||
|
||||
@ -90,7 +90,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
||||
$stmt->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
} 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;
|
||||
@ -113,7 +113,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
||||
$stmt->bindValue(':time', time() - $lifetime, \PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} 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;
|
||||
@ -149,7 +149,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
||||
|
||||
return '';
|
||||
} 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) {
|
||||
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;
|
||||
@ -216,7 +216,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
||||
* @param string $id
|
||||
* @param string $data
|
||||
*
|
||||
* @return boolean True.
|
||||
* @return boolean True
|
||||
*/
|
||||
private function createNewSession($id, $data = '')
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ class MetadataBag implements SessionBagInterface
|
||||
/**
|
||||
* 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')
|
||||
{
|
||||
@ -90,7 +90,7 @@ class MetadataBag implements SessionBagInterface
|
||||
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
|
||||
* will leave the system settings unchanged, 0 sets the cookie
|
||||
* to expire with browser session. Time is in seconds, and is
|
||||
* not a Unix timestamp.
|
||||
* not a Unix timestamp
|
||||
*/
|
||||
public function stampNew($lifetime = null)
|
||||
{
|
||||
|
@ -71,9 +71,9 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Session name.
|
||||
* @param MetadataBag $metaBag MetadataBag instance.
|
||||
* @param integer $mode Session on demand mode.
|
||||
* @param string $name Session name
|
||||
* @param MetadataBag $metaBag MetadataBag instance
|
||||
* @param integer $mode Session on demand mode
|
||||
*/
|
||||
public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null, $mode = self::START_ON_DEMAND)
|
||||
{
|
||||
@ -167,7 +167,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
public function save()
|
||||
{
|
||||
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
|
||||
$this->closed = false;
|
||||
@ -204,13 +204,13 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
public function getBag($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) {
|
||||
$this->start();
|
||||
} 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];
|
||||
|
@ -32,10 +32,10 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $savePath Path of directory to save session files.
|
||||
* @param string $name Session name.
|
||||
* @param MetadataBag $metaBag MetadataBag instance.
|
||||
* @param integer $mode Start on demand mode.
|
||||
* @param string $savePath Path of directory to save session files
|
||||
* @param string $name Session name
|
||||
* @param MetadataBag $metaBag MetadataBag instance
|
||||
* @param integer $mode Start on demand mode
|
||||
*/
|
||||
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()
|
||||
{
|
||||
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));
|
||||
|
@ -102,10 +102,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
* upload_progress.min-freq, "1"
|
||||
* url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset="
|
||||
*
|
||||
* @param array $options Session configuration options.
|
||||
* @param object $handler SessionHandlerInterface.
|
||||
* @param MetadataBag $metaBag MetadataBag.
|
||||
* @param integer $mode Start on demand mode.
|
||||
* @param array $options Session configuration options
|
||||
* @param object $handler SessionHandlerInterface
|
||||
* @param MetadataBag $metaBag MetadataBag
|
||||
* @param integer $mode Start on demand mode
|
||||
*/
|
||||
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
|
||||
if (!session_start()) {
|
||||
throw new \RuntimeException('Failed to start the session');
|
||||
throw new \RuntimeException('Failed to start the session.');
|
||||
}
|
||||
|
||||
$this->loadSession();
|
||||
@ -266,13 +266,13 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
public function getBag($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) {
|
||||
$this->start();
|
||||
} 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];
|
||||
@ -316,7 +316,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
* For convenience we omit 'session.' from the beginning of the 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
|
||||
*/
|
||||
@ -354,7 +354,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
* @see http://php.net/sessionhandlerinterface
|
||||
* @see http://php.net/sessionhandler
|
||||
*
|
||||
* @param object $saveHandler Default null means NativeProxy.
|
||||
* @param object $saveHandler Default null means NativeProxy
|
||||
*/
|
||||
public function setSaveHandler($saveHandler = null)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ abstract class AbstractProxy
|
||||
protected $saveHandlerName;
|
||||
|
||||
/**
|
||||
* Gets the session.save_handler name.
|
||||
* Gets the session.save_handler name
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@ -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
|
||||
*/
|
||||
@ -105,7 +105,7 @@ abstract class AbstractProxy
|
||||
public function setId($id)
|
||||
{
|
||||
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);
|
||||
@ -131,7 +131,7 @@ abstract class AbstractProxy
|
||||
public function setName($name)
|
||||
{
|
||||
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);
|
||||
|
@ -32,7 +32,7 @@ class NativeProxy extends AbstractProxy
|
||||
/**
|
||||
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
|
||||
*
|
||||
* @return Boolean False.
|
||||
* @return Boolean False
|
||||
*/
|
||||
public function isWrapper()
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testtStartOnDemandException()
|
||||
public function testStartOnDemandException()
|
||||
{
|
||||
$storage = new MockArraySessionStorage('MOCKSESSID', null, MockArraySessionStorage::NO_START_ON_DEMAND_STRICT);
|
||||
$storage->registerBag(new AttributeBag);
|
||||
|
@ -127,7 +127,7 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testtStartOnDemandException()
|
||||
public function testStartOnDemandException()
|
||||
{
|
||||
$storage = new MockFileSessionStorage($this->sessionDir, 'MOCKSESSID', null, MockFileSessionStorage::NO_START_ON_DEMAND_STRICT);
|
||||
$storage->registerBag(new AttributeBag);
|
||||
|
@ -159,7 +159,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testtStartOnDemandException()
|
||||
public function testStartOnDemandException()
|
||||
{
|
||||
$storage = new NativeSessionStorage(array(), null, null, NativeSessionStorage::NO_START_ON_DEMAND_STRICT);
|
||||
$storage->registerBag(new AttributeBag);
|
||||
|
Reference in New Issue
Block a user