@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param ApplicationContracts $app |
| 22 | 22 | * @param $request |
| 23 | 23 | */ |
| 24 | - public function __construct(ApplicationContracts $app,$request) |
|
| 24 | + public function __construct(ApplicationContracts $app, $request) |
|
| 25 | 25 | {
|
| 26 | 26 | parent::__construct($app); |
| 27 | 27 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param $key |
| 38 | 38 | * @return mixed|void |
| 39 | 39 | */ |
| 40 | - public function annotation($method,$key) |
|
| 40 | + public function annotation($method, $key) |
|
| 41 | 41 | {
|
| 42 | 42 | //set annotation value with getting reflection |
| 43 | 43 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
|
@@ -62,18 +62,18 @@ discard block |
||
| 62 | 62 | * @param string $key |
| 63 | 63 | * @param null|string $data |
| 64 | 64 | */ |
| 65 | - private function catchException($key,$data) |
|
| 65 | + private function catchException($key, $data) |
|
| 66 | 66 | {
|
| 67 | - if(isset($this->exceptionParams[$key])){
|
|
| 67 | + if (isset($this->exceptionParams[$key])) {
|
|
| 68 | 68 | |
| 69 | 69 | //get key params for exception params |
| 70 | 70 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 71 | 71 | |
| 72 | 72 | //catch exception |
| 73 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
| 73 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
| 74 | 74 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 75 | 75 | } |
| 76 | - else{
|
|
| 76 | + else {
|
|
| 77 | 77 | //catch exception |
| 78 | 78 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 79 | 79 | } |
@@ -86,23 +86,23 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | private function getException($key) |
| 88 | 88 | {
|
| 89 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 89 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 90 | 90 | |
| 91 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 91 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 92 | 92 | |
| 93 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 94 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 93 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 94 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 95 | 95 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 98 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 99 | 99 | |
| 100 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 100 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 101 | 101 | unset($this->exceptionParams[$key]['params']); |
| 102 | 102 | |
| 103 | - foreach ($paramsCommaExplode as $params){
|
|
| 104 | - $paramsEqualExplode = explode("=",$params);
|
|
| 105 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 103 | + foreach ($paramsCommaExplode as $params) {
|
|
| 104 | + $paramsEqualExplode = explode("=", $params);
|
|
| 105 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 106 | 106 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -119,24 +119,24 @@ discard block |
||
| 119 | 119 | {
|
| 120 | 120 | // with the method based regex annotation, |
| 121 | 121 | // we check the rule definition for our requests. |
| 122 | - if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
|
|
| 123 | - if(isset($this->inputs[$key])){
|
|
| 122 | + if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
|
|
| 123 | + if (isset($this->inputs[$key])) {
|
|
| 124 | 124 | |
| 125 | 125 | // for the definition of rules, |
| 126 | 126 | // our inputs can be array and in this case we offer array option for user comfort. |
| 127 | - if(is_array($this->inputs[$key])){
|
|
| 127 | + if (is_array($this->inputs[$key])) {
|
|
| 128 | 128 | |
| 129 | - foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){
|
|
| 130 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
|
| 131 | - $this->catchException($key,$regex[1]); |
|
| 129 | + foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) {
|
|
| 130 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
|
|
| 131 | + $this->catchException($key, $regex[1]); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - else{
|
|
| 135 | + else {
|
|
| 136 | 136 | |
| 137 | 137 | // we control the regex rule that evaluates when only string arrives. |
| 138 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 139 | - $this->catchException($key,$regex[1]); |
|
| 138 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 139 | + $this->catchException($key, $regex[1]); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | private function getRemove($key) |
| 153 | 153 | {
|
| 154 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
|
|
| 155 | - if(isset($this->inputs[$key])){
|
|
| 156 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 154 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
|
|
| 155 | + if (isset($this->inputs[$key])) {
|
|
| 156 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 157 | 157 | unset($this->inputs[$key]); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | private function getRules($key) |
| 169 | 169 | {
|
| 170 | - if(preg_match('@rule\((.*?)\)\r\n@is',$this->annotation,$rule)){
|
|
| 170 | + if (preg_match('@rule\((.*?)\)\r\n@is', $this->annotation, $rule)) {
|
|
| 171 | 171 | |
| 172 | 172 | $requestRules = $this->getReflection('rules');
|
| 173 | 173 | |
| 174 | - $rules = explode(":",$rule[1]);
|
|
| 175 | - if(isset($this->inputs[$key])){
|
|
| 176 | - foreach($rules as $rule){
|
|
| 177 | - if(isset($requestRules[$rule])){
|
|
| 178 | - if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){
|
|
| 179 | - exception($rule,['key'=>$key]) |
|
| 174 | + $rules = explode(":", $rule[1]);
|
|
| 175 | + if (isset($this->inputs[$key])) {
|
|
| 176 | + foreach ($rules as $rule) {
|
|
| 177 | + if (isset($requestRules[$rule])) {
|
|
| 178 | + if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) {
|
|
| 179 | + exception($rule, ['key'=>$key]) |
|
| 180 | 180 | ->invalidArgument($key.' input value is not valid for '.$rule.' request rule'); |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -24,12 +24,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(!is_null($langMessage) && property_exists(core(),'exceptionTranslateParams')){
|
|
| 299 | + if (!is_null($langMessage) && 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 | |