New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes default dependency to Zend\StdLib #21

Merged
merged 3 commits into from Apr 21, 2016

Conversation

Projects
None yet
5 participants
@heiglandreas
Member

heiglandreas commented Nov 12, 2015

This commit removes the default dependency to the \Zend\StdLib\ErrorHandler by replacing it with a
\Zend\Ldap\ErrorHandler that delegates the error handling to an injectable ErrorHandler.

That way the tests can use \Zend\StdLib\ErrorHandler and silence errors during the tests whereas in a live environment no error-suppression is used by default.

Other ErrorHandlers can be used by creating a class that implements \Zend\Ldap\ErrorHandlerInterface and injecting an instance of that class as ErrorHandler using \Zend\Ldap\ErrorHandler::setErrorHandler()

The main aim would be to get rid of external dependencies to make the component as independent as possible and allow a more widespread usage.

This has been influenced by zendframework/zendframework#7497 and symfony/symfony-docs#5756

/**
* Setup autoloading
*/
require __DIR__ . '/../vendor/autoload.php';
/**
* Setting the Zend\StdLib/ErrorHandler as default ErrorHandler
*/
Zend\Ldap\ErrorHandler::setErrorHandler(new ZendTest\Ldap\ErrorHandler());

This comment has been minimized.

@Maks3w

Maks3w Nov 12, 2015

Member

Is this needed?

@Maks3w

Maks3w Nov 12, 2015

Member

Is this needed?

This comment has been minimized.

@heiglandreas

heiglandreas Nov 12, 2015

Member

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.

@heiglandreas

heiglandreas Nov 12, 2015

Member

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.

@Maks3w Maks3w added the enhancement label Nov 12, 2015

@felipsmartins

This comment has been minimized.

Show comment
Hide comment
@felipsmartins

felipsmartins commented Nov 12, 2015

Looks nice!

Show outdated Hide outdated composer.json

@heiglandreas heiglandreas changed the title from [WIP] Removes default dependency to Zend\StdLib to Removes default dependency to Zend\StdLib Jan 14, 2016

@gianarb

This comment has been minimized.

Show comment
Hide comment
@gianarb

gianarb commented Jan 14, 2016

👍

heiglandreas added some commits Nov 12, 2015

Removes default dependency to Zend\StdLib
This commit removes the default dependency to the
```\Zend\StdLib\ErrorHandler``` by replacing it with a
```\Zend\Ldap\ErrorHandler```
that delegates the error handling to an injectable ErrorHandler.

That way the tests can use ```\Zend\StdLib\ErrorHandler``` and silence errors
during the tests whereas in a live environment no error-suppression is
used by default.

Other ErrorHandlers can be used by creating a class that implements
```\Zend\Ldap\ErrorHandlerInterface``` and injecting an instance of that class
as ErrorHandler using ```\Zend\Ldap\ErrorHandler::setErrorHandler()```
Fixes CS-Fixes issues
This commit adds some space and newlines

@heiglandreas heiglandreas added this to the 2.7.0 milestone Apr 21, 2016

@heiglandreas heiglandreas self-assigned this Apr 21, 2016

@heiglandreas heiglandreas merged commit 81bf78b into zendframework:master Apr 21, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment