Passed
Push — 0.8.x ( 2c19c4...12ae30 )
by Alexander
10:05 queued 05:36
created
src/components/Debug/Exceptions/FrameHandler/Supervisor.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -31,156 +31,156 @@
 block discarded – undo
31 31
  */
32 32
 class Supervisor
33 33
 {
34
-	/**
35
-	 * Get exception. 
36
-	 * 
37
-	 * @var \Throwable $exception
38
-	 */
39
-	protected $exception;
40
-
41
-	/**
42
-	 * The frame execute errors.
43
-	 * 
44
-	 * @var string $frames
45
-	 */
46
-	protected $frames;
47
-
48
-	/**
49
-	 * Constructor. The Supervisor class instance.
50
-	 * 
51
-	 * @param  \Throwable  $exception
52
-	 * 
53
-	 * @return string
54
-	 */
55
-	public function __construct($exception)
56
-	{
57
-		$this->exception = $exception;
58
-	}
34
+    /**
35
+     * Get exception. 
36
+     * 
37
+     * @var \Throwable $exception
38
+     */
39
+    protected $exception;
40
+
41
+    /**
42
+     * The frame execute errors.
43
+     * 
44
+     * @var string $frames
45
+     */
46
+    protected $frames;
47
+
48
+    /**
49
+     * Constructor. The Supervisor class instance.
50
+     * 
51
+     * @param  \Throwable  $exception
52
+     * 
53
+     * @return string
54
+     */
55
+    public function __construct($exception)
56
+    {
57
+        $this->exception = $exception;
58
+    }
59 59
 	
60
-	/**
61
-	 * Returns an iterator for the inspected exception's frames.
62
-	 * 
63
-	 * @param  \Throwable  $exception
64
-	 * 
65
-	 * @return array 
66
-	 */
67
-	public function getFrames()
68
-	{
69
-		if ($this->frames === null) {
70
-			$frames = $this->getTrace($this->exception);	
71
-
72
-			// Fill empty line/file info for call_user_func_array usages 
73
-			foreach ($frames as $k => $frame) {
74
-				if (empty($frame['file'])) {
75
-					// Default values when file and line are missing
76
-					$file = '[PHP internal Code]';
77
-					$line = 0;
78
-					$next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : [];
79
-					$frames[$k]['file'] = $file;
80
-					$frames[$k]['line'] = $line;
81
-				}
82
-			}
60
+    /**
61
+     * Returns an iterator for the inspected exception's frames.
62
+     * 
63
+     * @param  \Throwable  $exception
64
+     * 
65
+     * @return array 
66
+     */
67
+    public function getFrames()
68
+    {
69
+        if ($this->frames === null) {
70
+            $frames = $this->getTrace($this->exception);	
71
+
72
+            // Fill empty line/file info for call_user_func_array usages 
73
+            foreach ($frames as $k => $frame) {
74
+                if (empty($frame['file'])) {
75
+                    // Default values when file and line are missing
76
+                    $file = '[PHP internal Code]';
77
+                    $line = 0;
78
+                    $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : [];
79
+                    $frames[$k]['file'] = $file;
80
+                    $frames[$k]['line'] = $line;
81
+                }
82
+            }
83 83
 			
84
-			// Find latest non-error handling frame index ($i) used to remove error handling frames
85
-			$i = 0;
86
-
87
-			foreach ($frames as $k => $frame) {
88
-				if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) {
89
-					$i = $k;
90
-				}
91
-			}
92
-			// Remove error handling frames
93
-			if ($i > 0) {
94
-				array_splice($frames, 0, $i);
95
-			}
84
+            // Find latest non-error handling frame index ($i) used to remove error handling frames
85
+            $i = 0;
86
+
87
+            foreach ($frames as $k => $frame) {
88
+                if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) {
89
+                    $i = $k;
90
+                }
91
+            }
92
+            // Remove error handling frames
93
+            if ($i > 0) {
94
+                array_splice($frames, 0, $i);
95
+            }
96 96
 	
97
-			$firstFrame = $this->getFrameFromException($this->exception);	
98
-			array_unshift($frames, $firstFrame);
99
-
100
-			$this->frames = new Collection($frames);
101
-		}
102
-
103
-		return $this->frames;
104
-	}
105
-
106
-	/**
107
-	 * Given an exception, generates an array in the format generated by Exception::getTrace().
108
-	 * 
109
-	 * @param  \Throwable  $exception
110
-	 * 
111
-	 * @return array
112
-	 */
113
-	protected function getFrameFromException(Throwable $exception): array
114
-	{
115
-		return [
116
-			'file'  => $exception->getFile(),
117
-			'line'  => $exception->getLine(),
118
-			'class' => getClass($exception),
119
-			'code'  => $exception->getCode(),
120
-			'args'  => [
121
-				$exception->getMessage(),
122
-			],
123
-		];
124
-	}
125
-
126
-	/**
127
-	 * Gets exception already specified.
128
-	 * 
129
-	 * @return \Throwable
130
-	 */
131
-	public function getException()
132
-	{
133
-		return $this->exception;
134
-	}
135
-
136
-	/**
137
-	 * Gets the message of exception.
138
-	 * 
139
-	 * @return string
140
-	 */
141
-	public function getExceptionMessage(): string
142
-	{
143
-		return $this->exception->getMessage();
144
-	}
145
-
146
-	/**
147
-	 * Gets the class name of exception.
148
-	 * 
149
-	 * @return mixed
150
-	 */
151
-	public function getExceptionName()
152
-	{
153
-		return getClass($this->exception);
154
-	}
97
+            $firstFrame = $this->getFrameFromException($this->exception);	
98
+            array_unshift($frames, $firstFrame);
99
+
100
+            $this->frames = new Collection($frames);
101
+        }
102
+
103
+        return $this->frames;
104
+    }
105
+
106
+    /**
107
+     * Given an exception, generates an array in the format generated by Exception::getTrace().
108
+     * 
109
+     * @param  \Throwable  $exception
110
+     * 
111
+     * @return array
112
+     */
113
+    protected function getFrameFromException(Throwable $exception): array
114
+    {
115
+        return [
116
+            'file'  => $exception->getFile(),
117
+            'line'  => $exception->getLine(),
118
+            'class' => getClass($exception),
119
+            'code'  => $exception->getCode(),
120
+            'args'  => [
121
+                $exception->getMessage(),
122
+            ],
123
+        ];
124
+    }
125
+
126
+    /**
127
+     * Gets exception already specified.
128
+     * 
129
+     * @return \Throwable
130
+     */
131
+    public function getException()
132
+    {
133
+        return $this->exception;
134
+    }
135
+
136
+    /**
137
+     * Gets the message of exception.
138
+     * 
139
+     * @return string
140
+     */
141
+    public function getExceptionMessage(): string
142
+    {
143
+        return $this->exception->getMessage();
144
+    }
145
+
146
+    /**
147
+     * Gets the class name of exception.
148
+     * 
149
+     * @return mixed
150
+     */
151
+    public function getExceptionName()
152
+    {
153
+        return getClass($this->exception);
154
+    }
155 155
 	
