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

Commit

Permalink
Merge branch 'master' into markup
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Markup/Parser/Textile.php
	library/Zend/Markup/Renderer/AbstractRenderer.php
	library/Zend/Markup/Renderer/Html.php
  • Loading branch information
kokx committed Oct 30, 2010
2 parents 6250f70 + 63c4a7e commit 9c4e0cc
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 418 deletions.
11 changes: 5 additions & 6 deletions src/AbstractManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Session
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand Down Expand Up @@ -87,7 +86,7 @@ public function __construct($config = null, $storage = null)
}
} elseif (is_string($config)) {
if (!class_exists($config)) {
throw new Exception('Configuration class provided is invalid; not found');
throw new Exception\InvalidArgumentException('Configuration class provided is invalid; not found');
}
$config = new $config;
}
Expand Down Expand Up @@ -121,7 +120,7 @@ protected function _setConfig($config)
}

if (!class_exists($class)) {
throw new Exception('Class provided for configuration is invalid; not found');
throw new Exception\InvalidArgumentException('Class provided for configuration is invalid; not found');
}

$options = $config;
Expand All @@ -131,7 +130,7 @@ protected function _setConfig($config)
}

if (!$config instanceof Configuration) {
throw new Exception('Configuration type provided is invalid; must implement Zend\\Session\\Configuration');
throw new Exception\InvalidArgumentException('Configuration type provided is invalid; must implement Zend\\Session\\Configuration');
}
$this->_config = $config;
}
Expand Down Expand Up @@ -163,13 +162,13 @@ protected function _setStorage($storage)

if (is_string($storage)) {
if (!class_exists($storage)) {
throw new Exception('Class provided for Storage does not exist');
throw new Exception\InvalidArgumentException('Class provided for Storage does not exist');
}
$storage = new $storage();
}

if (!$storage instanceof Storage) {
throw new Exception('Storage type provided is invalid; must implement Zend\\Session\\Storage');
throw new Exception\InvalidArgumentException('Storage type provided is invalid; must implement Zend\\Session\\Storage');
}

$this->_storage = $storage;
Expand Down
1 change: 0 additions & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Session
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand Down
13 changes: 6 additions & 7 deletions src/Configuration/SessionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Session
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand All @@ -25,7 +24,7 @@
namespace Zend\Session\Configuration;

use Zend\Validator\Hostname\Hostname as HostnameValidator,
Zend\Session\Exception as SessionException;
Zend\Session\Exception;

