Passed
Push — master ( 54baf2...00d2da )
by Php Easy Api
06:27
created
src/resta/Request/Request.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         // if we leave the request process to the application side,
59 59
         // then in this case we refer to the requestClient object in
60 60
         // the services section of the store directory.
61
-        (property_exists($this,'app') && $this->app) ? parent::handle() : $this->handle();
61
+        (property_exists($this, 'app') && $this->app) ? parent::handle() : $this->handle();
62 62
     }
63 63
 
64 64
     /**
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
      */
69 69
     private function autoValidate($validate)
70 70
     {
71
-        foreach ($this->{$validate} as $object=>$datas){
72
-            if(Utils::isNamespaceExists($object)){
71
+        foreach ($this->{$validate} as $object=>$datas) {
72
+            if (Utils::isNamespaceExists($object)) {
73 73
                 $getObjectInstance = app()->resolve($object);
74
-                foreach ($datas as $dataKey=>$data){
75
-                    if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
76
-                        if(isset($this->origin[$data])){
77
-                            if(!is_array($this->origin[$data])){
74
+                foreach ($datas as $dataKey=>$data) {
75
+                    if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
76
+                        if (isset($this->origin[$data])) {
77
+                            if (!is_array($this->origin[$data])) {
78 78
                                 $this->origin[$data] = array($this->origin[$data]);
79 79
                             }
80
-                            foreach ($this->origin[$data] as $originData){
80
+                            foreach ($this->origin[$data] as $originData) {
81 81
                                 $getObjectInstance->{$data}($originData);
82 82
                             }
83 83
                         }
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 
100 100
         // Determines which HTTP method
101 101
         // the request object will be exposed to.
102
-        if($this->checkProperties('http')){
102
+        if ($this->checkProperties('http')) {
103 103
 
104 104
             // if the current http method does not exist
105 105
             // in the http object, the exception will be thrown.
106
-            if(!in_array($method,$this->http)){
106
+            if (!in_array($method, $this->http)) {
107 107
 
108 108
                 //exception batMethodCall
109 109
                 exception()->badMethodCall(
110
-                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
110
+                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
111 111
             }
112 112
         }
113 113
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         // from the properties of the object properties to
124 124
         // the existing variables, control the array and at least one element.
125
-        return (property_exists($this,$properties)
125
+        return (property_exists($this, $properties)
126 126
             && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
127 127
     }
128 128
 
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
     public function except($except)
136 136
     {
137 137
         // the except parameter is a callable value.
138
-        if(is_callable($except)){
139
-            $call = call_user_func_array($except,[$this]);
138
+        if (is_callable($except)) {
139
+            $call = call_user_func_array($except, [$this]);
140 140
             $except = $call;
141 141
         }
142 142
 
143 143
         // except with the except exceptions property
144 144
         // and then assigning them to the inputs property.
145
-        $this->except = array_merge($this->except,$except);
146
-        $this->inputs = array_diff_key($this->inputs,array_flip($this->except));
145
+        $this->except = array_merge($this->except, $except);
146
+        $this->inputs = array_diff_key($this->inputs, array_flip($this->except));
147 147
 
148 148
         return $this;
149 149
     }
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
     {
158 158
         // expected method is executed.
159 159
         // this method is a must for http method values to be found in this property.
160
-        if($this->checkProperties('expected')){
160
+        if ($this->checkProperties('expected')) {
161 161
 
162 162
             // we are saving the expected values ​​for the request in container.
163 163
             // this record can be returned in exception information.
164
-            app()->register('request.expected',$this->expected);
164
+            app()->register('request.expected', $this->expected);
165 165
 
166 166
             // if the expected values are not found in the inputs array,
167 167
             // the exception will be thrown.
168
-            foreach ($this->expected as $expected){
169
-                if(!isset($this->inputs[$expected])){
168
+            foreach ($this->expected as $expected) {
169
+                if (!isset($this->inputs[$expected])) {
170 170
                     exception()->unexpectedValue('You absolutely have to send the value '.$expected.' for request object');
171 171
                 }
172 172
             }
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
     {
183 183
         // check the presence of the generator object
184 184
         // and operate the generator over this object.
185
-        if($this->checkProperties('auto_generators')){
185
+        if ($this->checkProperties('auto_generators')) {
186 186
             $generators = $this->auto_generators;
187 187
         }
188 188
 
189 189
         // check the presence of the generator object
190 190
         // and operate the generator over this object.
191
-        if($this->checkProperties('generators')){
192
-            $generators = array_merge(isset($generators) ? $generators: [],$this->generators);
191
+        if ($this->checkProperties('generators')) {
192
+            $generators = array_merge(isset($generators) ? $generators : [], $this->generators);
193 193
         }
194 194
 
195
-        if(isset($generators)){
195
+        if (isset($generators)) {
196 196
             $this->generatorMethod($generators);
197 197
         }
198 198
     }
@@ -205,30 +205,30 @@  discard block
 block discarded – undo
205 205
     private function generatorMethod($generators)
206 206
     {
207 207
         //generator array object
208
-        foreach ($generators as $generator){
208
+        foreach ($generators as $generator) {
209 209
 
210 210
             //generator method name
211 211
             $generatorMethodName = $generator.'Generator';
212 212
 
213 213
             // if the generator method is present,
214 214
             // the fake value is assigned.
215
-            if(method_exists($this,$generatorMethodName)){
215
+            if (method_exists($this, $generatorMethodName)) {
216 216
 
217 217
                 //fake registration
218
-                if(!isset($this->inputs[$generator])){
218
+                if (!isset($this->inputs[$generator])) {
219 219
                     $this->{$generator} = $this->{$generatorMethodName}();
220 220
                     $this->inputs[$generator] = $this->{$generatorMethodName}();
221 221
                 }
222 222
                 else {
223 223
 
224
-                    if($this->checkProperties('auto_generators_dont_overwrite')
225
-                        && in_array($generator,$this->auto_generators_dont_overwrite)){
224
+                    if ($this->checkProperties('auto_generators_dont_overwrite')
225
+                        && in_array($generator, $this->auto_generators_dont_overwrite)) {
226 226
                         $this->{$generator} = $this->{$generatorMethodName}();
227 227
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
228 228
                     }
229 229
 
230
-                    if($this->checkProperties('generators_dont_overwrite')
231
-                        && in_array($generator,$this->generators_dont_overwrite)){
230
+                    if ($this->checkProperties('generators_dont_overwrite')
231
+                        && in_array($generator, $this->generators_dont_overwrite)) {
232 232
                         $this->{$generator} = $this->{$generatorMethodName}();
233 233
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
234 234
                     }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     private function getClientObjects()
259 259
     {
260
-        return array_diff_key($this->getObjects(),['inputs'=>[]]);
260
+        return array_diff_key($this->getObjects(), ['inputs'=>[]]);
261 261
     }
262 262
 
263 263
     /**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         // we use the http method to write
302 302
         // the values to the inputs and origin properties.
303
-        foreach($this->requestHttp->resolve() as $key=>$value){
303
+        foreach ($this->requestHttp->resolve() as $key=>$value) {
304 304
 
305 305
             //inputs and origin properties
306 306
             $this->inputs[$key] = $value;
@@ -316,68 +316,68 @@  discard block
 block discarded – undo
316 316
      *
317 317
      * @throws \ReflectionException
318 318
      */
319
-    private function checkAnnotations($method,$key)
319
+    private function checkAnnotations($method, $key)
320 320
     {
321 321
         $reflection = $this->reflection->reflectionMethodParams($method);
322 322
         $annotation = $reflection->document;
323 323
 
324 324
         $exceptionParamList = [];
325 325
 
326
-        if(preg_match('@exception\((.*?)\)\r\n@is',$annotation,$exception)){
326
+        if (preg_match('@exception\((.*?)\)\r\n@is', $annotation, $exception)) {
327 327
 
328
-            $exceptionSpaceExplode = explode(" ",$exception[1]);
329
-            foreach ($exceptionSpaceExplode as $exceptions){
330
-                $exceptionsDotExplode = explode(":",$exceptions);
328
+            $exceptionSpaceExplode = explode(" ", $exception[1]);
329
+            foreach ($exceptionSpaceExplode as $exceptions) {
330
+                $exceptionsDotExplode = explode(":", $exceptions);
331 331
                 $exceptionParamList[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1];
332 332
             }
333 333
 
334
-            if(isset($exceptionParamList[$key]['params'])){
335
-                $paramsCommaExplode = explode(",",$exceptionParamList[$key]['params']);
334
+            if (isset($exceptionParamList[$key]['params'])) {
335
+                $paramsCommaExplode = explode(",", $exceptionParamList[$key]['params']);
336 336
                 unset($exceptionParamList[$key]['params']);
337
-                foreach ($paramsCommaExplode as $params){
338
-                    $paramsEqualExplode = explode("=",$params);
339
-                    if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
337
+                foreach ($paramsCommaExplode as $params) {
338
+                    $paramsEqualExplode = explode("=", $params);
339
+                    if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
340 340
                         $exceptionParamList[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1];
341 341
                     }
342 342
                 }
343 343
             }
344 344
         }
345 345
 
346
-        if(preg_match('@remove\((.*?)\)\r\n@is',$annotation,$remove)){
347
-            if(isset($this->inputs[$key])){
348
-                if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
346
+        if (preg_match('@remove\((.*?)\)\r\n@is', $annotation, $remove)) {
347
+            if (isset($this->inputs[$key])) {
348
+                if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
349 349
                     unset($this->inputs[$key]);
350 350
                 }
351 351
             }
352 352
         }
353 353
 
354
-        if(preg_match('@regex\((.*?)\)\r\n@is',$annotation,$regex)){
355
-            if(isset($this->inputs[$key])){
354
+        if (preg_match('@regex\((.*?)\)\r\n@is', $annotation, $regex)) {
355
+            if (isset($this->inputs[$key])) {
356 356
 
357
-                if(is_array($this->inputs[$key])){
357
+                if (is_array($this->inputs[$key])) {
358 358
 
359
-                    foreach ($this->inputs[$key] as $inputKey=>$inputValue){
359
+                    foreach ($this->inputs[$key] as $inputKey=>$inputValue) {
360 360
 
361
-                        if(!preg_match('@'.$regex[1].'@is',$inputValue)){
362
-                            if(isset($exceptionParamList[$key])){
361
+                        if (!preg_match('@'.$regex[1].'@is', $inputValue)) {
362
+                            if (isset($exceptionParamList[$key])) {
363 363
                                 $keyParams = ($exceptionParamList[$key]['params']) ?? [];
364
-                                exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
364
+                                exception($exceptionParamList[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
365 365
                             }
366
-                            else{
366
+                            else {
367 367
                                 exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
368 368
                             }
369 369
                         }
370 370
                     }
371 371
 
372 372
                 }
373
-                else{
373
+                else {
374 374
 
375
-                    if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
376
-                        if(isset($exceptionParamList[$key])){
375
+                    if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
376
+                        if (isset($exceptionParamList[$key])) {
377 377
                             $keyParams = ($exceptionParamList[$key]['params']) ?? [];
378
-                            exception($exceptionParamList[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
378
+                            exception($exceptionParamList[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
379 379
                         }
380
-                        else{
380
+                        else {
381 381
                             exception()->unexpectedValue($key.' input value is not valid as format ('.$regex[1].')');
382 382
                         }
383 383
                     }
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 
424 424
         // we update the input values ​​after
425 425
         // we receive and check the saved objects.
426
-        foreach ($clientObjects as $key=>$value){
426
+        foreach ($clientObjects as $key=>$value) {
427 427
 
428
-            if(isset($clientObjects['origin'][$key])){
428
+            if (isset($clientObjects['origin'][$key])) {
429 429
 
430 430
                 $this->{$key} = $clientObjects['origin'][$key];
431 431
                 $this->inputs[$key] = $this->{$key};
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 
451 451
         // the request update to be performed using
452 452
         // the method name to be used with the http method.
453
-        $this->setRequestInputs($requestMethod,$key);
453
+        $this->setRequestInputs($requestMethod, $key);
454 454
 
455 455
         // the request update to be performed using
456 456
         // the method name to be used without the http method.
457
-        $this->setRequestInputs($key,$key);
457
+        $this->setRequestInputs($key, $key);
458 458
     }
459 459
 
460 460
     /**
@@ -463,27 +463,27 @@  discard block
 block discarded – undo
463 463
      * @param $method
464 464
      * @param $key
465 465
      */
466
-    private function setRequestInputs($method,$key)
466
+    private function setRequestInputs($method, $key)
467 467
     {
468
-        if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
468
+        if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
469 469
 
470 470
             //check annotations for method
471
-            $this->checkAnnotations($method,$key);
471
+            $this->checkAnnotations($method, $key);
472 472
 
473
-            if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
473
+            if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
474 474
 
475 475
                 $inputKeys = $this->inputs[$key];
476 476
 
477 477
                 $this->inputs[$key] = [];
478
-                foreach ($inputKeys as $input){
478
+                foreach ($inputKeys as $input) {
479 479
 
480 480
                     $this->{$key}           = $input;
481 481
                     $keyMethod              = $this->{$method}();
482 482
                     $this->inputs[$key][]   = $keyMethod;
483 483
                 }
484 484
             }
485
-            else{
486
-                if(isset($this->inputs[$key])){
485
+            else {
486
+                if (isset($this->inputs[$key])) {
487 487
                     $keyMethod = $this->{$method}();
488 488
                     $this->inputs[$key] = $keyMethod;
489 489
                 }
@@ -499,22 +499,22 @@  discard block
 block discarded – undo
499 499
      */
500 500
     private function validation()
501 501
     {
502
-        if(property_exists($this,'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
502
+        if (property_exists($this, 'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
503 503
             $this->autoValidate('autoObjectValidate');
504 504
         }
505 505
         // we need to find the rule method
506 506
         // because we can not validate it.
507
-        if(method_exists($this,'rule')){
507
+        if (method_exists($this, 'rule')) {
508 508
             $this->rule();
509 509
         }
510 510
 
511 511
         // if we only want to make a rule of
512 512
         // the specified request object, we will use
513 513
         // the rule method with the prefix of the request object.
514
-        $validName=strtolower(str_replace('Request','',class_basename($this))).'Rule';
514
+        $validName = strtolower(str_replace('Request', '', class_basename($this))).'Rule';
515 515
 
516 516
         //if the specified method exists;
517
-        if(method_exists($this,$validName)){
517
+        if (method_exists($this, $validName)) {
518 518
             $this->{$validName}();
519 519
         }
520 520
     }
Please login to merge, or discard this patch.
src/resta/Exception/ErrorProvider.php 1 patch
Spacing   +89 added lines, -90 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @var $data array
26 26
      */
27
-    protected $data=array();
27
+    protected $data = array();
28 28
 
29 29
     /**
30 30
      * @return mixed|string
31 31
      */
32
-    private function getEnvironmentStatus(){
32
+    private function getEnvironmentStatus() {
33 33
 
34 34
         // application key, but if it has a null value
35 35
         // then we move the environment value to the production environment.
@@ -39,41 +39,41 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * @return void|mixed
41 41
      */
42
-    private function getStatusFromContext(){
42
+    private function getStatusFromContext() {
43 43
 
44
-        $exception=$this->exception;
44
+        $exception = $this->exception;
45 45
 
46
-        if(isset(core()->exceptiontrace))
46
+        if (isset(core()->exceptiontrace))
47 47
         {
48 48
             $this->data['status'] = (int)core()->exceptiontrace['callNamespace']->getCode();
49 49
         }
50 50
         else {
51 51
 
52
-            $this->data['status']=(int)$exception::exceptionTypeCodes($this->data['errType']);
52
+            $this->data['status'] = (int)$exception::exceptionTypeCodes($this->data['errType']);
53 53
         }
54 54
 
55 55
         $this->app->terminate('responseSuccess');
56 56
         $this->app->terminate('responseStatus');
57
-        $this->app->register('responseSuccess',(bool)false);
58
-        $this->app->register('responseStatus',$this->data['status']);
57
+        $this->app->register('responseSuccess', (bool)false);
58
+        $this->app->register('responseStatus', $this->data['status']);
59 59
 
60 60
 
61
-        $optionalException=str_replace("\\","\\\\",$this->app->namespace()->exception());
61
+        $optionalException = str_replace("\\", "\\\\", $this->app->namespace()->exception());
62 62
 
63
-        if(preg_match('@'.$optionalException.'@is',$this->data['errType'])){
63
+        if (preg_match('@'.$optionalException.'@is', $this->data['errType'])) {
64 64
 
65 65
             //linux test
66
-            $trace=$this->data['errContext']['trace'];
67
-            if(preg_match('@Stack trace:\n#0(.*)\n#1@is',$trace,$traceArray)){
68
-                $traceFile=str_replace(root,'',$traceArray[1]);
69
-                if(preg_match('@(.*)\((\d+)\)@is',$traceFile,$traceResolve)){
70
-                    $this->data['errFile']=$traceResolve[1];
71
-                    $this->data['errLine']=(int)$traceResolve[2];
66
+            $trace = $this->data['errContext']['trace'];
67
+            if (preg_match('@Stack trace:\n#0(.*)\n#1@is', $trace, $traceArray)) {
68
+                $traceFile = str_replace(root, '', $traceArray[1]);
69
+                if (preg_match('@(.*)\((\d+)\)@is', $traceFile, $traceResolve)) {
70
+                    $this->data['errFile'] = $traceResolve[1];
71
+                    $this->data['errLine'] = (int)$traceResolve[2];
72 72
                 }
73 73
             }
74 74
 
75 75
 
76
-            $this->data['errType']=class_basename($this->data['errType']);
76
+            $this->data['errType'] = class_basename($this->data['errType']);
77 77
         }
78 78
     }
79 79
 
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
         // in general we will use the exception class
90 90
         // in the store/config directory to make it possible
91 91
         // to change the user-based exceptions.
92
-        $this->exception=StaticPathModel::$store.'\Config\Exception';
92
+        $this->exception = StaticPathModel::$store.'\Config\Exception';
93 93
 
94 94
         //This function can be used for defining your own way of handling errors during runtime,
95 95
         //for example in applications in which you need to do cleanup of data/files when a critical error happens,
96 96
         //or when you need to trigger an error under certain conditions (using trigger_error()).
97
-        set_error_handler([$this,'setErrorHandler']);
97
+        set_error_handler([$this, 'setErrorHandler']);
98 98
 
99 99
         //Registers a callback to be executed after script execution finishes or exit() is called.
100 100
         //Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as
101 101
         //they were registered. If you call exit() within one registered shutdown function,
102 102
         //processing will stop completely and no other registered shutdown functions will be called.
103
-        register_shutdown_function([$this,'fatalErrorShutdownHandler']);
103
+        register_shutdown_function([$this, 'fatalErrorShutdownHandler']);
104 104
     }
105 105
 
106 106
     /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param null $errLine
111 111
      * @param null $errContext
112 112
      */
113
-    public function setErrorHandler($errNo=null, $errStr=null, $errFile=null, $errLine=null, $errContext=null)
113
+    public function setErrorHandler($errNo = null, $errStr = null, $errFile = null, $errLine = null, $errContext = null)
114 114
     {
115 115
         // in case of a deficiency,
116 116
         // we need to boot our general needs to be needed for the exception.
@@ -135,79 +135,78 @@  discard block
 block discarded – undo
135 135
 
136 136
         $this->getStatusFromContext();
137 137
 
138
-        if(is_array($meta=config('response.meta'))){
138
+        if (is_array($meta = config('response.meta'))) {
139 139
 
140 140
             //set as the success object is false
141
-            $this->data['appExceptionSuccess']=[];
141
+            $this->data['appExceptionSuccess'] = [];
142 142
         }
143
-        else{
143
+        else {
144 144
 
145 145
             //set as the success object is false
146
-            $this->data['appExceptionSuccess']=['success'=>(bool)false,'status'=>$this->data['status']];
146
+            $this->data['appExceptionSuccess'] = ['success'=>(bool)false, 'status'=>$this->data['status']];
147 147
         }
148 148
 
149 149
         //get lang message for exception
150 150
         $this->getLangMessageForException();
151 151
 
152
-        if(property_exists(core(),'exceptiontrace')){
152
+        if (property_exists(core(), 'exceptiontrace')) {
153 153
 
154
-            $customExceptionTrace=core()->exceptiontrace;
155
-            $this->data['errFile']=$customExceptionTrace['file'];
156
-            $this->data['errLine']=$customExceptionTrace['line'];
154
+            $customExceptionTrace = core()->exceptiontrace;
155
+            $this->data['errFile'] = $customExceptionTrace['file'];
156
+            $this->data['errLine'] = $customExceptionTrace['line'];
157 157
         }
158 158
 
159 159
         $environment = $this->getEnvironmentStatus();
160 160
 
161
-        $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'','',$this->data['errFile']);
161
+        $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'', '', $this->data['errFile']);
162 162
 
163
-        if(Str::startsWith($vendorDirectory,'vendor')
164
-            && Str::startsWith($vendorDirectory,'vendor/php-resta')===false)
163
+        if (Str::startsWith($vendorDirectory, 'vendor')
164
+            && Str::startsWith($vendorDirectory, 'vendor/php-resta')===false)
165 165
         {
166 166
             $externalMessage = ($environment==="production") ?
167
-                'An unexpected external error has occurred' :
168
-                $this->data['errStrReal'];
167
+                'An unexpected external error has occurred' : $this->data['errStrReal'];
169 168
 
170
-            $appException=$this->getAppException($environment,$externalMessage);
169
+            $appException = $this->getAppException($environment, $externalMessage);
171 170
 
172 171
 
173 172
             //Get or Set the HTTP response code
174 173
             http_response_code(500);
175 174
             $this->app->terminate('responseStatus');
176
-            $this->app->register('responseStatus',500);
175
+            $this->app->register('responseStatus', 500);
177 176
 
178 177
 
179 178
         }
180
-        else{
179
+        else {
181 180
 
182
-            $appException=$this->getAppException($environment,$this->data['errStrReal']);
181
+            $appException = $this->getAppException($environment, $this->data['errStrReal']);
183 182
 
184 183
             //Get or Set the HTTP response code
185 184
             http_response_code($this->data['status']);
186 185
         }
187 186
 
188 187
 
189
-        if($environment==="production"){
188
+        if ($environment==="production") {
190 189
 
191
-            $productionLogMessage = $this->getAppException('local',$this->data['errStrReal']);
192
-            $this->app->register('productionLogMessage',core()->out->outputFormatter($productionLogMessage));
190
+            $productionLogMessage = $this->getAppException('local', $this->data['errStrReal']);
191
+            $this->app->register('productionLogMessage', core()->out->outputFormatter($productionLogMessage));
193 192
         }
194 193
 
195
-        if(app()->has('requestExpected') && config('app.requestWithError')===true){
194
+        if (app()->has('requestExpected') && config('app.requestWithError')===true) {
196 195
             $appException['request']['expected'] = app()->get('requestExpected');
197 196
         }
198 197
 
199 198
 
200 199
         //set json app exception
201
-        core()->routerResult=$appException;
200
+        core()->routerResult = $appException;
202 201
 
203 202
         $restaOutHandle = null;
204 203
 
205
-        if(!defined('responseApp')){
204
+        if (!defined('responseApp')) {
206 205
 
207
-            $restaOutHandle=core()->out->handle();
206
+            $restaOutHandle = core()->out->handle();
208 207
         }
209 208
 
210
-        if($restaOutHandle===null){
209
+        if ($restaOutHandle===null) {
211 210
 
212 211
             //header set and symfony response call
213 212
             header('Content-type:application/json;charset=utf-8');
@@ -215,7 +214,7 @@  discard block
 block discarded – undo
215 214
             echo json_encode(core()->out->outputFormatter($appException));
216 215
             exit();
217 216
         }
218
-        else{
217
+        else {
219 218
             echo $restaOutHandle;
220 219
             exit();
221 220
         }
@@ -226,7 +225,7 @@  discard block
 block discarded – undo
226 225
      * @param $environment
227 226
      * @return mixed
228 227
      */
229
-    private function getAppException($environment,$message)
228
+    private function getAppException($environment, $message)
230 229
     {
231 230
         return $this->data['appExceptionSuccess']+$this->data['exception']::$environment(
232 231
             $this->data['errNo'],
@@ -244,18 +243,18 @@  discard block
 block discarded – undo
244 243
     public function fatalErrorShutdownHandler()
245 244
     {
246 245
         //get fatal error
247
-        $last_error =error_get_last();
246
+        $last_error = error_get_last();
248 247
 
249 248
         $this->inStactTrace($last_error);
250 249
 
251
-        if($last_error!==null){
250
+        if ($last_error!==null) {
252 251
 
253
-            if(!defined('methodName')){
252
+            if (!defined('methodName')) {
254 253
 
255
-                define('methodName',null);
254
+                define('methodName', null);
256 255
             }
257 256
 
258
-            if(isset(core()->exceptionFile)){
257
+            if (isset(core()->exceptionFile)) {
259 258
                 $last_error['file'] = core()->exceptionFile;
260 259
                 $last_error['line'] = core()->exceptionLine;
261 260
             }
@@ -275,12 +274,12 @@  discard block
 block discarded – undo
275 274
      */
276 275
     public function inStactTrace($error)
277 276
     {
278
-        if(isset(core()->urlComponent)){
279
-            if(!preg_match('@'.core()->urlComponent['project'].'@',$error['file']) && !isset(core()->exceptionFile)){
280
-                if(preg_match('@ in\s(.*?)\n@is',$error['message'],$result)){
281
-                    $errorMessage = explode(":",$result[1]);
282
-                    $this->app->register('exceptionFile',$errorMessage[0]);
283
-                    $this->app->register('exceptionLine',$errorMessage[1]);
277
+        if (isset(core()->urlComponent)) {
278
+            if (!preg_match('@'.core()->urlComponent['project'].'@', $error['file']) && !isset(core()->exceptionFile)) {
279
+                if (preg_match('@ in\s(.*?)\n@is', $error['message'], $result)) {
280
+                    $errorMessage = explode(":", $result[1]);
281
+                    $this->app->register('exceptionFile', $errorMessage[0]);
282
+                    $this->app->register('exceptionLine', $errorMessage[1]);
284 283
                 }
285 284
             }
286 285
         }
@@ -289,76 +288,76 @@  discard block
 block discarded – undo
289 288
     /**
290 289
      * @return void|mixed
291 290
      */
292
-    private function getLangMessageForException(){
291
+    private function getLangMessageForException() {
293 292
 
294 293
         $clone = clone $this;
295 294
 
296
-        if(property_exists(core(),'exceptionTranslate')){
295
+        if (property_exists(core(), 'exceptionTranslate')) {
297 296
 
298
-            $langMessage=trans('exception.'.core()->exceptionTranslate);
297
+            $langMessage = trans('exception.'.core()->exceptionTranslate);
299 298
 
300
-            if(property_exists(core(),'exceptionTranslateParams')){
299
+            if (property_exists(core(), 'exceptionTranslateParams')) {
301 300
 
302
-                if(count(core()->exceptionTranslateParams[core()->exceptionTranslate])){
303
-                    foreach (core()->exceptionTranslateParams[core()->exceptionTranslate] as $key=>$value){
304
-                        $langMessage=preg_replace('@\('.$key.'\)@is',$value,$langMessage);
301
+                if (count(core()->exceptionTranslateParams[core()->exceptionTranslate])) {
302
+                    foreach (core()->exceptionTranslateParams[core()->exceptionTranslate] as $key=>$value) {
303
+                        $langMessage = preg_replace('@\('.$key.'\)@is', $value, $langMessage);
305 304
                     }
306 305
                 }
307 306
             }
308 307
 
309
-            if($langMessage!==null){
310
-                $this->data['errStrReal']=$langMessage;
308
+            if ($langMessage!==null) {
309
+                $this->data['errStrReal'] = $langMessage;
311 310
             }
312 311
         }
313 312
 
314
-        if(class_exists($this->data['errorClassNamespace'])
315
-            && Str::startsWith($this->data['errorClassNamespace'],'App')){
313
+        if (class_exists($this->data['errorClassNamespace'])
314
+            && Str::startsWith($this->data['errorClassNamespace'], 'App')) {
316 315
 
317 316
             ClosureDispatcher::bind($this->data['errorClassNamespace'])->call(function() use ($clone) {
318
-                if(property_exists($this,'lang')){
319
-                    $clone->lang=$this->lang;
317
+                if (property_exists($this, 'lang')) {
318
+                    $clone->lang = $this->lang;
320 319
                 }
321 320
             });
322 321
         }
323 322
 
324
-        $this->data['lang']=$lang=$clone->lang;
323
+        $this->data['lang'] = $lang = $clone->lang;
325 324
 
326
-        if($lang!==null){
327
-            $langMessage=trans('exception.'.$lang);
325
+        if ($lang!==null) {
326
+            $langMessage = trans('exception.'.$lang);
328 327
         }
329
-        else{
330
-            $langMessage=null;
328
+        else {
329
+            $langMessage = null;
331 330
         }
332 331
 
333 332
 
334
-        if($langMessage!==null){
335
-            $this->data['errStrReal']=$langMessage;
333
+        if ($langMessage!==null) {
334
+            $this->data['errStrReal'] = $langMessage;
336 335
         }
337 336
     }
338 337
 
339 338
     /**
340 339
      * @return void|mixed
341 340
      */
342
-    private function getUncaughtProcess(){
341
+    private function getUncaughtProcess() {
343 342
 
344 343
         // catch exception via preg match
345 344
         // and then clear the Uncaught statement from inside.
346
-        if(preg_match('@(.*?):@is',$this->data['errStrReal'],$errArr)){
345
+        if (preg_match('@(.*?):@is', $this->data['errStrReal'], $errArr)) {
347 346
 
348
-            $this->data['errType']=trim(str_replace('Uncaught','',$errArr[1]));
349
-            $this->data['errorClassNamespace']=$this->data['errType'];
347
+            $this->data['errType'] = trim(str_replace('Uncaught', '', $errArr[1]));
348
+            $this->data['errorClassNamespace'] = $this->data['errType'];
350 349
         }
351 350
 
352
-        if(preg_match('@Uncaught@is',$this->data['errStrReal'])
353
-            && preg_match('@(.*?):(.*?)\sin\s@is',$this->data['errStrReal'],$errStrRealArray)){
354
-            $this->data['errStrReal']=trim($errStrRealArray[2]);
351
+        if (preg_match('@Uncaught@is', $this->data['errStrReal'])
352
+            && preg_match('@(.*?):(.*?)\sin\s@is', $this->data['errStrReal'], $errStrRealArray)) {
353
+            $this->data['errStrReal'] = trim($errStrRealArray[2]);
355 354
         }
356 355
 
357
-        if($this->data['errType']==="Undefined"){
358
-            $this->data['errStrReal']=$this->data['errStrReal'];
356
+        if ($this->data['errType']==="Undefined") {
357
+            $this->data['errStrReal'] = $this->data['errStrReal'];
359 358
         }
360
-        else{
361
-            $this->data['errContext']['trace']=$this->data['errStrReal'];
359
+        else {
360
+            $this->data['errContext']['trace'] = $this->data['errStrReal'];
362 361
         }
363 362
     }
364 363
 
Please login to merge, or discard this patch.