Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zend-session-cs' of https://github.com/mwillbank…
Browse files Browse the repository at this point in the history
…s/zf2 into hotfix/session-cs
  • Loading branch information
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 255 deletions.
40 changes: 20 additions & 20 deletions src/AbstractManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@ abstract class AbstractManager implements Manager
/**
* @var Configuration
*/
protected $_config;
protected $config;

/**
* Default configuration class to use when no configuration provided
* @var string
*/
protected $_configDefaultClass = 'Zend\\Session\\Configuration\\SessionConfiguration';
protected $configDefaultClass = 'Zend\\Session\\Configuration\\SessionConfiguration';

/**
* @var Storage
*/
protected $_storage;
protected $storage;

/**
* Default storage class to use when no storage provided
* @var string
*/
protected $_storageDefaultClass = 'Zend\\Session\\Storage\\SessionStorage';
protected $storageDefaultClass = 'Zend\\Session\\Storage\\SessionStorage';

/**
* @var SaveHandler
*/
protected $_saveHandler;
protected $saveHandler;


/**
Expand Down Expand Up @@ -103,9 +103,9 @@ public function __construct($config = null, $storage = null, $saveHandler = null
$config = new $config;
}

$this->_setConfig($config);
$this->_setStorage($storage);
$this->_setSaveHandler($saveHandler);
$this->setConfig($config);
$this->setStorage($storage);
$this->setSaveHandler($saveHandler);
}

/**
Expand All @@ -119,14 +119,14 @@ public function __construct($config = null, $storage = null, $saveHandler = null
* @param null|string|array|Configuration $config
* @return void
*/
protected function _setConfig($config)
public function setConfig($config)
{
if (null === $config) {
$config = new $this->_configDefaultClass();
$config = new $this->configDefaultClass();
}

if (is_array($config)) {
$class = $this->_configDefaultClass;
$class = $this->configDefaultClass;
if (array_key_exists('class', $config)) {
$class = $config['class'];
unset($config['class']);
Expand All @@ -145,7 +145,7 @@ protected function _setConfig($config)
if (!$config instanceof Configuration) {
throw new Exception\InvalidArgumentException('Configuration type provided is invalid; must implement Zend\\Session\\Configuration');
}
$this->_config = $config;
$this->config = $config;
}

/**
Expand All @@ -155,7 +155,7 @@ protected function _setConfig($config)
*/
public function getConfig()
{
return $this->_config;
return $this->config;
}

/**
Expand All @@ -167,10 +167,10 @@ public function getConfig()
* @param null|string|Storage $storage
* @return void
*/
protected function _setStorage($storage)
public function setStorage($storage)
{
if (null === $storage) {
$storage = new $this->_storageDefaultClass();
$storage = new $this->storageDefaultClass();
}

if (is_string($storage)) {
Expand All @@ -184,7 +184,7 @@ protected function _setStorage($storage)
throw new Exception\InvalidArgumentException('Storage type provided is invalid; must implement Zend\\Session\\Storage');
}

$this->_storage = $storage;
$this->storage = $storage;
}

/**
Expand All @@ -194,7 +194,7 @@ protected function _setStorage($storage)
*/
public function getStorage()
{
return $this->_storage;
return $this->storage;
}

/**
Expand All @@ -206,7 +206,7 @@ public function getStorage()
* @param null|string|SaveHandler $saveHandler
* @return void
*/
public function _setSaveHandler($saveHandler)
public function setSaveHandler($saveHandler)
{
if (null === $saveHandler) {
return ;
Expand All @@ -223,7 +223,7 @@ public function _setSaveHandler($saveHandler)
throw new Exception\InvalidArgumentException('SaveHandler type provided is invalid; must implement Zend\\Session\\SaveHandler');
}

$this->_saveHandler = $saveHandler;
$this->saveHandler = $saveHandler;
}

/**
Expand All @@ -233,6 +233,6 @@ public function _setSaveHandler($saveHandler)
*/
public function getSaveHandler()
{
return $this->_saveHandler;
return $this->saveHandler;
}
}
52 changes: 26 additions & 26 deletions src/Configuration/SessionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@
class SessionConfiguration extends StandardConfiguration
{
/**
* Used with {@link _handleError()}; stores PHP error code
* Used with {@link handleError()}; stores PHP error code
* @var int
*/
protected $_phpErrorCode = false;
protected $phpErrorCode = false;

/**
* Used with {@link _handleError()}; stores PHP error message
* Used with {@link handleError()}; stores PHP error message
* @var string
*/
protected $_phpErrorMessage = false;
protected $phpErrorMessage = false;

/**
* @var int Default number of seconds to make session sticky, when rememberMe() is called
*/
protected $_rememberMeSeconds = 1209600; // 2 weeks
protected $rememberMeSeconds = 1209600; // 2 weeks

/**
* @var string session.serialize_handler
*/
protected $_serializeHandler;
protected $serializeHandler;

/**
* @var array Valid cache limiters (per session.cache_limiter)
*/
protected $_validCacheLimiters = array(
protected $validCacheLimiters = array(
'nocache',
'public',
'private',
Expand All @@ -72,7 +72,7 @@ class SessionConfiguration extends StandardConfiguration
/**
* @var array Valid hash bits per character (per session.hash_bits_per_character)
*/
protected $_validHashBitsPerCharacters = array(
protected $validHashBitsPerCharacters = array(
4,
5,
6,
Expand All @@ -81,7 +81,7 @@ class SessionConfiguration extends StandardConfiguration
/**
* @var array Valid hash functions (per session.hash_function)
*/
protected $_validHashFunctions;
protected $validHashFunctions;

/**
* Set storage option in backend configuration store
Expand Down Expand Up @@ -126,7 +126,7 @@ public function getStorageOption($name)
switch ($name) {
case 'remember_me_seconds':
// No remote storage option; just return the current value
return $this->_rememberMeSeconds;
return $this->rememberMeSeconds;
case 'url_rewriter_tags':
$key = 'url_rewriter.tags';
break;
Expand Down Expand Up @@ -157,10 +157,10 @@ public function getStorageOption($name)
* @param string $message
* @return void
*/
protected function _handleError($code, $message)
protected function handleError($code, $message)
{
$this->_phpErrorCode = $code;
$this->_phpErrorMessage = $message;
$this->phpErrorCode = $code;
$this->phpErrorMessage = $message;
}

/**
Expand All @@ -173,10 +173,10 @@ protected function _handleError($code, $message)
public function setPhpSaveHandler($saveHandler)
{
$saveHandler = (string) $saveHandler;
set_error_handler(array($this, '_handleError'));
set_error_handler(array($this, 'handleError'));
ini_set('session.save_handler', $saveHandler);
restore_error_handler();
if ($this->_phpErrorCode >= E_WARNING) {
if ($this->phpErrorCode >= E_WARNING) {
throw new Exception\InvalidArgumentException('Invalid save handler specified');
}

Expand All @@ -195,14 +195,14 @@ public function setSerializeHandler($serializeHandler)
{
$serializeHandler = (string) $serializeHandler;

set_error_handler(array($this, '_handleError'));
set_error_handler(array($this, 'handleError'));
ini_set('session.serialize_handler', $serializeHandler);
restore_error_handler();
if ($this->_phpErrorCode >= E_WARNING) {
if ($this->phpErrorCode >= E_WARNING) {
throw new Exception\InvalidArgumentException('Invalid serialize handler specified');
}

$this->_serializeHandler = (string) $serializeHandler;
$this->serializeHandler = (string) $serializeHandler;
return $this;
}

Expand All @@ -211,7 +211,7 @@ public function setSerializeHandler($serializeHandler)
public function setCacheLimiter($cacheLimiter)
{
$cacheLimiter = (string) $cacheLimiter;
if (!in_array($cacheLimiter, $this->_validCacheLimiters)) {
if (!in_array($cacheLimiter, $this->validCacheLimiters)) {
throw new Exception\InvalidArgumentException('Invalid cache limiter provided');
}
$this->setOption('cache_limiter', $cacheLimiter);
Expand All @@ -224,17 +224,17 @@ public function setCacheLimiter($cacheLimiter)
*
* @return array
*/
protected function _getHashFunctions()
protected function getHashFunctions()
{
if (empty($this->_validHashFunctions)) {
if (empty($this->validHashFunctions)) {
/**
* @see http://php.net/manual/en/session.configuration.php#ini.session.hash-function
* "0" and "1" refer to MD5-128 and SHA1-160, respectively, and are
* valid in addition to whatever is reported by hash_algos()
*/
$this->_validHashFunctions = array('0', '1') + hash_algos();
$this->validHashFunctions = array('0', '1') + hash_algos();
}
return $this->_validHashFunctions;
return $this->validHashFunctions;
}

/**
Expand All @@ -247,8 +247,8 @@ protected function _getHashFunctions()
public function setHashFunction($hashFunction)
{
$hashFunction = (string) $hashFunction;
$validHashFunctions = $this->_getHashFunctions();
if (!in_array($hashFunction, $this->_getHashFunctions(), true)) {
$validHashFunctions = $this->getHashFunctions();
if (!in_array($hashFunction, $this->getHashFunctions(), true)) {
throw new Exception\InvalidArgumentException('Invalid hash function provided');
}

Expand All @@ -267,7 +267,7 @@ public function setHashFunction($hashFunction)
public function setHashBitsPerCharacter($hashBitsPerCharacter)
{
if (!is_numeric($hashBitsPerCharacter)
|| !in_array($hashBitsPerCharacter, $this->_validHashBitsPerCharacters)
|| !in_array($hashBitsPerCharacter, $this->validHashBitsPerCharacters)
) {
throw new Exception\InvalidArgumentException('Invalid hash bits per character provided');
}
Expand Down
Loading

0 comments on commit b6eb950

Please sign in to comment.