Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Call / Exception / FatalThrowableError.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.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
11 namespace Behat\Testwork\Call\Exception;
12
13 use ErrorException;
14 use ParseError;
15 use Throwable;
16 use TypeError;
17
18 /**
19  * Fatal Throwable Error.
20  *
21  * @author Nicolas Grekas <p@tchwork.com>
22  */
23 class FatalThrowableError extends ErrorException
24 {
25     public function __construct(Throwable $e)
26     {
27         if ($e instanceof ParseError) {
28             $message = 'Parse error: '.$e->getMessage();
29             $severity = E_PARSE;
30         } elseif ($e instanceof TypeError) {
31             $message = 'Type error: '.$e->getMessage();
32             $severity = E_RECOVERABLE_ERROR;
33         } else {
34             $message = 'Fatal error: '.$e->getMessage();
35             $severity = E_ERROR;
36         }
37
38         parent::__construct(
39             $message,
40             $e->getCode(),
41             $severity,
42             $e->getFile(),
43             $e->getLine()
44         );
45
46         $this->setTrace($e->getTrace());
47     }
48
49     private function setTrace($trace)
50     {
51         $traceReflector = new \ReflectionProperty('Exception', 'trace');
52         $traceReflector->setAccessible(true);
53         $traceReflector->setValue($this, $trace);
54     }
55 }