/**
* Session configuration proxying to session INI options
Expand Down Expand Up @@ -178,7 +177,7 @@ public function setSaveHandler($saveHandler)
ini_set('session.save_handler', $saveHandler);
restore_error_handler();
if ($this->_phpErrorCode >= E_WARNING) {
throw new SessionException('Invalid save handler specified');
throw new Exception\InvalidArgumentException('Invalid save handler specified');
}

$this->setOption('save_handler', $saveHandler);
Expand All @@ -200,7 +199,7 @@ public function setSerializeHandler($serializeHandler)
ini_set('session.serialize_handler', $serializeHandler);
restore_error_handler();
if ($this->_phpErrorCode >= E_WARNING) {
throw new SessionException('Invalid serialize handler specified');
throw new Exception\InvalidArgumentException('Invalid serialize handler specified');
}

$this->_serializeHandler = (string) $serializeHandler;
Expand All @@ -213,7 +212,7 @@ public function setCacheLimiter($cacheLimiter)
{
$cacheLimiter = (string) $cacheLimiter;
if (!in_array($cacheLimiter, $this->_validCacheLimiters)) {
throw new SessionException('Invalid cache limiter provided');
throw new Exception\InvalidArgumentException('Invalid cache limiter provided');
}
$this->setOption('cache_limiter', $cacheLimiter);
ini_set('session.cache_limiter', $cacheLimiter);
Expand Down Expand Up @@ -250,7 +249,7 @@ public function setHashFunction($hashFunction)
$hashFunction = (string) $hashFunction;
$validHashFunctions = $this->_getHashFunctions();
if (!in_array($hashFunction, $this->_getHashFunctions(), true)) {
throw new SessionException('Invalid hash function provided');
throw new Exception\InvalidArgumentException('Invalid hash function provided');
}

$this->setOption('hash_function', $hashFunction);
Expand All @@ -270,7 +269,7 @@ public function setHashBitsPerCharacter($hashBitsPerCharacter)
if (!is_numeric($hashBitsPerCharacter)
|| !in_array($hashBitsPerCharacter, $this->_validHashBitsPerCharacters)
) {
throw new SessionException('Invalid hash bits per character provided');
throw new Exception\InvalidArgumentException('Invalid hash bits per character provided');
}

$hashBitsPerCharacter = (int) $hashBitsPerCharacter;
Expand Down
47 changes: 23 additions & 24 deletions src/Configuration/StandardConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Session
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand All @@ -25,7 +24,7 @@
namespace Zend\Session\Configuration;

use Zend\Session\Configuration as Configurable,
Zend\Session\Exception as SessionException,
Zend\Session\Exception,
Zend\Validator\Hostname as HostnameValidator,
Zend\Filter\Word\CamelCaseToUnderscore as CamelCaseToUnderscoreFilter;

Expand Down Expand Up @@ -132,7 +131,7 @@ public function getStorageOption($name)
public function setSavePath($path)
{
if (!is_dir($path)) {
throw new SessionException('Invalid save_path provided');
throw new Exception\InvalidArgumentException('Invalid save_path provided');
}
$this->_savePath = $path;
$this->setStorageOption('save_path', $path);
Expand Down Expand Up @@ -163,7 +162,7 @@ public function setName($name)
{
$this->_name = (string) $name;
if (empty($this->_name)) {
throw new SessionException('Invalid session name; cannot be empty');
throw new Exception\InvalidArgumentException('Invalid session name; cannot be empty');
}
$this->setStorageOption('name', $this->_name);
return $this;
Expand Down Expand Up @@ -192,11 +191,11 @@ public function getName()
public function setGcProbability($gcProbability)
{
if (!is_numeric($gcProbability)) {
throw new SessionException('Invalid gc_probability; must be numeric');
throw new Exception\InvalidArgumentException('Invalid gc_probability; must be numeric');
}
$gcProbability = (int) $gcProbability;
if (1 > $gcProbability || 100 < $gcProbability) {
throw new SessionException('Invalid gc_probability; must be a percentage');
throw new Exception\InvalidArgumentException('Invalid gc_probability; must be a percentage');
}
$this->setOption('gc_probability', $gcProbability);
$this->setStorageOption('gc_probability', $gcProbability);
Expand All @@ -213,11 +212,11 @@ public function setGcProbability($gcProbability)
public function setGcDivisor($gcDivisor)
{
if (!is_numeric($gcDivisor)) {
throw new SessionException('Invalid gc_divisor; must be numeric');
throw new Exception\InvalidArgumentException('Invalid gc_divisor; must be numeric');
}
$gcDivisor = (int) $gcDivisor;
if (1 > $gcDivisor) {
throw new SessionException('Invalid gc_divisor; must be a positive integer');
throw new Exception\InvalidArgumentException('Invalid gc_divisor; must be a positive integer');
}
$this->setOption('gc_divisor', $gcDivisor);
$this->setStorageOption('gc_divisor', $gcDivisor);
Expand All @@ -234,12 +233,12 @@ public function setGcDivisor($gcDivisor)
public function setGcMaxlifetime($gcMaxlifetime)
{
if (!is_numeric($gcMaxlifetime)) {
throw new SessionException('Invalid gc_maxlifetime; must be numeric');
throw new Exception\InvalidArgumentException('Invalid gc_maxlifetime; must be numeric');
}

$gcMaxlifetime = (int) $gcMaxlifetime;
if (1 > $gcMaxlifetime) {
throw new SessionException('Invalid gc_maxlifetime; must be a positive integer');
throw new Exception\InvalidArgumentException('Invalid gc_maxlifetime; must be a positive integer');
}

$this->setOption('gc_maxlifetime', $gcMaxlifetime);
Expand All @@ -257,10 +256,10 @@ public function setGcMaxlifetime($gcMaxlifetime)
public function setCookieLifetime($cookieLifetime)
{
if (!is_numeric($cookieLifetime)) {
throw new SessionException('Invalid cookie_lifetime; must be numeric');
throw new Exception\InvalidArgumentException('Invalid cookie_lifetime; must be numeric');
}
if (0 > $cookieLifetime) {
throw new SessionException('Invalid cookie_lifetime; must be a positive integer or zero');
throw new Exception\InvalidArgumentException('Invalid cookie_lifetime; must be a positive integer or zero');
}

$this->_cookieLifetime = (int) $cookieLifetime;
Expand Down Expand Up @@ -294,7 +293,7 @@ public function setCookiePath($cookiePath)

$test = parse_url($cookiePath, PHP_URL_PATH);
if ($test != $cookiePath || '/' != $test[0]) {
throw new SessionException('Invalid cookie path');
throw new Exception\InvalidArgumentException('Invalid cookie path');
}

$this->_cookiePath = $cookiePath;
Expand Down Expand Up @@ -325,13 +324,13 @@ public function getCookiePath()
public function setCookieDomain($cookieDomain)
{
if (!is_string($cookieDomain)) {
throw new SessionException('Invalid cookie domain: must be a string');
throw new Exception\InvalidArgumentException('Invalid cookie domain: must be a string');
}

$validator = new HostnameValidator(HostnameValidator::ALLOW_ALL);

if (!empty($cookieDomain) && !$validator->isValid($cookieDomain)) {
throw new SessionException('Invalid cookie domain: ' . implode('; ', $validator->getMessages()));
throw new Exception\InvalidArgumentException('Invalid cookie domain: ' . implode('; ', $validator->getMessages()));
}

$this->_cookieDomain = $cookieDomain;
Expand Down Expand Up @@ -443,7 +442,7 @@ public function getUseCookies()
public function setEntropyFile($path)
{
if (!file_exists($path) || is_dir($path) || !is_readable($path)) {
throw new SessionException('Invalid entropy_file provided');
throw new Exception\InvalidArgumentException('Invalid entropy_file provided');
}
$this->setOption('entropy_file', $path);
$this->setStorageOption('entropy_file', $path);
Expand All @@ -460,10 +459,10 @@ public function setEntropyFile($path)
public function setEntropyLength($entropyLength)
{
if (!is_numeric($entropyLength)) {
throw new SessionException('Invalid entropy_length; must be numeric');
throw new Exception\InvalidArgumentException('Invalid entropy_length; must be numeric');
}
if (0 > $entropyLength) {
throw new SessionException('Invalid entropy_length; must be a positive integer or zero');
throw new Exception\InvalidArgumentException('Invalid entropy_length; must be a positive integer or zero');
}

$this->setOption('entropy_length', $entropyLength);
Expand All @@ -481,12 +480,12 @@ public function setEntropyLength($entropyLength)
public function setCacheExpire($cacheExpire)
{
if (!is_numeric($cacheExpire)) {
throw new SessionException('Invalid cache_expire; must be numeric');
throw new Exception\InvalidArgumentException('Invalid cache_expire; must be numeric');
}

$cacheExpire = (int) $cacheExpire;
if (1 > $cacheExpire) {
throw new SessionException('Invalid cache_expire; must be a positive integer');
throw new Exception\InvalidArgumentException('Invalid cache_expire; must be a positive integer');
}

$this->setOption('cache_expire', $cacheExpire);
Expand All @@ -504,7 +503,7 @@ public function setCacheExpire($cacheExpire)
public function setHashBitsPerCharacter($hashBitsPerCharacter)
{
if (!is_numeric($hashBitsPerCharacter)) {
throw new SessionException('Invalid hash bits per character provided');
throw new Exception\InvalidArgumentException('Invalid hash bits per character provided');
}
$hashBitsPerCharacter = (int) $hashBitsPerCharacter;
$this->setOption('hash_bits_per_character', $hashBitsPerCharacter);
Expand All @@ -522,12 +521,12 @@ public function setHashBitsPerCharacter($hashBitsPerCharacter)
public function setRememberMeSeconds($rememberMeSeconds)
{
if (!is_numeric($rememberMeSeconds)) {
throw new SessionException('Invalid remember_me_seconds; must be numeric');
throw new Exception\InvalidArgumentException('Invalid remember_me_seconds; must be numeric');
}

$rememberMeSeconds = (int) $rememberMeSeconds;
if (1 > $rememberMeSeconds) {
throw new SessionException('Invalid remember_me_seconds; must be a positive integer');
throw new Exception\InvalidArgumentException('Invalid remember_me_seconds; must be a positive integer');
}

$this->_rememberMeSeconds = $rememberMeSeconds;
Expand Down Expand Up @@ -683,7 +682,7 @@ public function __call($method, $args)
$value = array_shift($args);
return $this->setOption($key, $value);
}
throw new \BadMethodCallException(sprintf('Method "%s" does not exist', $method));
throw new Exception\BadMethodCallException(sprintf('Method "%s" does not exist', $method));
}

/**
Expand Down
13 changes: 6 additions & 7 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Session
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand Down Expand Up @@ -73,7 +72,7 @@ class Container extends ArrayObject
public function __construct($name = 'Default', $manager = null)
{
if (!preg_match('/^[a-z][a-z0-9_]+$/i', $name)) {
throw new Exception('Name passed to container is invalid; must consist of alphanumerics and underscores only');
throw new Exception\InvalidArgumentException('Name passed to container is invalid; must consist of alphanumerics and underscores only');
}
$this->_name = $name;
$this->_setManager($manager);
Expand Down Expand Up @@ -109,7 +108,7 @@ public static function getDefaultManager()
if (null === self::$_defaultManager) {
$manager = new self::$_managerDefaultClass();
if (!$manager instanceof Manager) {
throw new Exception('Invalid manager type provided; must implement Manager');
throw new Exception\InvalidArgumentException('Invalid manager type provided; must implement Manager');
}
self::$_defaultManager = $manager;
}
Expand Down Expand Up @@ -148,7 +147,7 @@ protected function _setManager($manager)
$manager = self::getDefaultManager();
}
if (!$manager instanceof Manager) {
throw new Exception('Manager provided is invalid; must implement Manager interface');
throw new Exception\InvalidArgumentException('Manager provided is invalid; must implement Manager interface');
}
$this->_manager = $manager;
return $this;
Expand Down Expand Up @@ -199,7 +198,7 @@ protected function _verifyNamespace($createContainer = true)
$storage[$name] = $this->_createContainer();
}
if (!is_array($storage[$name]) && !$storage[$name] instanceof ArrayObject) {
throw new Exception('Container cannot write to storage due to type mismatch');
throw new Exception\RuntimeException('Container cannot write to storage due to type mismatch');
}
return $storage;
}
Expand Down Expand Up @@ -488,7 +487,7 @@ public function setExpirationSeconds($ttl, $vars = null)
// Create metadata array to merge in
$data = array('EXPIRE_KEYS' => $expires);
} else {
throw new Exception('Unknown data provided as second argument to ' . __METHOD__);
throw new Exception\InvalidArgumentException('Unknown data provided as second argument to ' . __METHOD__);
}

$storage->setMetadata(
Expand Down Expand Up @@ -534,7 +533,7 @@ public function setExpirationHops($hops, $vars = null)
// Create metadata array to merge in
$data = array('EXPIRE_HOPS_KEYS' => $expires);
} else {
throw new Exception('Unknown data provided as second argument to ' . __METHOD__);
throw new Exception\InvalidArgumentException('Unknown data provided as second argument to ' . __METHOD__);
}

$storage->setMetadata(
Expand Down
Loading

0 comments on commit 9c4e0cc

Please sign in to comment.