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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Preparing to tag 2.1.0 -- all new features from develop are now merged to master.
  • Loading branch information
weierophinney committed Jan 29, 2013
164 parents 3038cfa + 1112202 + b6d0c88 + 7edee62 + 60ea64c + a08bcca + b40ec3e + 63172ed + 448f428 + 92a516a + 5ecbc99 + a2df21b + 4de87f2 + 7c259ec + a22bdcb + 084ad9f + 9414e5a + 489be93 + cb39e7e + 54a28dc + c9c769e + dda791d + 70d382a + 8bbad0e + 9321185 + 7ab35a6 + b93694e + 3ea7087 + 0fe3d3a + bd5e189 + d1cba17 + 8d75392 + 3fb5b55 + 6cb0ccb + 30aa565 + 8409977 + 8074ba0 + 8f92486 + 94860d1 + 05d33c4 + 425826b + f0e91f0 + e31468f + 7d2af87 + 2e4dc80 + 19d128f + 1b9e4b2 + 1c46483 + fdda3f2 + 595fcd1 + 213395c + 8e514a8 + 2f30186 + bb4ed65 + 132d5b6 + 030ff33 + f2f20f3 + a50e133 + 4c554ee + dbfb1b8 + ccab83f + 00b350f + 78945d0 + f0e5f4b + ceb7d8c + 9e124d1 + 3de5912 + b6a974a + 10a6438 + cb6c1e7 + 18afd6c + 3baf1bd + c800904 + f52dcb8 + 126ccb2 + e7d6206 + e2d24ab + ec1abfc + 290ea90 + 9f4ca1b + edaa760 + c4c0c95 + d21f055 + 5b18029 + e6b97af + 010fb36 + 64c7b8d + 636523e + 4cc2cd6 + e34098a + 16367cd + 943c77f + 8226e5b + 0b47726 + 3cd8a03 + cc4782c + 9c653a6 + 656dbe5 + 9bce1ba + 7dc18ca + 861130d + 2d2ffbd + 4f413a5 + 2e1067a + 1d082e4 + e8aeb79 + b562091 + ff2fdc3 + 4aa72c0 + 1bb67ac + cd015c8 + 5e89910 + 0c21258 + dd54faf + 57f9063 + b88ce2e + af68643 + 06cd3b4 + 2c71b71 + ee02c35 + 9456314 + 5a77a7b + e98a077 + 738f2e6 + cb1e63c + 736df07 + d0a0154 + 990523c + 78687de + a5b6e79 + 6e9dfe9 + e201a1c + d9b45ef + 76222ad + 16d67da + 1ab2258 + b81d711 + ed2e9bc + 61efe82 + f353ea5 + 1f02519 + 58c1fe8 + ed502d9 + 2defba6 + 4885013 + 06a8384 + 17d9eed + 3b21b5d + c62101c + 909ef34 + 13d376a + efcb00e + 0a0842f + 8a75367 + 98a3cf5 + 270f2c4 + c8fb359 + 8d37cd0 + 4d868a7 + 555cb91 + 9fe9c96 + a3ecac6 + 10e77c1 + e0d3e13 commit eb61c8f
Show file tree
Hide file tree
Showing 76 changed files with 3,686 additions and 244 deletions.
15 changes: 5 additions & 10 deletions src/AbstractOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;

use Traversable;

