diff --git a/.travis.yml b/.travis.yml index f89f34ade..739739279 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ before_install: - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi - composer self-update - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi + - if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.5" ]]; then composer require --dev --no-update phpunit/phpunit ~4; fi install: - travis_retry composer install --no-interaction --ignore-platform-reqs diff --git a/composer.json b/composer.json index 6a72b43bd..adc582241 100644 --- a/composer.json +++ b/composer.json @@ -14,15 +14,15 @@ }, "require": { "php": ">=5.5", - "ext-ldap": "*", - "zendframework/zend-stdlib": "~2.5" + "ext-ldap": "*" }, "require-dev": { "zendframework/zend-config": "~2.5", "zendframework/zend-eventmanager": "~2.5", "fabpot/php-cs-fixer": "1.7.*", "phpunit/PHPUnit": "~4.0", - "php-mock/php-mock-phpunit": "~0.3" + "php-mock/php-mock-phpunit": "~0.3", + "zendframework/zend-stdlib": "~2.5" }, "suggest": { "zendframework/zend-eventmanager": "Zend\\EventManager component" diff --git a/src/Collection/DefaultIterator.php b/src/Collection/DefaultIterator.php index f53af04ce..ca2aecb1f 100644 --- a/src/Collection/DefaultIterator.php +++ b/src/Collection/DefaultIterator.php @@ -13,7 +13,7 @@ use Iterator; use Zend\Ldap; use Zend\Ldap\Exception; -use Zend\Stdlib\ErrorHandler; +use Zend\Ldap\ErrorHandler; /** * Zend\Ldap\Collection\DefaultIterator is the default collection iterator implementation diff --git a/src/Converter/Converter.php b/src/Converter/Converter.php index f48052c8c..166df5e1a 100644 --- a/src/Converter/Converter.php +++ b/src/Converter/Converter.php @@ -11,7 +11,7 @@ use DateTime; use DateTimeZone; -use Zend\Stdlib\ErrorHandler; +use Zend\Ldap\ErrorHandler; /** * Zend\Ldap\Converter is a collection of useful LDAP related conversion functions. diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php new file mode 100644 index 000000000..60fe4e7c7 --- /dev/null +++ b/src/ErrorHandler.php @@ -0,0 +1,100 @@ +startErrorHandling($level); + } + + /** + * @param bool|false $throw + * + * @return mixed + */ + public static function stop($throw = false) + { + return self::getErrorHandler()->stopErrorHandling($throw); + } + + /** + * Get an error handler + * + * @return ErrorHandlerInterface + */ + protected static function getErrorHandler() + { + if (! self::$errorHandler && ! self::$errorHandler instanceof ErrorHandlerInterface) { + self::$errorHandler = new self(); + } + + return self::$errorHandler; + } + + /** + * This method does nothing on purpose. + * + * @param int $level + * + * @see ErrorHandlerInterface::startErrorHandling() + * @return void + */ + public function startErrorHandling($level = E_WARNING) + { + // Do nothing! + } + + /** + * This method does nothing on purpose. + * + * @param bool|false $throw + * + * @see ErrorHandlerInterface::stopErrorHandling() + * @return void + */ + public function stopErrorHandling($throw = false) + { + // Do nothing; + } + + /** + * Set the error handler to be used + * + * @param ErrorHandlerInterface $errorHandler + * + * @return void + */ + public static function setErrorHandler(ErrorHandlerInterface $errorHandler) + { + self::$errorHandler = $errorHandler; + } +} diff --git a/src/ErrorHandlerInterface.php b/src/ErrorHandlerInterface.php new file mode 100644 index 000000000..04266ee08 --- /dev/null +++ b/src/ErrorHandlerInterface.php @@ -0,0 +1,39 @@ +$throw handles whether the captured errors shall + * be thrown as Exceptions or not + * + * @param bool|false $throw + * + * @return mixed + */ + public function stopErrorHandling($throw = false); +} diff --git a/src/Ldap.php b/src/Ldap.php index ee8f01024..7a32fb810 100644 --- a/src/Ldap.php +++ b/src/Ldap.php @@ -11,7 +11,6 @@ use Traversable; use Zend\Ldap\Exception\LdapException; -use Zend\Stdlib\ErrorHandler; class Ldap { diff --git a/test/ErrorHandler.php b/test/ErrorHandler.php new file mode 100644 index 000000000..b3aec9418 --- /dev/null +++ b/test/ErrorHandler.php @@ -0,0 +1,42 @@ +$throw handles whether the captured errors shall + * be thrown as Exceptions or not + * + * @param bool|false $throw + * + * @return mixed + */ + public function stopErrorHandling($throw = false) + { + return DefaultErrorHandler::stop($throw); + } +} diff --git a/test/bootstrap.php b/test/bootstrap.php index 565d7bb7c..e67898958 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -21,11 +21,17 @@ unset($phpUnitVersion); } + /** * Setup autoloading */ require __DIR__ . '/../vendor/autoload.php'; +/** + * Setting the Zend\StdLib/ErrorHandler as default ErrorHandler + */ +Zend\Ldap\ErrorHandler::setErrorHandler(new ZendTest\Ldap\ErrorHandler()); + /** * Start output buffering, if enabled */