Просмотр файла vendor/symfony/error-handler/ThrowableUtils.php

Размер файла: 865B
  1. <?php
  2.  
  3. /*
  4. * This file is part of the Symfony package.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11.  
  12. namespace Symfony\Component\ErrorHandler;
  13.  
  14. use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
  15.  
  16. /**
  17. * @internal
  18. */
  19. class ThrowableUtils
  20. {
  21. public static function getSeverity(SilencedErrorContext|\Throwable $throwable): int
  22. {
  23. if ($throwable instanceof \ErrorException || $throwable instanceof SilencedErrorContext) {
  24. return $throwable->getSeverity();
  25. }
  26.  
  27. if ($throwable instanceof \ParseError) {
  28. return \E_PARSE;
  29. }
  30.  
  31. if ($throwable instanceof \TypeError) {
  32. return \E_RECOVERABLE_ERROR;
  33. }
  34.  
  35. return \E_ERROR;
  36. }
  37. }