vendor/symfony/error-handler/Exception/FlattenException.php line 27

Open in your IDE?
  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\ErrorHandler\Exception;
  11. use Symfony\Component\Debug\Exception\FatalThrowableError;
  12. use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
  13. use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  16. /**
  17.  * FlattenException wraps a PHP Error or Exception to be able to serialize it.
  18.  *
  19.  * Basically, this class removes all objects from the trace.
  20.  *
  21.  * @author Fabien Potencier <fabien@symfony.com>
  22.  */
  23. class FlattenException extends LegacyFlattenException
  24. {
  25.     /** @var string */
  26.     private $message;
  27.     /** @var int|string */
  28.     private $code;
  29.     /** @var self|null */
  30.     private $previous;
  31.     /** @var array */
  32.     private $trace;
  33.     /** @var string */
  34.     private $traceAsString;
  35.     /** @var string */
  36.     private $class;
  37.     /** @var int */
  38.     private $statusCode;
  39.     /** @var string */
  40.     private $statusText;
  41.     /** @var array */
  42.     private $headers;
  43.     /** @var string */
  44.     private $file;
  45.     /** @var int */
  46.     private $line;
  47.     /** @var string|null */
  48.     private $asString;
  49.     /**
  50.      * @return static
  51.      */
  52.     public static function create(\Exception $exception$statusCode null, array $headers = []): self
  53.     {
  54.         return static::createFromThrowable($exception$statusCode$headers);
  55.     }
  56.     /**
  57.      * @return static
  58.      */
  59.     public static function createFromThrowable(\Throwable $exceptionint $statusCode null, array $headers = []): self
  60.     {
  61.         $e = new static();
  62.         $e->setMessage($exception->getMessage());
  63.         $e->setCode($exception->getCode());
  64.         if ($exception instanceof HttpExceptionInterface) {
  65.             $statusCode $exception->getStatusCode();
  66.             $headers array_merge($headers$exception->getHeaders());
  67.         } elseif ($exception instanceof RequestExceptionInterface) {
  68.             $statusCode 400;
  69.         }
  70.         if (null === $statusCode) {
  71.             $statusCode 500;
  72.         }
  73.         if (class_exists(Response::class) && isset(Response::$statusTexts[$statusCode])) {
  74.             $statusText Response::$statusTexts[$statusCode];
  75.         } else {
  76.             $statusText 'Whoops, looks like something went wrong.';
  77.         }
  78.         $e->setStatusText($statusText);
  79.         $e->setStatusCode($statusCode);
  80.         $e->setHeaders($headers);
  81.         $e->setTraceFromThrowable($exception);
  82.         $e->setClass($exception instanceof FatalThrowableError $exception->getOriginalClassName() : \get_class($exception));
  83.         $e->setFile($exception->getFile());
  84.         $e->setLine($exception->getLine());
  85.         $previous $exception->getPrevious();
  86.         if ($previous instanceof \Throwable) {
  87.             $e->setPrevious(static::createFromThrowable($previous));
  88.         }
  89.         return $e;
  90.     }
  91.     public function toArray(): array
  92.     {
  93.         $exceptions = [];
  94.         foreach (array_merge([$this], $this->getAllPrevious()) as $exception) {
  95.             $exceptions[] = [
  96.                 'message' => $exception->getMessage(),
  97.                 'class' => $exception->getClass(),
  98.                 'trace' => $exception->getTrace(),
  99.             ];
  100.         }
  101.         return $exceptions;
  102.     }
  103.     public function getStatusCode(): int
  104.     {
  105.         return $this->statusCode;
  106.     }
  107.     /**
  108.      * @param int $code
  109.      *
  110.      * @return $this
  111.      */
  112.     public function setStatusCode($code): self
  113.     {
  114.         $this->statusCode $code;
  115.         return $this;
  116.     }
  117.     public function getHeaders(): array
  118.     {
  119.         return $this->headers;
  120.     }
  121.     /**
  122.      * @return $this
  123.      */
  124.     public function setHeaders(array $headers): self
  125.     {
  126.         $this->headers $headers;
  127.         return $this;
  128.     }
  129.     public function getClass(): string
  130.     {
  131.         return $this->class;
  132.     }
  133.     /**
  134.      * @param string $class
  135.      *
  136.      * @return $this
  137.      */
  138.     public function setClass($class): self
  139.     {
  140.         $this->class false !== strpos($class"@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' $class;
  141.         return $this;
  142.     }
  143.     public function getFile(): string
  144.     {
  145.         return $this->file;
  146.     }
  147.     /**
  148.      * @param string $file
  149.      *
  150.      * @return $this
  151.      */
  152.     public function setFile($file): self
  153.     {
  154.         $this->file $file;
  155.         return $this;
  156.     }
  157.     public function getLine(): int
  158.     {
  159.         return $this->line;
  160.     }
  161.     /**
  162.      * @param int $line
  163.      *
  164.      * @return $this
  165.      */
  166.     public function setLine($line): self
  167.     {
  168.         $this->line $line;
  169.         return $this;
  170.     }
  171.     public function getStatusText(): string
  172.     {
  173.         return $this->statusText;
  174.     }
  175.     public function setStatusText(string $statusText): self
  176.     {
  177.         $this->statusText $statusText;
  178.         return $this;
  179.     }
  180.     public function getMessage(): string
  181.     {
  182.         return $this->message;
  183.     }
  184.     /**
  185.      * @param string $message
  186.      *
  187.      * @return $this
  188.      */
  189.     public function setMessage($message): self
  190.     {
  191.         if (false !== strpos($message"@anonymous\0")) {
  192.             $message preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
  193.                 return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' $m[0];
  194.             }, $message);
  195.         }
  196.         $this->message $message;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return int|string int most of the time (might be a string with PDOException)
  201.      */
  202.     public function getCode()
  203.     {
  204.         return $this->code;
  205.     }
  206.     /**
  207.      * @param int|string $code
  208.      *
  209.      * @return $this
  210.      */
  211.     public function setCode($code): self
  212.     {
  213.         $this->code $code;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return self|null
  218.      */
  219.     public function getPrevious()
  220.     {
  221.         return $this->previous;
  222.     }
  223.     /**
  224.      * @return $this
  225.      */
  226.     final public function setPrevious(?LegacyFlattenException $previous): self
  227.     {
  228.         $this->previous $previous;
  229.         return $this;
  230.     }
  231.     /**
  232.      * @return self[]
  233.      */
  234.     public function getAllPrevious(): array
  235.     {
  236.         $exceptions = [];
  237.         $e $this;
  238.         while ($e $e->getPrevious()) {
  239.             $exceptions[] = $e;
  240.         }
  241.         return $exceptions;
  242.     }
  243.     public function getTrace(): array
  244.     {
  245.         return $this->trace;
  246.     }
  247.     /**
  248.      * @deprecated since 4.1, use {@see setTraceFromThrowable()} instead.
  249.      */
  250.     public function setTraceFromException(\Exception $exception)
  251.     {
  252.         @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use "setTraceFromThrowable()" instead.'__METHOD__), \E_USER_DEPRECATED);
  253.         $this->setTraceFromThrowable($exception);
  254.     }
  255.     /**
  256.      * @return $this
  257.      */
  258.     public function setTraceFromThrowable(\Throwable $throwable): self
  259.     {
  260.         $this->traceAsString $throwable->getTraceAsString();
  261.         return $this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine());
  262.     }
  263.     /**
  264.      * @param array       $trace
  265.      * @param string|null $file
  266.      * @param int|null    $line
  267.      *
  268.      * @return $this
  269.      */
  270.     public function setTrace($trace$file$line): self
  271.     {
  272.         $this->trace = [];
  273.         $this->trace[] = [
  274.             'namespace' => '',
  275.             'short_class' => '',
  276.             'class' => '',
  277.             'type' => '',
  278.             'function' => '',
  279.             'file' => $file,
  280.             'line' => $line,
  281.             'args' => [],
  282.         ];
  283.         foreach ($trace as $entry) {
  284.             $class '';
  285.             $namespace '';
  286.             if (isset($entry['class'])) {
  287.                 $parts explode('\\'$entry['class']);
  288.                 $class array_pop($parts);
  289.                 $namespace implode('\\'$parts);
  290.             }
  291.             $this->trace[] = [
  292.                 'namespace' => $namespace,
  293.                 'short_class' => $class,
  294.                 'class' => $entry['class'] ?? '',
  295.                 'type' => $entry['type'] ?? '',
  296.                 'function' => $entry['function'] ?? null,
  297.                 'file' => $entry['file'] ?? null,
  298.                 'line' => $entry['line'] ?? null,
  299.                 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : [],
  300.             ];
  301.         }
  302.         return $this;
  303.     }
  304.     private function flattenArgs(array $argsint $level 0int &$count 0): array
  305.     {
  306.         $result = [];
  307.         foreach ($args as $key => $value) {
  308.             if (++$count 1e4) {
  309.                 return ['array''*SKIPPED over 10000 entries*'];
  310.             }
  311.             if ($value instanceof \__PHP_Incomplete_Class) {
  312.                 // is_object() returns false on PHP<=7.1
  313.                 $result[$key] = ['incomplete-object'$this->getClassNameFromIncomplete($value)];
  314.             } elseif (\is_object($value)) {
  315.                 $result[$key] = ['object', \get_class($value)];
  316.             } elseif (\is_array($value)) {
  317.                 if ($level 10) {
  318.                     $result[$key] = ['array''*DEEP NESTED ARRAY*'];
  319.                 } else {
  320.                     $result[$key] = ['array'$this->flattenArgs($value$level 1$count)];
  321.                 }
  322.             } elseif (null === $value) {
  323.                 $result[$key] = ['null'null];
  324.             } elseif (\is_bool($value)) {
  325.                 $result[$key] = ['boolean'$value];
  326.             } elseif (\is_int($value)) {
  327.                 $result[$key] = ['integer'$value];
  328.             } elseif (\is_float($value)) {
  329.                 $result[$key] = ['float'$value];
  330.             } elseif (\is_resource($value)) {
  331.                 $result[$key] = ['resource'get_resource_type($value)];
  332.             } else {
  333.                 $result[$key] = ['string', (string) $value];
  334.             }
  335.         }
  336.         return $result;
  337.     }
  338.     private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value): string
  339.     {
  340.         $array = new \ArrayObject($value);
  341.         return $array['__PHP_Incomplete_Class_Name'];
  342.     }
  343.     public function getTraceAsString(): string
  344.     {
  345.         return $this->traceAsString;
  346.     }
  347.     /**
  348.      * @return $this
  349.      */
  350.     public function setAsString(?string $asString): self
  351.     {
  352.         $this->asString $asString;
  353.         return $this;
  354.     }
  355.     public function getAsString(): string
  356.     {
  357.         if (null !== $this->asString) {
  358.             return $this->asString;
  359.         }
  360.         $message '';
  361.         $next false;
  362.         foreach (array_reverse(array_merge([$this], $this->getAllPrevious())) as $exception) {
  363.             if ($next) {
  364.                 $message .= 'Next ';
  365.             } else {
  366.                 $next true;
  367.             }
  368.             $message .= $exception->getClass();
  369.             if ('' != $exception->getMessage()) {
  370.                 $message .= ': '.$exception->getMessage();
  371.             }
  372.             $message .= ' in '.$exception->getFile().':'.$exception->getLine().
  373.                 "\nStack trace:\n".$exception->getTraceAsString()."\n\n";
  374.         }
  375.         return rtrim($message);
  376.     }
  377. }
