@@ -57,25 +57,25 @@ discard block |
||
57 | 57 | private function autoValidate($validate) |
58 | 58 | { |
59 | 59 | //we get the values ββto auto-validate. |
60 | - foreach ($this->{$validate} as $object=>$datas){ |
|
60 | + foreach ($this->{$validate} as $object=>$datas) { |
|
61 | 61 | |
62 | 62 | // the auto-validate value must necessarily represent a class. |
63 | 63 | // otherwise auto-validate is not used. |
64 | - if(Utils::isNamespaceExists($object)){ |
|
64 | + if (Utils::isNamespaceExists($object)) { |
|
65 | 65 | $getObjectInstance = app()->resolve($object); |
66 | 66 | |
67 | 67 | // we get the index values, |
68 | 68 | // which are called methods of the auto-validate value that represents the class. |
69 | - foreach ($datas as $dataKey=>$data){ |
|
69 | + foreach ($datas as $dataKey=>$data) { |
|
70 | 70 | |
71 | 71 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
72 | 72 | // the process of auto-validate automatic implementation will be completed. |
73 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){ |
|
74 | - if(isset($this->origin[$data])){ |
|
75 | - if(!is_array($this->origin[$data])){ |
|
73 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) { |
|
74 | + if (isset($this->origin[$data])) { |
|
75 | + if (!is_array($this->origin[$data])) { |
|
76 | 76 | $this->origin[$data] = array($this->origin[$data]); |
77 | 77 | } |
78 | - foreach ($this->origin[$data] as $originData){ |
|
78 | + foreach ($this->origin[$data] as $originData) { |
|
79 | 79 | $getObjectInstance->{$data}($originData); |
80 | 80 | } |
81 | 81 | } |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | |
98 | 98 | // Determines which HTTP method |
99 | 99 | // the request object will be exposed to. |
100 | - if($this->checkProperties('http')){ |
|
100 | + if ($this->checkProperties('http')) { |
|
101 | 101 | |
102 | 102 | // if the current http method does not exist |
103 | 103 | // in the http object, the exception will be thrown. |
104 | - if(!in_array($method,$this->http)){ |
|
104 | + if (!in_array($method, $this->http)) { |
|
105 | 105 | |
106 | 106 | //exception batMethodCall |
107 | 107 | exception()->badMethodCall( |
108 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
108 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | // from the properties of the object properties to |
122 | 122 | // the existing variables, control the array and at least one element. |
123 | - return (property_exists($this,$properties) |
|
123 | + return (property_exists($this, $properties) |
|
124 | 124 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
125 | 125 | } |
126 | 126 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | // we are saving the expected values ββfor the request in container. |
135 | 135 | // this record can be returned in exception information. |
136 | - app()->register('requestExpected',$this->expected); |
|
136 | + app()->register('requestExpected', $this->expected); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | public function except($except) |
146 | 146 | { |
147 | 147 | // the except parameter is a callable value. |
148 | - if(is_callable($except)){ |
|
149 | - $call = call_user_func_array($except,[$this]); |
|
148 | + if (is_callable($except)) { |
|
149 | + $call = call_user_func_array($except, [$this]); |
|
150 | 150 | $except = $call; |
151 | 151 | } |
152 | 152 | |
153 | 153 | // except with the except exceptions property |
154 | 154 | // and then assigning them to the inputs property. |
155 | - $this->except = array_merge($this->except,$except); |
|
156 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
155 | + $this->except = array_merge($this->except, $except); |
|
156 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
157 | 157 | |
158 | 158 | return $this; |
159 | 159 | } |
@@ -167,27 +167,27 @@ discard block |
||
167 | 167 | { |
168 | 168 | // expected method is executed. |
169 | 169 | // this method is a must for http method values to be found in this property. |
170 | - if($this->checkProperties('expected')){ |
|
170 | + if ($this->checkProperties('expected')) { |
|
171 | 171 | |
172 | 172 | // if the expected values are not found in the inputs array, |
173 | 173 | // the exception will be thrown. |
174 | - foreach ($this->expected as $expected){ |
|
174 | + foreach ($this->expected as $expected) { |
|
175 | 175 | |
176 | 176 | $expectedValues = []; |
177 | 177 | |
178 | 178 | // mandatory expected data for each key can be separated by | operator. |
179 | 179 | // this is evaluated as "or". |
180 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
181 | - if(!isset($this->inputs[$inputs])){ |
|
180 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
181 | + if (!isset($this->inputs[$inputs])) { |
|
182 | 182 | $expectedValues[] = $inputs; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | 186 | // if the expectedData and expectedValues ββ |
187 | 187 | // array are numerically equal to the expected key, the exception is thrown. |
188 | - if(count($expectedData)===count($expectedValues)){ |
|
188 | + if (count($expectedData)===count($expectedValues)) { |
|
189 | 189 | exception($expected) |
190 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
190 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -202,17 +202,17 @@ discard block |
||
202 | 202 | { |
203 | 203 | // check the presence of the generator object |
204 | 204 | // and operate the generator over this object. |
205 | - if($this->checkProperties('auto_generators')){ |
|
205 | + if ($this->checkProperties('auto_generators')) { |
|
206 | 206 | $generators = $this->getAutoGenerators(); |
207 | 207 | } |
208 | 208 | |
209 | 209 | // check the presence of the generator object |
210 | 210 | // and operate the generator over this object. |
211 | - if($this->checkProperties('generators')){ |
|
212 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
211 | + if ($this->checkProperties('generators')) { |
|
212 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
213 | 213 | } |
214 | 214 | |
215 | - if(isset($generators)){ |
|
215 | + if (isset($generators)) { |
|
216 | 216 | $this->generatorMethod($generators); |
217 | 217 | } |
218 | 218 | } |
@@ -227,30 +227,30 @@ discard block |
||
227 | 227 | private function generatorMethod($generators) |
228 | 228 | { |
229 | 229 | //generator array object |
230 | - foreach ($generators as $generator){ |
|
230 | + foreach ($generators as $generator) { |
|
231 | 231 | |
232 | 232 | //generator method name |
233 | 233 | $generatorMethodName = $generator.'Generator'; |
234 | 234 | |
235 | 235 | // if the generator method is present, |
236 | 236 | // the fake value is assigned. |
237 | - if(method_exists($this,$generatorMethodName)){ |
|
237 | + if (method_exists($this, $generatorMethodName)) { |
|
238 | 238 | |
239 | 239 | //fake registration |
240 | - if(!isset($this->inputs[$generator])){ |
|
240 | + if (!isset($this->inputs[$generator])) { |
|
241 | 241 | $this->{$generator} = $this->{$generatorMethodName}(); |
242 | 242 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
243 | 243 | } |
244 | 244 | else { |
245 | 245 | |
246 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
247 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
246 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
247 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
248 | 248 | $this->{$generator} = $this->{$generatorMethodName}(); |
249 | 249 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
250 | 250 | } |
251 | 251 | |
252 | - if($this->checkProperties('generators_dont_overwrite') |
|
253 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
252 | + if ($this->checkProperties('generators_dont_overwrite') |
|
253 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
254 | 254 | $this->{$generator} = $this->{$generatorMethodName}(); |
255 | 255 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
256 | 256 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | { |
298 | 298 | // we use the http method to write |
299 | 299 | // the values to the inputs and origin properties. |
300 | - foreach($this->requestHttp->resolve() as $key=>$value){ |
|
300 | + foreach ($this->requestHttp->resolve() as $key=>$value) { |
|
301 | 301 | |
302 | 302 | //inputs and origin properties |
303 | 303 | $this->inputs[$key] = $value; |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | |
342 | 342 | // we update the input values ββafter |
343 | 343 | // we receive and check the saved objects. |
344 | - foreach ($clientObjects as $key=>$value){ |
|
344 | + foreach ($clientObjects as $key=>$value) { |
|
345 | 345 | |
346 | - if(isset($clientObjects['origin'][$key])){ |
|
346 | + if (isset($clientObjects['origin'][$key])) { |
|
347 | 347 | |
348 | 348 | $this->{$key} = $clientObjects['origin'][$key]; |
349 | 349 | $this->inputs[$key] = $this->{$key}; |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | |
371 | 371 | // the request update to be performed using |
372 | 372 | // the method name to be used with the http method. |
373 | - $this->setRequestInputs($requestMethod,$key); |
|
373 | + $this->setRequestInputs($requestMethod, $key); |
|
374 | 374 | |
375 | 375 | // the request update to be performed using |
376 | 376 | // the method name to be used without the http method. |
377 | - $this->setRequestInputs($key,$key); |
|
377 | + $this->setRequestInputs($key, $key); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -385,28 +385,28 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @throws ReflectionExceptionAlias |
387 | 387 | */ |
388 | - private function setRequestInputs($method,$key) |
|
388 | + private function setRequestInputs($method, $key) |
|
389 | 389 | { |
390 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
390 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
391 | 391 | |
392 | 392 | //check annotations for method |
393 | - $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]); |
|
394 | - $annotation->annotation($method,$key); |
|
393 | + $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]); |
|
394 | + $annotation->annotation($method, $key); |
|
395 | 395 | |
396 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
396 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
397 | 397 | |
398 | 398 | $inputKeys = $this->inputs[$key]; |
399 | 399 | |
400 | 400 | $this->inputs[$key] = []; |
401 | - foreach ($inputKeys as $input){ |
|
401 | + foreach ($inputKeys as $input) { |
|
402 | 402 | |
403 | 403 | $this->{$key} = $input; |
404 | 404 | $keyMethod = $this->{$method}(); |
405 | 405 | $this->inputs[$key][] = $keyMethod; |
406 | 406 | } |
407 | 407 | } |
408 | - else{ |
|
409 | - if(isset($this->inputs[$key])){ |
|
408 | + else { |
|
409 | + if (isset($this->inputs[$key])) { |
|
410 | 410 | $keyMethod = $this->{$method}(); |
411 | 411 | $this->inputs[$key] = $keyMethod; |
412 | 412 | } |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | { |
425 | 425 | // the auto object validate property is the property |
426 | 426 | // where all of your request values ββare automatically validated. |
427 | - if(property_exists($this,'autoObjectValidate') |
|
428 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
427 | + if (property_exists($this, 'autoObjectValidate') |
|
428 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
429 | 429 | $this->autoValidate('autoObjectValidate'); |
430 | 430 | } |
431 | 431 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $exception = $this->exception; |
50 | 50 | |
51 | - if($this->app->has('exceptiontrace')) |
|
51 | + if ($this->app->has('exceptiontrace')) |
|
52 | 52 | { |
53 | 53 | $this->data['status'] = (int)$this->app['exceptiontrace']['callNamespace']->getCode(); |
54 | 54 | } |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | |
60 | 60 | $this->app->terminate('responseSuccess'); |
61 | 61 | $this->app->terminate('responseStatus'); |
62 | - $this->app->register('responseSuccess',(bool)false); |
|
63 | - $this->app->register('responseStatus',$this->data['status']); |
|
62 | + $this->app->register('responseSuccess', (bool)false); |
|
63 | + $this->app->register('responseStatus', $this->data['status']); |
|
64 | 64 | |
65 | 65 | |
66 | - $optionalException = str_replace("\\","\\\\",$this->app->namespace()->exception()); |
|
66 | + $optionalException = str_replace("\\", "\\\\", $this->app->namespace()->exception()); |
|
67 | 67 | |
68 | - if(preg_match('@'.$optionalException.'@is',$this->data['errType'])){ |
|
68 | + if (preg_match('@'.$optionalException.'@is', $this->data['errType'])) { |
|
69 | 69 | |
70 | 70 | //linux test |
71 | 71 | $trace = $this->data['errContext']['trace']; |
72 | - if(preg_match('@Stack trace:\n#0(.*)\n#1@is',$trace,$traceArray)){ |
|
72 | + if (preg_match('@Stack trace:\n#0(.*)\n#1@is', $trace, $traceArray)) { |
|
73 | 73 | |
74 | - $traceFile = str_replace(root,'',$traceArray[1]); |
|
74 | + $traceFile = str_replace(root, '', $traceArray[1]); |
|
75 | 75 | |
76 | - if(preg_match('@(.*)\((\d+)\)@is',$traceFile,$traceResolve)){ |
|
76 | + if (preg_match('@(.*)\((\d+)\)@is', $traceFile, $traceResolve)) { |
|
77 | 77 | $this->data['errFile'] = $traceResolve[1]; |
78 | 78 | $this->data['errLine'] = (int)$traceResolve[2]; |
79 | 79 | } |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | $this->data['errType'] = class_basename($this->data['errType']); |
84 | 84 | } |
85 | 85 | |
86 | - if(is_array($meta = config('response.meta'))){ |
|
86 | + if (is_array($meta = config('response.meta'))) { |
|
87 | 87 | |
88 | 88 | //set as the success object is false |
89 | 89 | $this->data['appExceptionSuccess'] = []; |
90 | 90 | } |
91 | - else{ |
|
91 | + else { |
|
92 | 92 | |
93 | 93 | //set as the success object is false |
94 | - $this->data['appExceptionSuccess'] = ['success'=>(bool)false,'status'=>$this->data['status']]; |
|
94 | + $this->data['appExceptionSuccess'] = ['success'=>(bool)false, 'status'=>$this->data['status']]; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | //This function can be used for defining your own way of handling errors during runtime, |
114 | 114 | //for example in applications in which you need to do cleanup of data/files when a critical error happens, |
115 | 115 | //or when you need to trigger an error under certain conditions (using trigger_error()). |
116 | - set_error_handler([$this,'setErrorHandler']); |
|
116 | + set_error_handler([$this, 'setErrorHandler']); |
|
117 | 117 | |
118 | 118 | //Registers a callback to be executed after script execution finishes or exit() is called. |
119 | 119 | //Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as |
120 | 120 | //they were registered. If you call exit() within one registered shutdown function, |
121 | 121 | //processing will stop completely and no other registered shutdown functions will be called. |
122 | - register_shutdown_function([$this,'fatalErrorShutdownHandler']); |
|
122 | + register_shutdown_function([$this, 'fatalErrorShutdownHandler']); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param null|string $errLine |
132 | 132 | * @param null|string $errContext |
133 | 133 | */ |
134 | - public function setErrorHandler($errNo=null, $errStr=null, $errFile=null, $errLine=null, $errContext=null) |
|
134 | + public function setErrorHandler($errNo = null, $errStr = null, $errFile = null, $errLine = null, $errContext = null) |
|
135 | 135 | { |
136 | 136 | // in case of a deficiency, |
137 | 137 | // we need to boot our general needs to be needed for the exception. |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | //get lang message for exception |
159 | 159 | $this->getLangMessageForException(); |
160 | 160 | |
161 | - if($this->app->has('exceptiontrace')){ |
|
161 | + if ($this->app->has('exceptiontrace')) { |
|
162 | 162 | |
163 | 163 | $customExceptionTrace = $this->app['exceptiontrace']; |
164 | 164 | $this->data['errFile'] = $customExceptionTrace['file']; |
@@ -167,38 +167,37 @@ discard block |
||
167 | 167 | |
168 | 168 | $environment = $this->getEnvironmentStatus(); |
169 | 169 | |
170 | - $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'','',$this->data['errFile']); |
|
170 | + $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'', '', $this->data['errFile']); |
|
171 | 171 | |
172 | - if(Str::startsWith($vendorDirectory,'vendor') |
|
173 | - && Str::startsWith($vendorDirectory,'vendor/php-resta')===false) |
|
172 | + if (Str::startsWith($vendorDirectory, 'vendor') |
|
173 | + && Str::startsWith($vendorDirectory, 'vendor/php-resta')===false) |
|
174 | 174 | { |
175 | 175 | $externalMessage = ($environment==="production") ? |
176 | - 'An unexpected external error has occurred' : |
|
177 | - $this->data['errStrReal']; |
|
176 | + 'An unexpected external error has occurred' : $this->data['errStrReal']; |
|
178 | 177 | |
179 | - $this->result = $this->getAppException($environment,$externalMessage); |
|
178 | + $this->result = $this->getAppException($environment, $externalMessage); |
|
180 | 179 | |
181 | 180 | |
182 | 181 | //Get or Set the HTTP response code |
183 | 182 | http_response_code(500); |
184 | 183 | $this->app->terminate('responseStatus'); |
185 | - $this->app->register('responseStatus',500); |
|
184 | + $this->app->register('responseStatus', 500); |
|
186 | 185 | |
187 | 186 | |
188 | 187 | } |
189 | - else{ |
|
188 | + else { |
|
190 | 189 | |
191 | - $this->result = $this->getAppException($environment,$this->data['errStrReal']); |
|
190 | + $this->result = $this->getAppException($environment, $this->data['errStrReal']); |
|
192 | 191 | |
193 | 192 | //Get or Set the HTTP response code |
194 | 193 | http_response_code($this->data['status']); |
195 | 194 | } |
196 | 195 | |
197 | 196 | |
198 | - if($environment==="production"){ |
|
197 | + if ($environment==="production") { |
|
199 | 198 | |
200 | - $productionLogMessage = $this->getAppException('local',$this->data['errStrReal']); |
|
201 | - $this->app->register('productionLogMessage',$this->app->get('out')->outputFormatter($productionLogMessage)); |
|
199 | + $productionLogMessage = $this->getAppException('local', $this->data['errStrReal']); |
|
200 | + $this->app->register('productionLogMessage', $this->app->get('out')->outputFormatter($productionLogMessage)); |
|
202 | 201 | } |
203 | 202 | |
204 | 203 | // exception extender The exception information |
@@ -207,15 +206,15 @@ discard block |
||
207 | 206 | |
208 | 207 | |
209 | 208 | //set json app exception |
210 | - $this->app->register('routerResult',$this->result); |
|
209 | + $this->app->register('routerResult', $this->result); |
|
211 | 210 | |
212 | 211 | $restaOutHandle = null; |
213 | 212 | |
214 | - if(!defined('responseApp')){ |
|
213 | + if (!defined('responseApp')) { |
|
215 | 214 | $restaOutHandle = $this->app->get('out')->handle(); |
216 | 215 | } |
217 | 216 | |
218 | - if($restaOutHandle===null){ |
|
217 | + if ($restaOutHandle===null) { |
|
219 | 218 | |
220 | 219 | //header set and symfony response call |
221 | 220 | header('Content-type:application/json;charset=utf-8'); |
@@ -223,7 +222,7 @@ discard block |
||
223 | 222 | echo json_encode($this->app->get('out')->outputFormatter($this->result)); |
224 | 223 | exit(); |
225 | 224 | } |
226 | - else{ |
|
225 | + else { |
|
227 | 226 | echo $restaOutHandle; |
228 | 227 | exit(); |
229 | 228 | } |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | * @param $environment |
234 | 233 | * @return mixed |
235 | 234 | */ |
236 | - private function getAppException($environment,$message) |
|
235 | + private function getAppException($environment, $message) |
|
237 | 236 | { |
238 | 237 | return $this->data['appExceptionSuccess']+$this->data['exception']::$environment( |
239 | 238 | $this->data['errNo'], |
@@ -268,13 +267,13 @@ discard block |
||
268 | 267 | |
269 | 268 | $this->inStackTrace($last_error); |
270 | 269 | |
271 | - if(!is_null($last_error)){ |
|
270 | + if (!is_null($last_error)) { |
|
272 | 271 | |
273 | - if(!defined('methodName')){ |
|
274 | - define('methodName',null); |
|
272 | + if (!defined('methodName')) { |
|
273 | + define('methodName', null); |
|
275 | 274 | } |
276 | 275 | |
277 | - if($this->app->has('exceptionFile')){ |
|
276 | + if ($this->app->has('exceptionFile')) { |
|
278 | 277 | $last_error['file'] = $this->app['exceptionFile']; |
279 | 278 | $last_error['line'] = $this->app['exceptionLine']; |
280 | 279 | } |
@@ -294,13 +293,13 @@ discard block |
||
294 | 293 | */ |
295 | 294 | public function inStackTrace($error) |
296 | 295 | { |
297 | - if($this->app->has('urlComponent')){ |
|
298 | - if(!preg_match('@'.$this->app['urlComponent']['project'].'@',$error['file']) |
|
299 | - && !$this->app->has('exceptionFile')){ |
|
300 | - if(preg_match('@ in\s(.*?)\n@is',$error['message'],$result)){ |
|
301 | - $errorMessage = explode(":",$result[1]); |
|
302 | - $this->app->register('exceptionFile',$errorMessage[0]); |
|
303 | - $this->app->register('exceptionLine',$errorMessage[1]); |
|
296 | + if ($this->app->has('urlComponent')) { |
|
297 | + if (!preg_match('@'.$this->app['urlComponent']['project'].'@', $error['file']) |
|
298 | + && !$this->app->has('exceptionFile')) { |
|
299 | + if (preg_match('@ in\s(.*?)\n@is', $error['message'], $result)) { |
|
300 | + $errorMessage = explode(":", $result[1]); |
|
301 | + $this->app->register('exceptionFile', $errorMessage[0]); |
|
302 | + $this->app->register('exceptionLine', $errorMessage[1]); |
|
304 | 303 | } |
305 | 304 | } |
306 | 305 | } |
@@ -313,33 +312,33 @@ discard block |
||
313 | 312 | { |
314 | 313 | $clone = clone $this; |
315 | 314 | |
316 | - if($this->app->has('exceptionTranslate')){ |
|
315 | + if ($this->app->has('exceptionTranslate')) { |
|
317 | 316 | |
318 | 317 | $langMessage = trans('exception.'.$this->app->get('exceptionTranslate')); |
319 | 318 | |
320 | - if(!is_null($langMessage) && $this->app->has('exceptionTranslateParams')){ |
|
319 | + if (!is_null($langMessage) && $this->app->has('exceptionTranslateParams')) { |
|
321 | 320 | |
322 | - if(count($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']])){ |
|
323 | - foreach ($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']] as $key=>$value){ |
|
321 | + if (count($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']])) { |
|
322 | + foreach ($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']] as $key=>$value) { |
|
324 | 323 | |
325 | 324 | $valueLangName = !is_null(trans('default.'.$value)) ? trans('default.'.$value) : $value; |
326 | - $langMessage=preg_replace('@\('.$key.'\)@is',$valueLangName,$langMessage); |
|
325 | + $langMessage = preg_replace('@\('.$key.'\)@is', $valueLangName, $langMessage); |
|
327 | 326 | } |
328 | 327 | } |
329 | 328 | } |
330 | 329 | |
331 | - if($langMessage!==null){ |
|
330 | + if ($langMessage!==null) { |
|
332 | 331 | $this->data['errStrReal'] = $langMessage; |
333 | 332 | } |
334 | 333 | } |
335 | 334 | |
336 | - if(class_exists($this->data['errorClassNamespace']) |
|
335 | + if (class_exists($this->data['errorClassNamespace']) |
|
337 | 336 | && |
338 | - (Str::startsWith($this->data['errorClassNamespace'],'App') |
|
339 | - || Str::startsWith($this->data['errorClassNamespace'],__NAMESPACE__))){ |
|
337 | + (Str::startsWith($this->data['errorClassNamespace'], 'App') |
|
338 | + || Str::startsWith($this->data['errorClassNamespace'], __NAMESPACE__))) { |
|
340 | 339 | |
341 | 340 | ClosureDispatcher::bind($this->data['errorClassNamespace'])->call(function() use ($clone) { |
342 | - if(property_exists($this,'lang')){ |
|
341 | + if (property_exists($this, 'lang')) { |
|
343 | 342 | $clone->lang = $this->lang; |
344 | 343 | } |
345 | 344 | }); |
@@ -347,15 +346,15 @@ discard block |
||
347 | 346 | |
348 | 347 | $this->data['lang'] = $lang = $clone->lang; |
349 | 348 | |
350 | - if($lang!==null){ |
|
349 | + if ($lang!==null) { |
|
351 | 350 | $langMessage = trans('exception.'.$lang); |
352 | 351 | } |
353 | - else{ |
|
352 | + else { |
|
354 | 353 | $langMessage = null; |
355 | 354 | } |
356 | 355 | |
357 | 356 | |
358 | - if($langMessage!==null){ |
|
357 | + if ($langMessage!==null) { |
|
359 | 358 | $this->data['errStrReal'] = $langMessage; |
360 | 359 | } |
361 | 360 | } |
@@ -369,21 +368,21 @@ discard block |
||
369 | 368 | { |
370 | 369 | // catch exception via preg match |
371 | 370 | // and then clear the Uncaught statement from inside. |
372 | - if(preg_match('@(.*?):@is',$this->data['errStrReal'],$errArr)){ |
|
371 | + if (preg_match('@(.*?):@is', $this->data['errStrReal'], $errArr)) { |
|
373 | 372 | |
374 | - $this->data['errType']=trim(str_replace('Uncaught','',$errArr[1])); |
|
375 | - $this->data['errorClassNamespace']=$this->data['errType']; |
|
373 | + $this->data['errType'] = trim(str_replace('Uncaught', '', $errArr[1])); |
|
374 | + $this->data['errorClassNamespace'] = $this->data['errType']; |
|
376 | 375 | } |
377 | 376 | |
378 | - if(preg_match('@Uncaught@is',$this->data['errStrReal']) |
|
379 | - && preg_match('@(.*?):(.*?)\sin\s@is',$this->data['errStrReal'],$errStrRealArray)){ |
|
380 | - $this->data['errStrReal']=trim($errStrRealArray[2]); |
|
377 | + if (preg_match('@Uncaught@is', $this->data['errStrReal']) |
|
378 | + && preg_match('@(.*?):(.*?)\sin\s@is', $this->data['errStrReal'], $errStrRealArray)) { |
|
379 | + $this->data['errStrReal'] = trim($errStrRealArray[2]); |
|
381 | 380 | } |
382 | 381 | |
383 | - if($this->data['errType']==="Undefined"){ |
|
382 | + if ($this->data['errType']==="Undefined") { |
|
384 | 383 | $this->data['errStrReal'] = $this->data['errStrReal']; |
385 | 384 | } |
386 | - else{ |
|
385 | + else { |
|
387 | 386 | $this->data['errContext']['trace'] = $this->data['errStrReal']; |
388 | 387 | } |
389 | 388 | } |