156
-	/**
157
-	 * Gets the backtrace from an exception.
158
-	 * 
159
-	 * @param  \Throwable  $exception
160
-	 * 
161
-	 * @return array
162
-	 */
163
-	protected function getTrace($exception): array
164
-	{
165
-		$traces = $exception->getTrace();
166
-
167
-		if ( ! $exception instanceof ErrorException) {
168
-			return $traces;
169
-		}
170
-
171
-		if ( ! Misc::isFatalError($exception->getSeverity())) {
172
-			return $traces;
173
-		}
174
-
175
-		if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) {
176
-			return $traces;
177
-		}
156
+    /**
157
+     * Gets the backtrace from an exception.
158
+     * 
159
+     * @param  \Throwable  $exception
160
+     * 
161
+     * @return array
162
+     */
163
+    protected function getTrace($exception): array
164
+    {
165
+        $traces = $exception->getTrace();
166
+
167
+        if ( ! $exception instanceof ErrorException) {
168
+            return $traces;
169
+        }
170
+
171
+        if ( ! Misc::isFatalError($exception->getSeverity())) {
172
+            return $traces;
173
+        }
174
+
175
+        if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) {
176
+            return $traces;
177
+        }
178 178
 		
179
-		// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
180
-		$stack = array_reverse(xdebug_get_function_stack());
181
-		$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
182
-		$traces = array_diff_key($stack, $trace);
179
+        // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
180
+        $stack = array_reverse(xdebug_get_function_stack());
181
+        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
182
+        $traces = array_diff_key($stack, $trace);
183 183
 		
184
-		return $traces;
185
-	}
184
+        return $traces;
185
+    }
186 186
 }
187 187
\ No newline at end of file
Please login to merge, or discard this patch.