This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
Removes default dependency to Zend\StdLib #21
Merged
heiglandreas
merged 3 commits into
zendframework:master
from
heiglandreas:feature/removeExternalDependencies
Apr 21, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Ldap; | ||
|
||
/** | ||
* Handle Errors that might occur during execution of ldap_*-functions | ||
* | ||
* @package Zend\Ldap\ErrorHandler | ||
*/ | ||
class ErrorHandler implements ErrorHandlerInterface | ||
{ | ||
/** | ||
* @var ErrorHandlerInterface The Errror-Handler instance | ||
*/ | ||
protected static $errorHandler; | ||
|
||
/** | ||
* Start the Error-Handling | ||
* | ||
* You can specify which errors to handle by passing a combination of PHPs | ||
* Error-constants like E_WARNING or E_NOTICE or E_WARNING ^ E_DEPRECATED | ||
* | ||
* @param int $level The Error-level(s) to handle by this ErrorHandler | ||
* | ||
* @return void | ||
*/ | ||
public static function start($level = E_WARNING) | ||
{ | ||
self::getErrorHandler()->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Ldap; | ||
|
||
/** | ||
* Handle Errors that might occur during execution of ldap_*-functions | ||
* | ||
* @package Zend\Ldap\ErrorHandler | ||
*/ | ||
interface ErrorHandlerInterface | ||
{ | ||
/** | ||
* Start the ErrorHandling-process | ||
* | ||
* @param int $level | ||
* | ||
* @return void | ||
*/ | ||
public function startErrorHandling($level = E_WARNING); | ||
|
||
/** | ||
* Stop the error-handling process. | ||
* | ||
* The parameter <var>$throw</var> handles whether the captured errors shall | ||
* be thrown as Exceptions or not | ||
* | ||
* @param bool|false $throw | ||
* | ||
* @return mixed | ||
*/ | ||
public function stopErrorHandling($throw = false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
|
||
use Traversable; | ||
use Zend\Ldap\Exception\LdapException; | ||
use Zend\Stdlib\ErrorHandler; | ||
|
||
class Ldap | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Ldap; | ||
|
||
use Zend\Ldap\ErrorHandlerInterface; | ||
use Zend\Stdlib\ErrorHandler as DefaultErrorHandler; | ||
|
||
class ErrorHandler implements ErrorHandlerInterface | ||
{ | ||
/** | ||
* Start the ErrorHandling-process | ||
* | ||
* @param int $level | ||
* | ||
* @return void | ||
*/ | ||
public function startErrorHandling($level = E_WARNING) | ||
{ | ||
DefaultErrorHandler::start($level); | ||
} | ||
|
||
/** | ||
* Stop the error-handling process. | ||
* The parameter <var>$throw</var> 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the default ErrorHandler does nothing at all but the tests seem to depend on error-suppression I've added that one to get the tests running under the same conditions as before. I was thinking of adding that line to src/Ldap.php (at the very end) so that that's set as default error handler and users can overwrite that with their own implementation. On the other hand that would mean that the dependency to
Zend\StdLib\ErrorHandler
would not be eliminated.