@@ -12,27 +12,27 @@ |
||
12 | 12 | class UnexpectedEntityException extends \UnexpectedValueException |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * UnexpectedEntityException constructor |
|
17 | - * |
|
18 | - * @param mixed $entity the actual object or variable that was received |
|
19 | - * @param string $expected_class classname of the entity we wanted |
|
20 | - * @param string $message |
|
21 | - * @param int $code |
|
22 | - * @param \Exception $previous |
|
23 | - */ |
|
24 | - public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | - { |
|
26 | - if (empty($message)) { |
|
27 | - $message = sprintf( |
|
28 | - __( |
|
29 | - 'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.', |
|
30 | - 'event_espresso' |
|
31 | - ), |
|
32 | - is_object($entity) ? get_class($entity) : gettype($entity), |
|
33 | - $expected_class |
|
34 | - ); |
|
35 | - } |
|
36 | - parent::__construct($message, $code, $previous); |
|
37 | - } |
|
15 | + /** |
|
16 | + * UnexpectedEntityException constructor |
|
17 | + * |
|
18 | + * @param mixed $entity the actual object or variable that was received |
|
19 | + * @param string $expected_class classname of the entity we wanted |
|
20 | + * @param string $message |
|
21 | + * @param int $code |
|
22 | + * @param \Exception $previous |
|
23 | + */ |
|
24 | + public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | + { |
|
26 | + if (empty($message)) { |
|
27 | + $message = sprintf( |
|
28 | + __( |
|
29 | + 'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.', |
|
30 | + 'event_espresso' |
|
31 | + ), |
|
32 | + is_object($entity) ? get_class($entity) : gettype($entity), |
|
33 | + $expected_class |
|
34 | + ); |
|
35 | + } |
|
36 | + parent::__construct($message, $code, $previous); |
|
37 | + } |
|
38 | 38 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * EntityConstructionException constructor |
|
18 | - * |
|
19 | - * @param string $entity_class class name of the entity being constructed |
|
20 | - * @param string $message |
|
21 | - * @param int $code |
|
22 | - * @param \Exception $previous |
|
23 | - */ |
|
24 | - public function __construct($entity_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | - { |
|
26 | - if (empty($message)) { |
|
27 | - $message = sprintf( |
|
28 | - __( |
|
29 | - 'The "%1$s" entity could not be instantiated for an unknown reason', |
|
30 | - 'event_espresso' |
|
31 | - ), |
|
32 | - $entity_class |
|
33 | - ); |
|
34 | - } |
|
35 | - parent::__construct($message, $code, $previous); |
|
36 | - } |
|
16 | + /** |
|
17 | + * EntityConstructionException constructor |
|
18 | + * |
|
19 | + * @param string $entity_class class name of the entity being constructed |
|
20 | + * @param string $message |
|
21 | + * @param int $code |
|
22 | + * @param \Exception $previous |
|
23 | + */ |
|
24 | + public function __construct($entity_class, $message = '', $code = 0, \Exception $previous = null) |
|
25 | + { |
|
26 | + if (empty($message)) { |
|
27 | + $message = sprintf( |
|
28 | + __( |
|
29 | + 'The "%1$s" entity could not be instantiated for an unknown reason', |
|
30 | + 'event_espresso' |
|
31 | + ), |
|
32 | + $entity_class |
|
33 | + ); |
|
34 | + } |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | + } |
|
37 | 37 | } |
@@ -19,52 +19,52 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @param Exception $exception |
|
24 | - * @throws Exception |
|
25 | - */ |
|
26 | - public function __construct(Exception $exception) |
|
27 | - { |
|
28 | - if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
29 | - $this->displayException($exception); |
|
30 | - } else { |
|
31 | - throw $exception; |
|
32 | - } |
|
33 | - } |
|
22 | + /** |
|
23 | + * @param Exception $exception |
|
24 | + * @throws Exception |
|
25 | + */ |
|
26 | + public function __construct(Exception $exception) |
|
27 | + { |
|
28 | + if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
29 | + $this->displayException($exception); |
|
30 | + } else { |
|
31 | + throw $exception; |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @access protected |
|
38 | - * @param Exception $exception |
|
39 | - * @throws ReflectionException |
|
40 | - */ |
|
41 | - protected function displayException(Exception $exception) |
|
42 | - { |
|
43 | - $error_code = ''; |
|
44 | - $trace_details = ''; |
|
45 | - $time = time(); |
|
46 | - $trace = $exception->getTrace(); |
|
47 | - // get separate user and developer messages if they exist |
|
48 | - $msg = explode('||', $exception->getMessage()); |
|
49 | - $user_msg = $msg[0]; |
|
50 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
51 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
52 | - // start gathering output |
|
53 | - $output = $this->exceptionStyles(); |
|
54 | - $output .= ' |
|
36 | + /** |
|
37 | + * @access protected |
|
38 | + * @param Exception $exception |
|
39 | + * @throws ReflectionException |
|
40 | + */ |
|
41 | + protected function displayException(Exception $exception) |
|
42 | + { |
|
43 | + $error_code = ''; |
|
44 | + $trace_details = ''; |
|
45 | + $time = time(); |
|
46 | + $trace = $exception->getTrace(); |
|
47 | + // get separate user and developer messages if they exist |
|
48 | + $msg = explode('||', $exception->getMessage()); |
|
49 | + $user_msg = $msg[0]; |
|
50 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
51 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
52 | + // start gathering output |
|
53 | + $output = $this->exceptionStyles(); |
|
54 | + $output .= ' |
|
55 | 55 | <div id="ee-error-message" class="error">'; |
56 | - if (! WP_DEBUG) { |
|
57 | - $output .= ' |
|
56 | + if (! WP_DEBUG) { |
|
57 | + $output .= ' |
|
58 | 58 | <p>'; |
59 | - } |
|
60 | - // process trace info |
|
61 | - if (empty($trace)) { |
|
62 | - $trace_details .= __( |
|
63 | - 'Sorry, but no trace information was available for this exception.', |
|
64 | - 'event_espresso' |
|
65 | - ); |
|
66 | - } else { |
|
67 | - $trace_details .= ' |
|
59 | + } |
|
60 | + // process trace info |
|
61 | + if (empty($trace)) { |
|
62 | + $trace_details .= __( |
|
63 | + 'Sorry, but no trace information was available for this exception.', |
|
64 | + 'event_espresso' |
|
65 | + ); |
|
66 | + } else { |
|
67 | + $trace_details .= ' |
|
68 | 68 | <div id="ee-trace-details"> |
69 | 69 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
70 | 70 | <tr> |
@@ -72,260 +72,260 @@ discard block |
||
72 | 72 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
73 | 73 | <th scope="col" align="left" style="width:40%;">File</th> |
74 | 74 | <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __( |
75 | - 'Method( arguments )', |
|
76 | - 'event_espresso' |
|
77 | - ) . '</th> |
|
75 | + 'Method( arguments )', |
|
76 | + 'event_espresso' |
|
77 | + ) . '</th> |
|
78 | 78 | </tr>'; |
79 | - $last_on_stack = count($trace) - 1; |
|
80 | - // reverse array so that stack is in proper chronological order |
|
81 | - $sorted_trace = array_reverse($trace); |
|
82 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
83 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
84 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
85 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
86 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
87 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
88 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
89 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
90 | - $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
91 | - if (empty($file) && ! empty($class)) { |
|
92 | - $a = new ReflectionClass($class); |
|
93 | - $file = $a->getFileName(); |
|
94 | - if (empty($line) && ! empty($function)) { |
|
95 | - try { |
|
96 | - // if $function is a closure, this throws an exception |
|
97 | - $b = new ReflectionMethod($class, $function); |
|
98 | - $line = $b->getStartLine(); |
|
99 | - } catch (Exception $closure_exception) { |
|
100 | - $line = 'unknown'; |
|
101 | - } |
|
102 | - } |
|
103 | - } |
|
104 | - if ($nmbr === $last_on_stack) { |
|
105 | - $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | - $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | - $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | - } |
|
109 | - $file = \EEH_File::standardise_directory_separators($file); |
|
110 | - $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | - $line = ! empty($line) ? $line : ' '; |
|
112 | - $file = ! empty($file) ? $file : ' '; |
|
113 | - $class_display = ! empty($class) ? $class : ''; |
|
114 | - $type = ! empty($type) ? $type : ''; |
|
115 | - $function = ! empty($function) ? $function : ''; |
|
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | - $trace_details .= ' |
|
79 | + $last_on_stack = count($trace) - 1; |
|
80 | + // reverse array so that stack is in proper chronological order |
|
81 | + $sorted_trace = array_reverse($trace); |
|
82 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
83 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
84 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
85 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
86 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
87 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
88 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
89 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
90 | + $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
91 | + if (empty($file) && ! empty($class)) { |
|
92 | + $a = new ReflectionClass($class); |
|
93 | + $file = $a->getFileName(); |
|
94 | + if (empty($line) && ! empty($function)) { |
|
95 | + try { |
|
96 | + // if $function is a closure, this throws an exception |
|
97 | + $b = new ReflectionMethod($class, $function); |
|
98 | + $line = $b->getStartLine(); |
|
99 | + } catch (Exception $closure_exception) { |
|
100 | + $line = 'unknown'; |
|
101 | + } |
|
102 | + } |
|
103 | + } |
|
104 | + if ($nmbr === $last_on_stack) { |
|
105 | + $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | + $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | + $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | + } |
|
109 | + $file = \EEH_File::standardise_directory_separators($file); |
|
110 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | + $line = ! empty($line) ? $line : ' '; |
|
112 | + $file = ! empty($file) ? $file : ' '; |
|
113 | + $class_display = ! empty($class) ? $class : ''; |
|
114 | + $type = ! empty($type) ? $type : ''; |
|
115 | + $function = ! empty($function) ? $function : ''; |
|
116 | + $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | + $trace_details .= ' |
|
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
120 | - . $zebra |
|
121 | - . '">' |
|
122 | - . $nmbr |
|
123 | - . '</td> |
|
120 | + . $zebra |
|
121 | + . '">' |
|
122 | + . $nmbr |
|
123 | + . '</td> |
|
124 | 124 | <td align="right" valign="top" class="' |
125 | - . $zebra |
|
126 | - . '">' |
|
127 | - . $line |
|
128 | - . '</td> |
|
125 | + . $zebra |
|
126 | + . '">' |
|
127 | + . $line |
|
128 | + . '</td> |
|
129 | 129 | <td align="left" valign="top" class="' |
130 | - . $zebra |
|
131 | - . '">' |
|
132 | - . $file |
|
133 | - . '</td> |
|
130 | + . $zebra |
|
131 | + . '">' |
|
132 | + . $file |
|
133 | + . '</td> |
|
134 | 134 | <td align="left" valign="top" class="' |
135 | - . $zebra |
|
136 | - . '">' |
|
137 | - . $class_display |
|
138 | - . $type |
|
139 | - . $function |
|
140 | - . $args |
|
141 | - . '</td> |
|
135 | + . $zebra |
|
136 | + . '">' |
|
137 | + . $class_display |
|
138 | + . $type |
|
139 | + . $function |
|
140 | + . $args |
|
141 | + . '</td> |
|
142 | 142 | </tr>'; |
143 | - } |
|
144 | - $trace_details .= ' |
|
143 | + } |
|
144 | + $trace_details .= ' |
|
145 | 145 | </table> |
146 | 146 | </div>'; |
147 | - } |
|
148 | - $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | - // add generic non-identifying messages for non-privileged users |
|
150 | - if (! WP_DEBUG) { |
|
151 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | - . trim($msg) |
|
153 | - . '</span> <sup>' |
|
154 | - . $code |
|
155 | - . '</sup><br />'; |
|
156 | - } else { |
|
157 | - // or helpful developer messages if debugging is on |
|
158 | - $output .= ' |
|
147 | + } |
|
148 | + $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | + // add generic non-identifying messages for non-privileged users |
|
150 | + if (! WP_DEBUG) { |
|
151 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | + . trim($msg) |
|
153 | + . '</span> <sup>' |
|
154 | + . $code |
|
155 | + . '</sup><br />'; |
|
156 | + } else { |
|
157 | + // or helpful developer messages if debugging is on |
|
158 | + $output .= ' |
|
159 | 159 | <div class="ee-error-dev-msg-dv"> |
160 | 160 | <p class="ee-error-dev-msg-pg"> |
161 | 161 | ' |
162 | - . sprintf( |
|
163 | - __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | - '<strong class="ee-error-dev-msg-str">', |
|
165 | - get_class($exception), |
|
166 | - '</strong> <span>', |
|
167 | - $code . '</span>' |
|
168 | - ) |
|
169 | - . '<br /> |
|
162 | + . sprintf( |
|
163 | + __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | + '<strong class="ee-error-dev-msg-str">', |
|
165 | + get_class($exception), |
|
166 | + '</strong> <span>', |
|
167 | + $code . '</span>' |
|
168 | + ) |
|
169 | + . '<br /> |
|
170 | 170 | <span class="big-text">"' |
171 | - . trim($msg) |
|
172 | - . '"</span><br/> |
|
171 | + . trim($msg) |
|
172 | + . '"</span><br/> |
|
173 | 173 | <a id="display-ee-error-trace-1' |
174 | - . $time |
|
175 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | - . $time |
|
177 | - . '"> |
|
174 | + . $time |
|
175 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | + . $time |
|
177 | + . '"> |
|
178 | 178 | ' |
179 | - . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | - . ' |
|
179 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | + . ' |
|
181 | 181 | </a><br /> |
182 | 182 | ' |
183 | - . $exception->getFile() |
|
184 | - . sprintf( |
|
185 | - __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | - ' <span class="small-text lt-grey-text">', |
|
187 | - $exception->getLine(), |
|
188 | - '</span>' |
|
189 | - ) |
|
190 | - . ' |
|
183 | + . $exception->getFile() |
|
184 | + . sprintf( |
|
185 | + __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | + ' <span class="small-text lt-grey-text">', |
|
187 | + $exception->getLine(), |
|
188 | + '</span>' |
|
189 | + ) |
|
190 | + . ' |
|
191 | 191 | </p> |
192 | 192 | <div id="ee-error-trace-1' |
193 | - . $time |
|
194 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
193 | + . $time |
|
194 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
195 | 195 | ' |
196 | - . $trace_details; |
|
197 | - if (! empty($class)) { |
|
198 | - $output .= ' |
|
196 | + . $trace_details; |
|
197 | + if (! empty($class)) { |
|
198 | + $output .= ' |
|
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | 201 | <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
202 | - $a = new ReflectionClass($class); |
|
203 | - $output .= ' |
|
202 | + $a = new ReflectionClass($class); |
|
203 | + $output .= ' |
|
204 | 204 | <pre>' . $a . '</pre> |
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | - } |
|
208 | - $output .= ' |
|
207 | + } |
|
208 | + $output .= ' |
|
209 | 209 | </div> |
210 | 210 | </div> |
211 | 211 | <br />'; |
212 | - } |
|
213 | - // remove last linebreak |
|
214 | - $output = substr($output, 0, -6); |
|
215 | - if (! WP_DEBUG) { |
|
216 | - $output .= ' |
|
212 | + } |
|
213 | + // remove last linebreak |
|
214 | + $output = substr($output, 0, -6); |
|
215 | + if (! WP_DEBUG) { |
|
216 | + $output .= ' |
|
217 | 217 | </p>'; |
218 | - } |
|
219 | - $output .= ' |
|
218 | + } |
|
219 | + $output .= ' |
|
220 | 220 | </div>'; |
221 | - $output .= $this->printScripts(true); |
|
222 | - if (defined('DOING_AJAX')) { |
|
223 | - echo wp_json_encode(array('error' => $output)); |
|
224 | - exit(); |
|
225 | - } |
|
226 | - echo $output; |
|
227 | - } |
|
221 | + $output .= $this->printScripts(true); |
|
222 | + if (defined('DOING_AJAX')) { |
|
223 | + echo wp_json_encode(array('error' => $output)); |
|
224 | + exit(); |
|
225 | + } |
|
226 | + echo $output; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
231 | - /** |
|
232 | - * generate string from exception trace args |
|
233 | - * |
|
234 | - * @param array $arguments |
|
235 | - * @param int $indent |
|
236 | - * @param bool $array |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | - { |
|
241 | - $args = array(); |
|
242 | - $args_count = count($arguments); |
|
243 | - if ($args_count > 2) { |
|
244 | - $indent++; |
|
245 | - $args[] = '<br />'; |
|
246 | - } |
|
247 | - $x = 0; |
|
248 | - foreach ($arguments as $arg) { |
|
249 | - $x++; |
|
250 | - for ($i = 0; $i < $indent; $i++) { |
|
251 | - $args[] = ' '; |
|
252 | - } |
|
253 | - if (is_string($arg)) { |
|
254 | - if (! $array && strlen($arg) > 75) { |
|
255 | - $args[] = '<br />'; |
|
256 | - for ($i = 0; $i <= $indent; $i++) { |
|
257 | - $args[] = ' '; |
|
258 | - } |
|
259 | - $args[] = "'" . $arg . "'<br />"; |
|
260 | - } else { |
|
261 | - $args[] = " '" . $arg . "'"; |
|
262 | - } |
|
263 | - } elseif (is_array($arg)) { |
|
264 | - $arg_count = count($arg); |
|
265 | - if ($arg_count > 2) { |
|
266 | - $indent++; |
|
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | - $indent--; |
|
269 | - } else if ($arg_count === 0) { |
|
270 | - $args[] = ' array()'; |
|
271 | - } else { |
|
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | - } |
|
274 | - } elseif ($arg === null) { |
|
275 | - $args[] = ' null'; |
|
276 | - } elseif (is_bool($arg)) { |
|
277 | - $args[] = $arg ? ' true' : ' false'; |
|
278 | - } elseif (is_object($arg)) { |
|
279 | - $args[] = get_class($arg); |
|
280 | - } elseif (is_resource($arg)) { |
|
281 | - $args[] = get_resource_type($arg); |
|
282 | - } else { |
|
283 | - $args[] = $arg; |
|
284 | - } |
|
285 | - if ($x === $args_count) { |
|
286 | - if ($args_count > 2) { |
|
287 | - $args[] = '<br />'; |
|
288 | - $indent--; |
|
289 | - for ($i = 1; $i < $indent; $i++) { |
|
290 | - $args[] = ' '; |
|
291 | - } |
|
292 | - } |
|
293 | - } else { |
|
294 | - $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | - } |
|
296 | - } |
|
297 | - return implode('', $args); |
|
298 | - } |
|
230 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
231 | + /** |
|
232 | + * generate string from exception trace args |
|
233 | + * |
|
234 | + * @param array $arguments |
|
235 | + * @param int $indent |
|
236 | + * @param bool $array |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | + { |
|
241 | + $args = array(); |
|
242 | + $args_count = count($arguments); |
|
243 | + if ($args_count > 2) { |
|
244 | + $indent++; |
|
245 | + $args[] = '<br />'; |
|
246 | + } |
|
247 | + $x = 0; |
|
248 | + foreach ($arguments as $arg) { |
|
249 | + $x++; |
|
250 | + for ($i = 0; $i < $indent; $i++) { |
|
251 | + $args[] = ' '; |
|
252 | + } |
|
253 | + if (is_string($arg)) { |
|
254 | + if (! $array && strlen($arg) > 75) { |
|
255 | + $args[] = '<br />'; |
|
256 | + for ($i = 0; $i <= $indent; $i++) { |
|
257 | + $args[] = ' '; |
|
258 | + } |
|
259 | + $args[] = "'" . $arg . "'<br />"; |
|
260 | + } else { |
|
261 | + $args[] = " '" . $arg . "'"; |
|
262 | + } |
|
263 | + } elseif (is_array($arg)) { |
|
264 | + $arg_count = count($arg); |
|
265 | + if ($arg_count > 2) { |
|
266 | + $indent++; |
|
267 | + $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | + $indent--; |
|
269 | + } else if ($arg_count === 0) { |
|
270 | + $args[] = ' array()'; |
|
271 | + } else { |
|
272 | + $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | + } |
|
274 | + } elseif ($arg === null) { |
|
275 | + $args[] = ' null'; |
|
276 | + } elseif (is_bool($arg)) { |
|
277 | + $args[] = $arg ? ' true' : ' false'; |
|
278 | + } elseif (is_object($arg)) { |
|
279 | + $args[] = get_class($arg); |
|
280 | + } elseif (is_resource($arg)) { |
|
281 | + $args[] = get_resource_type($arg); |
|
282 | + } else { |
|
283 | + $args[] = $arg; |
|
284 | + } |
|
285 | + if ($x === $args_count) { |
|
286 | + if ($args_count > 2) { |
|
287 | + $args[] = '<br />'; |
|
288 | + $indent--; |
|
289 | + for ($i = 1; $i < $indent; $i++) { |
|
290 | + $args[] = ' '; |
|
291 | + } |
|
292 | + } |
|
293 | + } else { |
|
294 | + $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | + } |
|
296 | + } |
|
297 | + return implode('', $args); |
|
298 | + } |
|
299 | 299 | |
300 | 300 | |
301 | - /** |
|
302 | - * create error code from filepath, function name, |
|
303 | - * and line number where exception or error was thrown |
|
304 | - * |
|
305 | - * @access protected |
|
306 | - * @param string $file |
|
307 | - * @param string $func |
|
308 | - * @param string $line |
|
309 | - * @return string |
|
310 | - */ |
|
311 | - protected function generate_error_code($file = '', $func = '', $line = '') |
|
312 | - { |
|
313 | - $file_bits = explode('.', basename($file)); |
|
314 | - $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
315 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
316 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
317 | - return $error_code; |
|
318 | - } |
|
301 | + /** |
|
302 | + * create error code from filepath, function name, |
|
303 | + * and line number where exception or error was thrown |
|
304 | + * |
|
305 | + * @access protected |
|
306 | + * @param string $file |
|
307 | + * @param string $func |
|
308 | + * @param string $line |
|
309 | + * @return string |
|
310 | + */ |
|
311 | + protected function generate_error_code($file = '', $func = '', $line = '') |
|
312 | + { |
|
313 | + $file_bits = explode('.', basename($file)); |
|
314 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
315 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
316 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
317 | + return $error_code; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | - /** |
|
322 | - * _exception_styles |
|
323 | - * |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - private function exceptionStyles() |
|
327 | - { |
|
328 | - return ' |
|
321 | + /** |
|
322 | + * _exception_styles |
|
323 | + * |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + private function exceptionStyles() |
|
327 | + { |
|
328 | + return ' |
|
329 | 329 | <style type="text/css"> |
330 | 330 | #ee-error-message { |
331 | 331 | max-width:90% !important; |
@@ -382,29 +382,29 @@ discard block |
||
382 | 382 | color: #999; |
383 | 383 | } |
384 | 384 | </style>'; |
385 | - } |
|
385 | + } |
|
386 | 386 | |
387 | 387 | |
388 | - /** |
|
389 | - * _print_scripts |
|
390 | - * |
|
391 | - * @param bool $force_print |
|
392 | - * @return string |
|
393 | - */ |
|
394 | - private function printScripts($force_print = false) |
|
395 | - { |
|
396 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
397 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
398 | - return ''; |
|
399 | - } |
|
400 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
401 | - wp_enqueue_style('espresso_default'); |
|
402 | - wp_enqueue_style('espresso_custom_css'); |
|
403 | - wp_enqueue_script('ee_error_js'); |
|
404 | - wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
405 | - } |
|
406 | - } else { |
|
407 | - return ' |
|
388 | + /** |
|
389 | + * _print_scripts |
|
390 | + * |
|
391 | + * @param bool $force_print |
|
392 | + * @return string |
|
393 | + */ |
|
394 | + private function printScripts($force_print = false) |
|
395 | + { |
|
396 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
397 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
398 | + return ''; |
|
399 | + } |
|
400 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
401 | + wp_enqueue_style('espresso_default'); |
|
402 | + wp_enqueue_style('espresso_custom_css'); |
|
403 | + wp_enqueue_script('ee_error_js'); |
|
404 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
405 | + } |
|
406 | + } else { |
|
407 | + return ' |
|
408 | 408 | <script> |
409 | 409 | /* <![CDATA[ */ |
410 | 410 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
415 | 415 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
416 | 416 | '; |
417 | - } |
|
418 | - return ''; |
|
419 | - } |
|
417 | + } |
|
418 | + return ''; |
|
419 | + } |
|
420 | 420 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $output = $this->exceptionStyles(); |
54 | 54 | $output .= ' |
55 | 55 | <div id="ee-error-message" class="error">'; |
56 | - if (! WP_DEBUG) { |
|
56 | + if ( ! WP_DEBUG) { |
|
57 | 57 | $output .= ' |
58 | 58 | <p>'; |
59 | 59 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | <th scope="col" align="right" style="width:2.5%;">#</th> |
72 | 72 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
73 | 73 | <th scope="col" align="left" style="width:40%;">File</th> |
74 | - <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __( |
|
74 | + <th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__( |
|
75 | 75 | 'Method( arguments )', |
76 | 76 | 'event_espresso' |
77 | - ) . '</th> |
|
77 | + ).'</th> |
|
78 | 78 | </tr>'; |
79 | 79 | $last_on_stack = count($trace) - 1; |
80 | 80 | // reverse array so that stack is in proper chronological order |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $type = isset($trace['type']) ? $trace['type'] : ''; |
86 | 86 | $function = isset($trace['function']) ? $trace['function'] : ''; |
87 | 87 | $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
88 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
88 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
89 | 89 | $line = isset($trace['line']) ? $trace['line'] : ''; |
90 | 90 | $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
91 | 91 | if (empty($file) && ! empty($class)) { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $class_display = ! empty($class) ? $class : ''; |
114 | 114 | $type = ! empty($type) ? $type : ''; |
115 | 115 | $function = ! empty($function) ? $function : ''; |
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
116 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
117 | 117 | $trace_details .= ' |
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $code = $exception->getCode() ? $exception->getCode() : $error_code; |
149 | 149 | // add generic non-identifying messages for non-privileged users |
150 | - if (! WP_DEBUG) { |
|
150 | + if ( ! WP_DEBUG) { |
|
151 | 151 | $output .= '<span class="ee-error-user-msg-spn">' |
152 | 152 | . trim($msg) |
153 | 153 | . '</span> <sup>' |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | '<strong class="ee-error-dev-msg-str">', |
165 | 165 | get_class($exception), |
166 | 166 | '</strong> <span>', |
167 | - $code . '</span>' |
|
167 | + $code.'</span>' |
|
168 | 168 | ) |
169 | 169 | . '<br /> |
170 | 170 | <span class="big-text">"' |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
195 | 195 | ' |
196 | 196 | . $trace_details; |
197 | - if (! empty($class)) { |
|
197 | + if ( ! empty($class)) { |
|
198 | 198 | $output .= ' |
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | - <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
|
201 | + <h3>' . __('Class Details', 'event_espresso').'</h3>'; |
|
202 | 202 | $a = new ReflectionClass($class); |
203 | 203 | $output .= ' |
204 | - <pre>' . $a . '</pre> |
|
204 | + <pre>' . $a.'</pre> |
|
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | // remove last linebreak |
214 | 214 | $output = substr($output, 0, -6); |
215 | - if (! WP_DEBUG) { |
|
215 | + if ( ! WP_DEBUG) { |
|
216 | 216 | $output .= ' |
217 | 217 | </p>'; |
218 | 218 | } |
@@ -251,25 +251,25 @@ discard block |
||
251 | 251 | $args[] = ' '; |
252 | 252 | } |
253 | 253 | if (is_string($arg)) { |
254 | - if (! $array && strlen($arg) > 75) { |
|
254 | + if ( ! $array && strlen($arg) > 75) { |
|
255 | 255 | $args[] = '<br />'; |
256 | 256 | for ($i = 0; $i <= $indent; $i++) { |
257 | 257 | $args[] = ' '; |
258 | 258 | } |
259 | - $args[] = "'" . $arg . "'<br />"; |
|
259 | + $args[] = "'".$arg."'<br />"; |
|
260 | 260 | } else { |
261 | - $args[] = " '" . $arg . "'"; |
|
261 | + $args[] = " '".$arg."'"; |
|
262 | 262 | } |
263 | 263 | } elseif (is_array($arg)) { |
264 | 264 | $arg_count = count($arg); |
265 | 265 | if ($arg_count > 2) { |
266 | 266 | $indent++; |
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
267 | + $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')'; |
|
268 | 268 | $indent--; |
269 | 269 | } else if ($arg_count === 0) { |
270 | 270 | $args[] = ' array()'; |
271 | 271 | } else { |
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
272 | + $args[] = ' array( '.$this->_convert_args_to_string($arg).' )'; |
|
273 | 273 | } |
274 | 274 | } elseif ($arg === null) { |
275 | 275 | $args[] = ' null'; |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | { |
313 | 313 | $file_bits = explode('.', basename($file)); |
314 | 314 | $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
315 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
316 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
315 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
316 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
317 | 317 | return $error_code; |
318 | 318 | } |
319 | 319 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | private function printScripts($force_print = false) |
395 | 395 | { |
396 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
396 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
397 | 397 | if (wp_script_is('ee_error_js', 'enqueued')) { |
398 | 398 | return ''; |
399 | 399 | } |
@@ -407,12 +407,12 @@ discard block |
||
407 | 407 | return ' |
408 | 408 | <script> |
409 | 409 | /* <![CDATA[ */ |
410 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
410 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
411 | 411 | /* ]]> */ |
412 | 412 | </script> |
413 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
414 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
415 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
413 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
414 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
415 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
416 | 416 | '; |
417 | 417 | } |
418 | 418 | return ''; |
@@ -17,34 +17,34 @@ |
||
17 | 17 | class Windows1252 extends FormatterBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Converts the string to windows-1252 encoding. |
|
22 | - * |
|
23 | - * @param string|int|float $input anything easily cast into a string |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function format($input) |
|
27 | - { |
|
28 | - // in case an int or float etc was passed in |
|
29 | - $input = (string)$input; |
|
30 | - if (function_exists('iconv')) { |
|
31 | - $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
32 | - } elseif (WP_DEBUG) { |
|
33 | - trigger_error( |
|
34 | - sprintf( |
|
35 | - // @codingStandardsIgnoreStart |
|
36 | - esc_html__( |
|
37 | - '%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - // @codingStandardsIgnoreEnd |
|
41 | - get_class($this), |
|
42 | - $input, |
|
43 | - 'iconv', |
|
44 | - '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
48 | - return $input; |
|
49 | - } |
|
20 | + /** |
|
21 | + * Converts the string to windows-1252 encoding. |
|
22 | + * |
|
23 | + * @param string|int|float $input anything easily cast into a string |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function format($input) |
|
27 | + { |
|
28 | + // in case an int or float etc was passed in |
|
29 | + $input = (string)$input; |
|
30 | + if (function_exists('iconv')) { |
|
31 | + $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
32 | + } elseif (WP_DEBUG) { |
|
33 | + trigger_error( |
|
34 | + sprintf( |
|
35 | + // @codingStandardsIgnoreStart |
|
36 | + esc_html__( |
|
37 | + '%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + // @codingStandardsIgnoreEnd |
|
41 | + get_class($this), |
|
42 | + $input, |
|
43 | + 'iconv', |
|
44 | + '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | + return $input; |
|
49 | + } |
|
50 | 50 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function format($input) |
27 | 27 | { |
28 | 28 | // in case an int or float etc was passed in |
29 | - $input = (string)$input; |
|
29 | + $input = (string) $input; |
|
30 | 30 | if (function_exists('iconv')) { |
31 | 31 | $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
32 | 32 | } elseif (WP_DEBUG) { |
@@ -15,26 +15,26 @@ |
||
15 | 15 | abstract class FormatterBase implements FormatterInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Recursively applies the formatting to all VALUES in this multi-dimensional array |
|
20 | - * |
|
21 | - * @param array $input |
|
22 | - * @return array |
|
23 | - * @throws InvalidDataTypeException if $input is not an array |
|
24 | - */ |
|
25 | - public function formatArray($input) |
|
26 | - { |
|
27 | - if (! is_array($input)) { |
|
28 | - throw new InvalidDataTypeException('input', $input, 'array'); |
|
29 | - } |
|
30 | - // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
|
31 | - $formatter = $this; |
|
32 | - array_walk_recursive( |
|
33 | - $input, |
|
34 | - function (&$value, $key) use ($formatter) { |
|
35 | - $value = $formatter->format($value); |
|
36 | - } |
|
37 | - ); |
|
38 | - return $input; |
|
39 | - } |
|
18 | + /** |
|
19 | + * Recursively applies the formatting to all VALUES in this multi-dimensional array |
|
20 | + * |
|
21 | + * @param array $input |
|
22 | + * @return array |
|
23 | + * @throws InvalidDataTypeException if $input is not an array |
|
24 | + */ |
|
25 | + public function formatArray($input) |
|
26 | + { |
|
27 | + if (! is_array($input)) { |
|
28 | + throw new InvalidDataTypeException('input', $input, 'array'); |
|
29 | + } |
|
30 | + // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
|
31 | + $formatter = $this; |
|
32 | + array_walk_recursive( |
|
33 | + $input, |
|
34 | + function (&$value, $key) use ($formatter) { |
|
35 | + $value = $formatter->format($value); |
|
36 | + } |
|
37 | + ); |
|
38 | + return $input; |
|
39 | + } |
|
40 | 40 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | */ |
25 | 25 | public function formatArray($input) |
26 | 26 | { |
27 | - if (! is_array($input)) { |
|
27 | + if ( ! is_array($input)) { |
|
28 | 28 | throw new InvalidDataTypeException('input', $input, 'array'); |
29 | 29 | } |
30 | 30 | // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead |
31 | 31 | $formatter = $this; |
32 | 32 | array_walk_recursive( |
33 | 33 | $input, |
34 | - function (&$value, $key) use ($formatter) { |
|
34 | + function(&$value, $key) use ($formatter) { |
|
35 | 35 | $value = $formatter->format($value); |
36 | 36 | } |
37 | 37 | ); |
@@ -15,26 +15,26 @@ |
||
15 | 15 | class LeaveAlone extends FormatterBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Removes the emojis from the inputted string |
|
20 | - * |
|
21 | - * @param string|int|float $input anything easily cast into a string |
|
22 | - * @return string |
|
23 | - * @throws InvalidDataTypeException if $input is not a string |
|
24 | - */ |
|
25 | - public function format($input) |
|
26 | - { |
|
27 | - return $input; |
|
28 | - } |
|
18 | + /** |
|
19 | + * Removes the emojis from the inputted string |
|
20 | + * |
|
21 | + * @param string|int|float $input anything easily cast into a string |
|
22 | + * @return string |
|
23 | + * @throws InvalidDataTypeException if $input is not a string |
|
24 | + */ |
|
25 | + public function format($input) |
|
26 | + { |
|
27 | + return $input; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Just returns the inputted $input array |
|
32 | - * |
|
33 | - * @param array $input |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function formatArray($input) |
|
37 | - { |
|
38 | - return $input; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Just returns the inputted $input array |
|
32 | + * |
|
33 | + * @param array $input |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function formatArray($input) |
|
37 | + { |
|
38 | + return $input; |
|
39 | + } |
|
40 | 40 | } |
@@ -14,119 +14,119 @@ |
||
14 | 14 | class Response implements ResponseInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var array $notice |
|
19 | - */ |
|
20 | - protected $notice = array(); |
|
21 | - |
|
22 | - /** |
|
23 | - * rendered output to be returned to WP |
|
24 | - * |
|
25 | - * @var string $output |
|
26 | - */ |
|
27 | - protected $output = ''; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var bool |
|
31 | - */ |
|
32 | - protected $request_terminated = false; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var bool $deactivate_plugin |
|
36 | - */ |
|
37 | - protected $deactivate_plugin = false; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * EE_Response constructor. |
|
42 | - */ |
|
43 | - public function __construct() |
|
44 | - { |
|
45 | - $this->terminateRequest(false); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @param $key |
|
51 | - * @param $value |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function setNotice($key, $value) |
|
55 | - { |
|
56 | - $this->notice[$key] = $value; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @param $key |
|
62 | - * @return mixed |
|
63 | - */ |
|
64 | - public function getNotice($key) |
|
65 | - { |
|
66 | - return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - public function getNotices() |
|
74 | - { |
|
75 | - return $this->notice; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $string |
|
81 | - * @param bool $append |
|
82 | - */ |
|
83 | - public function addOutput($string, $append = true) |
|
84 | - { |
|
85 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function getOutput() |
|
93 | - { |
|
94 | - return $this->output; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return boolean |
|
100 | - */ |
|
101 | - public function requestTerminated() |
|
102 | - { |
|
103 | - return $this->request_terminated; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param boolean $request_terminated |
|
109 | - */ |
|
110 | - public function terminateRequest($request_terminated = true) |
|
111 | - { |
|
112 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return boolean |
|
118 | - */ |
|
119 | - public function pluginDeactivated() |
|
120 | - { |
|
121 | - return $this->deactivate_plugin; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * sets $deactivate_plugin to true |
|
127 | - */ |
|
128 | - public function deactivatePlugin() |
|
129 | - { |
|
130 | - $this->deactivate_plugin = true; |
|
131 | - } |
|
17 | + /** |
|
18 | + * @var array $notice |
|
19 | + */ |
|
20 | + protected $notice = array(); |
|
21 | + |
|
22 | + /** |
|
23 | + * rendered output to be returned to WP |
|
24 | + * |
|
25 | + * @var string $output |
|
26 | + */ |
|
27 | + protected $output = ''; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var bool |
|
31 | + */ |
|
32 | + protected $request_terminated = false; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var bool $deactivate_plugin |
|
36 | + */ |
|
37 | + protected $deactivate_plugin = false; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * EE_Response constructor. |
|
42 | + */ |
|
43 | + public function __construct() |
|
44 | + { |
|
45 | + $this->terminateRequest(false); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @param $key |
|
51 | + * @param $value |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function setNotice($key, $value) |
|
55 | + { |
|
56 | + $this->notice[$key] = $value; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @param $key |
|
62 | + * @return mixed |
|
63 | + */ |
|
64 | + public function getNotice($key) |
|
65 | + { |
|
66 | + return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + public function getNotices() |
|
74 | + { |
|
75 | + return $this->notice; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $string |
|
81 | + * @param bool $append |
|
82 | + */ |
|
83 | + public function addOutput($string, $append = true) |
|
84 | + { |
|
85 | + $this->output = $append ? $this->output . $string : $string . $this->output; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function getOutput() |
|
93 | + { |
|
94 | + return $this->output; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | + public function requestTerminated() |
|
102 | + { |
|
103 | + return $this->request_terminated; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param boolean $request_terminated |
|
109 | + */ |
|
110 | + public function terminateRequest($request_terminated = true) |
|
111 | + { |
|
112 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return boolean |
|
118 | + */ |
|
119 | + public function pluginDeactivated() |
|
120 | + { |
|
121 | + return $this->deactivate_plugin; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * sets $deactivate_plugin to true |
|
127 | + */ |
|
128 | + public function deactivatePlugin() |
|
129 | + { |
|
130 | + $this->deactivate_plugin = true; |
|
131 | + } |
|
132 | 132 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | */ |
83 | 83 | public function addOutput($string, $append = true) |
84 | 84 | { |
85 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
85 | + $this->output = $append ? $this->output.$string : $string.$this->output; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 |
@@ -23,87 +23,87 @@ |
||
23 | 23 | class RequestStackCoreApp implements RequestDecoratorInterface, RequestStackCoreAppInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var RequestInterface $request |
|
28 | - */ |
|
29 | - protected $request; |
|
26 | + /** |
|
27 | + * @var RequestInterface $request |
|
28 | + */ |
|
29 | + protected $request; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var ResponseInterface $response |
|
33 | - */ |
|
34 | - protected $response; |
|
31 | + /** |
|
32 | + * @var ResponseInterface $response |
|
33 | + */ |
|
34 | + protected $response; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * handle |
|
39 | - * sets hooks for running rest of system |
|
40 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
41 | - * starting EE Addons from any other point may lead to problems |
|
42 | - * |
|
43 | - * @param RequestInterface $request |
|
44 | - * @param ResponseInterface $response |
|
45 | - * @return ResponseInterface |
|
46 | - * @throws InvalidClassException |
|
47 | - * @throws EE_Error |
|
48 | - * @throws InvalidDataTypeException |
|
49 | - * @throws InvalidInterfaceException |
|
50 | - * @throws InvalidArgumentException |
|
51 | - */ |
|
52 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
53 | - { |
|
54 | - $this->request = $request; |
|
55 | - $this->response = $response; |
|
56 | - espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
57 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
58 | - // workarounds for PHP < 5.3 |
|
59 | - espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
60 | - do_action( |
|
61 | - 'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading' |
|
62 | - ); |
|
63 | - // legacy action for backwards compatibility |
|
64 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
65 | - $this->setupFramework(); |
|
66 | - $loader = LoaderFactory::getLoader(); |
|
67 | - $loader->getShared( |
|
68 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
69 | - ); |
|
70 | - // WP cron jobs |
|
71 | - $loader->getShared('EE_Cron_Tasks'); |
|
72 | - $loader->getShared('EE_System'); |
|
73 | - return $this->response; |
|
74 | - } |
|
37 | + /** |
|
38 | + * handle |
|
39 | + * sets hooks for running rest of system |
|
40 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
41 | + * starting EE Addons from any other point may lead to problems |
|
42 | + * |
|
43 | + * @param RequestInterface $request |
|
44 | + * @param ResponseInterface $response |
|
45 | + * @return ResponseInterface |
|
46 | + * @throws InvalidClassException |
|
47 | + * @throws EE_Error |
|
48 | + * @throws InvalidDataTypeException |
|
49 | + * @throws InvalidInterfaceException |
|
50 | + * @throws InvalidArgumentException |
|
51 | + */ |
|
52 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
53 | + { |
|
54 | + $this->request = $request; |
|
55 | + $this->response = $response; |
|
56 | + espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
57 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
58 | + // workarounds for PHP < 5.3 |
|
59 | + espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
60 | + do_action( |
|
61 | + 'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading' |
|
62 | + ); |
|
63 | + // legacy action for backwards compatibility |
|
64 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
65 | + $this->setupFramework(); |
|
66 | + $loader = LoaderFactory::getLoader(); |
|
67 | + $loader->getShared( |
|
68 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
69 | + ); |
|
70 | + // WP cron jobs |
|
71 | + $loader->getShared('EE_Cron_Tasks'); |
|
72 | + $loader->getShared('EE_System'); |
|
73 | + return $this->response; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * set framework for the rest of EE to hook into when loading |
|
79 | - * |
|
80 | - * @throws EE_Error |
|
81 | - */ |
|
82 | - private function setupFramework() |
|
83 | - { |
|
84 | - espresso_load_required( |
|
85 | - 'EE_Bootstrap', |
|
86 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
87 | - ); |
|
88 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
89 | - add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
90 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
91 | - add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
92 | - add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
93 | - } |
|
77 | + /** |
|
78 | + * set framework for the rest of EE to hook into when loading |
|
79 | + * |
|
80 | + * @throws EE_Error |
|
81 | + */ |
|
82 | + private function setupFramework() |
|
83 | + { |
|
84 | + espresso_load_required( |
|
85 | + 'EE_Bootstrap', |
|
86 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
87 | + ); |
|
88 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
89 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
90 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
91 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
92 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * called after the request stack has been fully processed |
|
98 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
99 | - * |
|
100 | - * @param RequestInterface $request |
|
101 | - * @param ResponseInterface $response |
|
102 | - */ |
|
103 | - public function handleResponse(RequestInterface $request, ResponseInterface $response) |
|
104 | - { |
|
105 | - if ($response->pluginDeactivated()) { |
|
106 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
107 | - } |
|
108 | - } |
|
96 | + /** |
|
97 | + * called after the request stack has been fully processed |
|
98 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
99 | + * |
|
100 | + * @param RequestInterface $request |
|
101 | + * @param ResponseInterface $response |
|
102 | + */ |
|
103 | + public function handleResponse(RequestInterface $request, ResponseInterface $response) |
|
104 | + { |
|
105 | + if ($response->pluginDeactivated()) { |
|
106 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | { |
54 | 54 | $this->request = $request; |
55 | 55 | $this->response = $response; |
56 | - espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
57 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
56 | + espresso_load_required('EE_Base', EE_CORE.'EE_Base.core.php'); |
|
57 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
58 | 58 | // workarounds for PHP < 5.3 |
59 | - espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
59 | + espresso_load_required('EEH_Class_Tools', EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
60 | 60 | do_action( |
61 | 61 | 'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading' |
62 | 62 | ); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | espresso_load_required( |
85 | 85 | 'EE_Bootstrap', |
86 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
86 | + EE_CORE.'EE_Bootstrap.core.php' |
|
87 | 87 | ); |
88 | 88 | add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
89 | 89 | add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
@@ -15,33 +15,33 @@ |
||
15 | 15 | class InvalidRequestStackMiddlewareException extends InvalidDataTypeException |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param mixed $middleware_app_class |
|
20 | - * @param string $message |
|
21 | - * @param int $code |
|
22 | - * @param Exception $previous |
|
23 | - */ |
|
24 | - public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
|
25 | - { |
|
26 | - if (is_array($middleware_app_class)) { |
|
27 | - $middleware_app_class = reset($middleware_app_class); |
|
28 | - } |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - esc_html__( |
|
32 | - 'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - $middleware_app_class |
|
36 | - ); |
|
37 | - } |
|
38 | - parent::__construct( |
|
39 | - '$middleware_app_class', |
|
40 | - $middleware_app_class, |
|
41 | - 'EventEspresso\core\services\request\middleware\Middleware', |
|
42 | - $message, |
|
43 | - $code, |
|
44 | - $previous |
|
45 | - ); |
|
46 | - } |
|
18 | + /** |
|
19 | + * @param mixed $middleware_app_class |
|
20 | + * @param string $message |
|
21 | + * @param int $code |
|
22 | + * @param Exception $previous |
|
23 | + */ |
|
24 | + public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
|
25 | + { |
|
26 | + if (is_array($middleware_app_class)) { |
|
27 | + $middleware_app_class = reset($middleware_app_class); |
|
28 | + } |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + esc_html__( |
|
32 | + 'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + $middleware_app_class |
|
36 | + ); |
|
37 | + } |
|
38 | + parent::__construct( |
|
39 | + '$middleware_app_class', |
|
40 | + $middleware_app_class, |
|
41 | + 'EventEspresso\core\services\request\middleware\Middleware', |
|
42 | + $message, |
|
43 | + $code, |
|
44 | + $previous |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | } |