DeprecationErrorHandler.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\Test;
  11. use Symfony\Component\Form\FormEvent;
  12. /**
  13. * @deprecated since version 2.3, to be removed in 3.0.
  14. */
  15. class DeprecationErrorHandler
  16. {
  17. public static function handle($errorNumber, $message, $file, $line, $context)
  18. {
  19. if ($errorNumber & ~E_USER_DEPRECATED) {
  20. return true;
  21. }
  22. if (class_exists('PHPUnit_Util_ErrorHandler')) {
  23. return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
  24. }
  25. return \PHPUnit\Util\ErrorHandler::handleError($errorNumber, $message, $file, $line);
  26. }
  27. public static function handleBC($errorNumber, $message, $file, $line, $context)
  28. {
  29. if ($errorNumber & ~E_USER_DEPRECATED) {
  30. return true;
  31. }
  32. return false;
  33. }
  34. public static function preBind($listener, FormEvent $event)
  35. {
  36. set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
  37. $listener->preBind($event);
  38. restore_error_handler();
  39. }
  40. }