/**
* @category Zend
* @package Zend_Stdlib
*/
abstract class AbstractOptions implements ParameterObjectInterface
{
/**
Expand All @@ -28,8 +23,6 @@ abstract class AbstractOptions implements ParameterObjectInterface

/**
* @param array|Traversable|null $options
* @return AbstractOptions
* @throws Exception\InvalidArgumentException
*/
public function __construct($options = null)
{
Expand All @@ -41,7 +34,7 @@ public function __construct($options = null)
/**
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
* @return void
* @return AbstractOptions Provides fluent interface
*/
public function setFromArray($options)
{
Expand All @@ -55,6 +48,7 @@ public function setFromArray($options)
foreach ($options as $key => $value) {
$this->__set($key, $value);
}
return $this;
}

/**
Expand Down Expand Up @@ -115,6 +109,7 @@ public function __get($key)
. 'which must be defined'
);
}

return $this->{$getter}();
}

Expand All @@ -131,14 +126,14 @@ public function __isset($key)
/**
* @see ParameterObject::__unset()
* @param string $key
* @return void
* @throws Exception\InvalidArgumentException
* @return void
*/
public function __unset($key)
{
try {
$this->__set($key, null);
} catch (\InvalidArgumentException $e) {
} catch (Exception\BadMethodCallException $e) {
throw new Exception\InvalidArgumentException(
'The class property $' . $key . ' cannot be unset as'
. ' NULL is an invalid value for it',
Expand Down
5 changes: 0 additions & 5 deletions src/ArraySerializableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;

/**
* @category Zend
* @package Zend_Stdlib
*/
interface ArraySerializableInterface
{
/**
Expand Down
4 changes: 0 additions & 4 deletions src/ArrayStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;
Expand All @@ -15,9 +14,6 @@

/**
* ArrayObject that acts as a stack with regards to iteration
*
* @category Zend
* @package Zend_Stdlib
*/
class ArrayStack extends ArrayObject
{
Expand Down
34 changes: 30 additions & 4 deletions src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;
Expand All @@ -16,9 +15,6 @@
* Utility class for testing and manipulation of PHP arrays.
*
* Declared abstract, as we have no need for instantiation.
*
* @category Zend
* @package Zend_Stdlib
*/
abstract class ArrayUtils
{
Expand Down Expand Up @@ -164,6 +160,36 @@ public static function isHashTable($value, $allowEmpty = false)
return (array_values($value) !== $value);
}

/**
* Checks if a value exists in an array.
*
* Due to "foo" == 0 === TRUE with in_array when strict = false, an option
* has been added to prevent this. When $strict = 0/false, the most secure
* non-strict check is implemented. if $strict = -1, the default in_array
* non-strict behaviour is used.
*
* @param mixed $needle
* @param array $haystack
* @param int|bool $strict
* @return bool
*/
public static function inArray($needle, array $haystack, $strict = false)
{
if (!$strict) {
if (is_int($needle) || is_float($needle)) {
$needle = (string) $needle;
}
if (is_string($needle)) {
foreach ($haystack as &$h) {
if (is_int($h) || is_float($h)) {
$h = (string) $h;
}
}
}
}
return in_array($needle, $haystack, $strict);
}

/**
* Convert an iterator to an array.
*
Expand Down
4 changes: 0 additions & 4 deletions src/CallbackHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;
Expand All @@ -20,9 +19,6 @@
* A handler for a event, event, filterchain, etc. Abstracts PHP callbacks,
* primarily to allow for lazy-loading and ensuring availability of default
* arguments (currying).
*
* @category Zend
* @package Zend_Stdlib
*/
class CallbackHandler
{
Expand Down
4 changes: 0 additions & 4 deletions src/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;
Expand All @@ -16,9 +15,6 @@
* DateTime
*
* An extension of the \DateTime object.
*
* @category Zend
* @package Zend_Stdlib
*/
class DateTime extends \DateTime
{
Expand Down
5 changes: 0 additions & 5 deletions src/DispatchableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;

use Zend\Stdlib\RequestInterface as Request;
use Zend\Stdlib\ResponseInterface as Response;

/**
* @category Zend
* @package Zend_Stdlib
*/
interface DispatchableInterface
{
/**
Expand Down
76 changes: 42 additions & 34 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib;
Expand All @@ -15,84 +14,92 @@
/**
* ErrorHandler that can be used to catch internal PHP errors
* and convert to a ErrorException instance.
*
* @category Zend
* @package Zend_Stdlib
*/
abstract class ErrorHandler
{
/**
* Flag to mark started
* Active stack
*
* @var bool
* @var array
*/
protected static $started = false;
protected static $stack = array();

/**
* All errors as one instance of ErrorException
* using the previous exception support.
* Check if this error handler is active
*
* @var null|ErrorException
* @return boolean
*/
protected static $errorException = null;
public static function started()
{
return (bool) static::getNestedLevel();
}

/**
* If the error handler has been started.
* Get the current nested level
*
* @return bool
* @return int
*/
public static function started()
public static function getNestedLevel()
{
return static::$started;
return count(static::$stack);
}

/**
* Starting the error handler
*
* @param int $errorLevel
* @throws Exception\LogicException If already started
*/
public static function start($errorLevel = \E_WARNING)
{
if (static::started() === true) {
throw new Exception\LogicException('ErrorHandler already started');
if (!static::$stack) {
set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
}

static::$started = true;
static::$errorException = null;

set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
static::$stack[] = null;
}

/**
* Stopping the error handler
*
* @param bool $throw Throw the ErrorException if any
* @return null|ErrorException
* @throws Exception\LogicException If not started before
* @throws ErrorException If an error has been catched and $throw is true
*/
public static function stop($throw = false)
{
if (static::started() === false) {
throw new Exception\LogicException('ErrorHandler not started');
}
$errorException = null;

$errorException = static::$errorException;
if (static::$stack) {
$errorException = array_pop(static::$stack);

static::$started = false;
static::$errorException = null;
restore_error_handler();
if (!static::$stack) {
restore_error_handler();
}

if ($errorException && $throw) {
throw $errorException;
if ($errorException && $throw) {
throw $errorException;
}
}

return $errorException;
}

/**
* Add an error to the stack.
* Stop all active handler
*
* @return void
*/
public static function clean()
{
if (static::$stack) {
restore_error_handler();
}

static::$stack = array();
}

/**
* Add an error to the stack
*
* @param int $errno
* @param string $errstr
Expand All @@ -102,6 +109,7 @@ public static function stop($throw = false)
*/
public static function addError($errno, $errstr = '', $errfile = '', $errline = 0)
{
static::$errorException = new ErrorException($errstr, 0, $errno, $errfile, $errline, static::$errorException);
$stack = & static::$stack[ count(static::$stack) - 1 ];
$stack = new ErrorException($errstr, 0, $errno, $errfile, $errline, $stack);
}
}
5 changes: 0 additions & 5 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib\Exception;

/**
* Bad method call exception
*
* @category Zend
* @package Zend_Stdlib
* @subpackage Exception
*/
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
Expand Down
5 changes: 0 additions & 5 deletions src/Exception/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Stdlib
*/

namespace Zend\Stdlib\Exception;

/**
* Domain exception
*
* @category Zend
* @package Zend_Stdlib
* @subpackage Exception
*/
class DomainException extends \DomainException implements ExceptionInterface
{
Expand Down
Loading

0 comments on commit eb61c8f

Please sign in to comment.