dobrowin | betleao | moverbet | winzada 777 | supremo | casadeapostas | dobrowin | betleao | moverbet | wazamba | fezbet | betsson | lvbet | dobrowin | betsul | pixbet | bwin | betobet | dobrowin | bet7 | betcris | blaze | 888 | betano | stake | stake | esportesdasorte | betmotion | rivalry | novibet | pinnacle | cbet | dobrowin | betleao | moverbet | gogowin | jogos win | campobet | mesk bet | infinity bet | betfury | doce | bet7k | jogowin | lobo888 | iribet | leao | dobrowin | allwin | aajogo | pgwin | greenbets | brapub | moverbet | onebra | flames | brdice | brwin | poplottery | queens | winbrl | omgbet | winbra | goinbet | codbet | betleao | fuwin | allwin568 | wingdus | juntosbet | today | talon777 | brlwin | fazobetai | pinup bet | bet sport | bet esporte | mrbet | premier bet | apostebet | spicy bet | prosport bet | bet nacional | luck | jogodeouro | heads bet | marjack bet | apostaganha | gbg bet | esoccer bet | esport bet | realbet | aposte e ganhe | aviator aposta | bet vitoria | imperador bet | realsbet | bet favorita | esportenet | flames bet | pague bet | betsury | doce888 | obabet | winzada | globalbet | bet77 | lottoland | 7gamesbet | dicasbet | esportivabet | tvbet | sportbet | misterjackbet | esportebet | nacionalbet | simplesbet | betestrela | batbet | Pk55 | Bet61 | Upsports Bet | roleta online | roleta | poker online | poker | blackjack online | bingo | 12bet | 33win | bet168 | bk8 | bong88 | bong99 | fcb8 | hb88 | hotlive | ibet888 | k8 | kubet77 | kubet | lode88 | mig8 | nbet | onebox63 | oxbet | s666 | sbobet | suncity | vwin | w88 | win2888 | zbet | xoso66 | zowin | sun | top88 | vnloto | 11bet | bet69 | 8xbet | Ceará | Paysandu | Juventude | Bahia | Sport | Cuiabá | Coritiba | Criciúma | Vitória | Fortaleza | Corinthians | São Paulo | Vasco | Grêmio | Fluminense | Cruzeiro | Botafogo | Flamengo | bingo slots | slots slots | hacker do slot | pg slot demo | slot win | pg slot soft | arne slot | riqueza slots | slots 777 | pg slot | 777 slot game | slot pg soft | hacker slot | 777 slots | slot-pg-soft | fortune ox demo grátis | demo fortune ox | fortune mouse demo | fortune ox demo | jogo fortune tiger | fortune tiger grátis | fortune tiger baixar | fortune tiger demo grátis | fortune tiger demo | fortune tiger 777 | 580bet | bet 7k | leao | luck 2 | john bet | 7755 bet | cbet | bet7 | pk55 | 8800 bet | doce | bet 4 | f12bet | bet7 | ggbet | bet77 | mrbet | bet61 | tvbet | pgwin | today | fuwin | brwin | bet7k | tv bet | allwin | stake | bwin 789 | lvbet | blaze | dj bet | umbet | b1bet | 20bet | bk bet | h2bet | 7kbet | fbbet | 9d bet | 9k bet | 73 bet | ktobet | 74 bet | betpix | betvip | batbet | onabet | f12bet | codbet | winbra | b2xbet | obabet | brlwin | onebra | winbrl | omgbet | queens | brdice | brapub | flames | betano | aajogo | iribet | pixbet | betsul | fezbet | curso beta | betway | bkbet | peixe beta | bet365 | pixbet | 4 play bet | 365bet | brxbet | 939 bet | seubet | cnc bet | gbg bet | 522bet | brl bet | pagbet | jonbet | jqk bet | 166bet | abc bet | bggbet | obabet | 136bet | mmabet | win bet | ir6 bet | 667bet | qqq bet | 193 bet | 3ss bet | 317 bet | kkk bet | 585 bet | 569 bet | vai bet | aaa bet | 969 bet | z11 bet | kw bet | 26 bet | mj bet | betio | 01 bet | ut bet | 9y bet | bet70 | f9 bet | hw bet | kg bet | 5e bet | bet br | hr bet | br bet | 75 bet | 03 bet | 6z bet | 6r bet | v6 bet | 78 bet | bt bet | 80 bet | 8g bet | 72 bet | xp bet | f12 bet | p9 bet | 5 bet | 4 bet | bet 4 | r7 bet | um bet | 29 bet | 5s bet | ck bet | pg bet | ea bet | 23 bet | bl bet | 3l bet | 2a bet | p7 bet | 888 bet | 707 bet | 361 bet | bet29 | 700 bet | 161 bet | bet777 | up bet | 58 bet | nn bet | 67 bet | 22 bet | 9g bet | 1x bet | bet10 | 70 bet | 2h bet | 9r bet | 16 bet | 81 bet | 7 bet | 5u bet | 6k bet | mg bet | b1 bet | 5h bet | je- bet | joya | hopa | nomini | ls bet | 1xbit | platin | ice bet | rant | bet us | bet go | 31 bet | slingo | flush | ice36 | weiss | bet9 | rabona | i bet | starda | dreams | bongo | snatch | 10 bet | daddy | metal | zep bet | drip | gama | drake | verde | shazam | wish | thor | exclusive | sol | highway | 500 casino | jazz | howl | supernova | sherbet | fresh | daddy | jet | wish | eclipse | inplay | drip | marvel | stake | scorpion | luxebet | drake | thor | puma | winzir | loki | shazam | rivalry | f1 casino | xgbet | sushi | bk8 | art casino | manga | pgasia | gemini | bingoplus | slot vip | help slot win | 8k8 slot | tadhana slot | jili slot | 55bmw slot | vip slot | nn777 slot | jili slot 777 | tg777 slot | w500 slot | phfun slot | bmw55 slot | sg777 slot | wj slot | slot free 100 | lucky cola slot | cc6 slot | taya777 slot | ph444 slot | slot games | fb777 slot | okebet slot | help slot | tg77 slot | phwin slot | vvjl slot | fc777 slot | slot vin | yy777 slot | define slot | define slot | inplay | 99bet | 60win | melbet | jollibet | jili slot | rich711 | tayabet | phl63 | unobet | 63jili | mwplay888 | gold99 | jolibet | ubet95 | nice88 | jili777 | nn777 | phlove | jiliko | 55bmw | phoenix game | 8k8 | cgebet | 7up gaming | diamond game | hellowin | win88 | big win | kabibe game | sabong bet | phcity | colorplay | tongits go | slotsgo | spinph | go perya | casino frenzy | aurora game | escala gaming | winning plus | bingo plus | ph dream | 747 live | niceph | lucky cola | pera play