Drupal investigation

FatalErrorException.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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\HttpKernel\Exception;
  11. /**
  12. * Fatal Error Exception.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. * @author Konstanton Myakshin <koc-dp@yandex.ru>
  16. * @author Nicolas Grekas <p@tchwork.com>
  17. *
  18. * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
  19. */
  20. class FatalErrorException extends \ErrorException
  21. {
  22. }
  23. namespace Symfony\Component\Debug\Exception;
  24. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  25. /**
  26. * Fatal Error Exception.
  27. *
  28. * @author Konstanton Myakshin <koc-dp@yandex.ru>
  29. */
  30. class FatalErrorException extends LegacyFatalErrorException
  31. {
  32. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null)
  33. {
  34. parent::__construct($message, $code, $severity, $filename, $lineno);
  35. if (null !== $trace) {
  36. if (!$traceArgs) {
  37. foreach ($trace as &$frame) {
  38. unset($frame['args'], $frame['this'], $frame);
  39. }
  40. }
  41. $this->setTrace($trace);
  42. } elseif (null !== $traceOffset) {
  43. if (function_exists('xdebug_get_function_stack')) {
  44. $trace = xdebug_get_function_stack();
  45. if (0 < $traceOffset) {
  46. array_splice($trace, -$traceOffset);
  47. }
  48. foreach ($trace as &$frame) {
  49. if (!isset($frame['type'])) {
  50. // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
  51. if (isset($frame['class'])) {
  52. $frame['type'] = '::';
  53. }
  54. } elseif ('dynamic' === $frame['type']) {
  55. $frame['type'] = '->';
  56. } elseif ('static' === $frame['type']) {
  57. $frame['type'] = '::';
  58. }
  59. // XDebug also has a different name for the parameters array
  60. if (!$traceArgs) {
  61. unset($frame['params'], $frame['args']);
  62. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  63. $frame['args'] = $frame['params'];
  64. unset($frame['params']);
  65. }
  66. }
  67. unset($frame);
  68. $trace = array_reverse($trace);
  69. } elseif (function_exists('symfony_debug_backtrace')) {
  70. $trace = symfony_debug_backtrace();
  71. if (0 < $traceOffset) {
  72. array_splice($trace, 0, $traceOffset);
  73. }
  74. } else {
  75. $trace = array();
  76. }
  77. $this->setTrace($trace);
  78. }
  79. }
  80. protected function setTrace($trace)
  81. {
  82. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  83. $traceReflector->setAccessible(true);
  84. $traceReflector->setValue($this, $trace);
  85. }
  86. }