@@ -14,6 +14,6 @@ |
||
| 14 | 14 | * @param array $commander |
| 15 | 15 | * @return mixed |
| 16 | 16 | */ |
| 17 | - public function exception($commander=array()); |
|
| 17 | + public function exception($commander = array()); |
|
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | {
|
| 28 | 28 | // we check that they are in |
| 29 | 29 | // the console to run the console commands in the kernel. |
| 30 | - if(Utils::isNamespaceExists($this->consoleClassNamespace)){
|
|
| 30 | + if (Utils::isNamespaceExists($this->consoleClassNamespace)) {
|
|
| 31 | 31 | return call_user_func($callback); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // if the kernel console is not found |
| 35 | 35 | // then we check the existence of the specific application command and run it if it is. |
| 36 | - return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(),$this))->handle(); |
|
| 36 | + return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(), $this))->handle(); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | * @param array $args |
| 44 | 44 | * @return void|mixed |
| 45 | 45 | */ |
| 46 | - protected function consoleEventHandler($args=array()) |
|
| 46 | + protected function consoleEventHandler($args = array()) |
|
| 47 | 47 | {
|
| 48 | - if(isset($this->app['eventDispatcher'])){
|
|
| 48 | + if (isset($this->app['eventDispatcher'])) {
|
|
| 49 | 49 | |
| 50 | 50 | $listeners = event()->getListeners(); |
| 51 | 51 | |
| 52 | - if(isset($args['event']) && isset($listeners['console'])){
|
|
| 52 | + if (isset($args['event']) && isset($listeners['console'])) {
|
|
| 53 | 53 | |
| 54 | - if(strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])){
|
|
| 54 | + if (strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])) {
|
|
| 55 | 55 | |
| 56 | 56 | $event = $listeners['console'][strtolower($args['event'])]; |
| 57 | - return call_user_func_array($event,['app'=>$this->app,'args'=>$args,]); |
|
| 57 | + return call_user_func_array($event, ['app'=>$this->app, 'args'=>$args, ]); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(isset($listeners['console']['default'])){
|
|
| 61 | + if (isset($listeners['console']['default'])) {
|
|
| 62 | 62 | |
| 63 | 63 | $event = $listeners['console']['default']; |
| 64 | - return call_user_func_array($event,['args'=>$args,'app'=>$this->app]); |
|
| 64 | + return call_user_func_array($event, ['args'=>$args, 'app'=>$this->app]); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | //If the console executor is a custom console application; in this case we look at the kernel directory inside the application. |
| 81 | 81 | //If the console class is not available on the kernel of resta, then the system will run the command class in the application. |
| 82 | - return $this->checkConsoleNamespace(function(){
|
|
| 82 | + return $this->checkConsoleNamespace(function() {
|
|
| 83 | 83 | |
| 84 | - if($this->isRunnableKernelCommandList()){
|
|
| 84 | + if ($this->isRunnableKernelCommandList()) {
|
|
| 85 | 85 | exception()->badMethodCall('this command is not runnable');
|
| 86 | 86 | } |
| 87 | 87 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $consoleArguments = $this->getConsoleArgumentsWithKey(); |
| 90 | 90 | |
| 91 | 91 | // we get the instance data of the kernel command class of the system. |
| 92 | - $commander = (new $this->consoleClassNamespace($consoleArguments,$this)); |
|
| 92 | + $commander = (new $this->consoleClassNamespace($consoleArguments, $this)); |
|
| 93 | 93 | |
| 94 | 94 | // we check the command rules of each command class. |
| 95 | - $this->prepareCommander($commander,function($commander){
|
|
| 95 | + $this->prepareCommander($commander, function($commander) {
|
|
| 96 | 96 | return $commander->{$this->getConsoleClassMethod()}();
|
| 97 | 97 | }); |
| 98 | 98 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | public function handle() |
| 111 | 111 | {
|
| 112 | 112 | //get is running console |
| 113 | - if($this->app->runningInConsole()){
|
|
| 113 | + if ($this->app->runningInConsole()) {
|
|
| 114 | 114 | |
| 115 | 115 | //run console process |
| 116 | - if(count($this->getArguments())){
|
|
| 116 | + if (count($this->getArguments())) {
|
|
| 117 | 117 | return $this->consoleProcess(); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -129,24 +129,24 @@ discard block |
||
| 129 | 129 | * @param callable $callback |
| 130 | 130 | * @return mixed |
| 131 | 131 | */ |
| 132 | - protected function prepareCommander(ConsoleOutputterContracts $commander,callable $callback) |
|
| 132 | + protected function prepareCommander(ConsoleOutputterContracts $commander, callable $callback) |
|
| 133 | 133 | {
|
| 134 | 134 | // closure binding custom command,move custom namespace as specific |
| 135 | 135 | // call prepare commander firstly for checking command builder |
| 136 | - $closureCommand = app()->resolve(ClosureDispatcher::class,['bind'=>$commander]); |
|
| 136 | + $closureCommand = app()->resolve(ClosureDispatcher::class, ['bind'=>$commander]); |
|
| 137 | 137 | |
| 138 | 138 | //assign commander method name |
| 139 | 139 | $closureCommand->prepareBind['methodName'] = $this->getConsoleClassMethod(); |
| 140 | 140 | |
| 141 | 141 | $prepareCommander = $commander->prepareCommander($closureCommand); |
| 142 | 142 | |
| 143 | - if(!$prepareCommander['status']){
|
|
| 143 | + if (!$prepareCommander['status']) {
|
|
| 144 | 144 | echo $commander->exception($prepareCommander); |
| 145 | 145 | die(); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | //callback custom console |
| 149 | - return call_user_func_array($callback,[$commander]); |
|
| 149 | + return call_user_func_array($callback, [$commander]); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | $commandList = $this->app->commandList(); |
| 160 | 160 | |
| 161 | 161 | //is runnable kernel command conditions |
| 162 | - return !array_key_exists($this->consoleClassNamespace,$commandList) OR |
|
| 163 | - (array_key_exists($this->consoleClassNamespace,$commandList) AND |
|
| 162 | + return !array_key_exists($this->consoleClassNamespace, $commandList) OR |
|
| 163 | + (array_key_exists($this->consoleClassNamespace, $commandList) AND |
|
| 164 | 164 | !$commandList[$this->consoleClassNamespace]['isRunnable']); |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | \ No newline at end of file |
@@ -8,83 +8,83 @@ |
||
| 8 | 8 | * @param null|string $msg |
| 9 | 9 | * @return mixed |
| 10 | 10 | */ |
| 11 | - public function invalidArgument($msg=null); |
|
| 11 | + public function invalidArgument($msg = null); |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @param null|string $msg |
| 15 | 15 | * @return mixed |
| 16 | 16 | */ |
| 17 | - public function badFunctionCall($msg=null); |
|
| 17 | + public function badFunctionCall($msg = null); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param null|string $msg |
| 21 | 21 | * @return mixed |
| 22 | 22 | */ |
| 23 | - public function badMethodCall($msg=null); |
|
| 23 | + public function badMethodCall($msg = null); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @param null|string $msg |
| 27 | 27 | * @return mixed |
| 28 | 28 | */ |
| 29 | - public function domain($msg=null); |
|
| 29 | + public function domain($msg = null); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @param null|string $msg |
| 33 | 33 | * @return mixed |
| 34 | 34 | */ |
| 35 | - public function length($msg=null); |
|
| 35 | + public function length($msg = null); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param null|string $msg |
| 39 | 39 | * @return mixed |
| 40 | 40 | */ |
| 41 | - public function logic($msg=null); |
|
| 41 | + public function logic($msg = null); |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param null|string $msg |
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | - public function notFoundException($msg=null); |
|
| 47 | + public function notFoundException($msg = null); |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param null|string $msg |
| 51 | 51 | * @return mixed |
| 52 | 52 | */ |
| 53 | - public function fileNotFoundException($msg=null); |
|
| 53 | + public function fileNotFoundException($msg = null); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @param null|string $msg |
| 57 | 57 | * @return mixed |
| 58 | 58 | */ |
| 59 | - public function outOfRange($msg=null); |
|
| 59 | + public function outOfRange($msg = null); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @param null|string $msg |
| 63 | 63 | * @return mixed |
| 64 | 64 | */ |
| 65 | - public function overflow($msg=null); |
|
| 65 | + public function overflow($msg = null); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * @param null|string $msg |
| 69 | 69 | * @return mixed |
| 70 | 70 | */ |
| 71 | - public function range($msg=null); |
|
| 71 | + public function range($msg = null); |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param null|string $msg |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - public function runtime($msg=null); |
|
| 77 | + public function runtime($msg = null); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * @param null|string $msg |
| 81 | 81 | * @return mixed |
| 82 | 82 | */ |
| 83 | - public function underflow($msg=null); |
|
| 83 | + public function underflow($msg = null); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @param null|string $msg |
| 87 | 87 | * @return mixed |
| 88 | 88 | */ |
| 89 | - public function unexpectedValue($msg=null); |
|
| 89 | + public function unexpectedValue($msg = null); |
|
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -72,8 +72,7 @@ discard block |
||
| 72 | 72 | {
|
| 73 | 73 | if($extension){
|
| 74 | 74 | $default=root.'/'.str_replace("\\","/",$class).'.php';
|
| 75 | - } |
|
| 76 | - else{
|
|
| 75 | + } else{
|
|
| 77 | 76 | $default=root.'/'.str_replace("\\","/",$class).'';
|
| 78 | 77 | } |
| 79 | 78 | |
@@ -240,21 +239,32 @@ discard block |
||
| 240 | 239 | */ |
| 241 | 240 | public static function array_diff_key_recursive ($array1, $array2) |
| 242 | 241 | {
|
| 243 | - if(count($array1)!==count($array2)) self::$bool[]=false; |
|
| 242 | + if(count($array1)!==count($array2)) {
|
|
| 243 | + self::$bool[]=false; |
|
| 244 | + } |
|
| 244 | 245 | |
| 245 | 246 | foreach ($array1 as $array1_key=>$array1_value){
|
| 246 | 247 | |
| 247 | 248 | if(!is_array($array1_value)){
|
| 248 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
| 249 | - } |
|
| 250 | - else{
|
|
| 251 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
| 249 | + if(!array_key_exists($array1_key,$array2)) {
|
|
| 250 | + self::$bool[]=false; |
|
| 251 | + } |
|
| 252 | + } else{
|
|
| 253 | + if(!array_key_exists($array1_key,$array2)) {
|
|
| 254 | + self::$bool[]=false; |
|
| 255 | + } |
|
| 252 | 256 | |
| 253 | - if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[]; |
|
| 257 | + if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) {
|
|
| 258 | + $array2[$array1_key]=[]; |
|
| 259 | + } |
|
| 254 | 260 | |
| 255 | - if(isset($array1_value[0])) $array1_value=$array1_value[0]; |
|
| 261 | + if(isset($array1_value[0])) {
|
|
| 262 | + $array1_value=$array1_value[0]; |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | - if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0]; |
|
| 265 | + if(isset($array2[$array1_key][0])) {
|
|
| 266 | + $array2[$array1_key]=$array2[$array1_key][0]; |
|
| 267 | + } |
|
| 258 | 268 | |
| 259 | 269 | self::array_diff_key_recursive($array1_value,$array2[$array1_key]); |
| 260 | 270 | } |
@@ -356,8 +366,7 @@ discard block |
||
| 356 | 366 | |
| 357 | 367 | if($reelPath===null){
|
| 358 | 368 | $pathWithPhpList[] = $pathWithPhp[0]; |
| 359 | - } |
|
| 360 | - else{
|
|
| 369 | + } else{
|
|
| 361 | 370 | $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0]; |
| 362 | 371 | } |
| 363 | 372 | |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | * @param bool $shift |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public static function upperCase($argument,$shift=true) |
|
| 19 | + public static function upperCase($argument, $shift = true) |
|
| 20 | 20 | {
|
| 21 | - if($shift){
|
|
| 21 | + if ($shift) {
|
|
| 22 | 22 | array_shift($argument); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - return array_map(function($argument){
|
|
| 25 | + return array_map(function($argument) {
|
|
| 26 | 26 | return ucfirst($argument); |
| 27 | 27 | },$argument); |
| 28 | 28 | } |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public static function strtolower($argument) |
| 48 | 48 | {
|
| 49 | - if(!is_array($argument)){
|
|
| 49 | + if (!is_array($argument)) {
|
|
| 50 | 50 | return strtolower($argument); |
| 51 | 51 | } |
| 52 | - return array_map(function($argument){
|
|
| 52 | + return array_map(function($argument) {
|
|
| 53 | 53 | return strtolower($argument); |
| 54 | 54 | },$argument); |
| 55 | 55 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * @param array $data |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - public static function generatorNamespace($data=array()) |
|
| 61 | + public static function generatorNamespace($data = array()) |
|
| 62 | 62 | {
|
| 63 | - return str_replace('.php','',implode("\\",$data));
|
|
| 63 | + return str_replace('.php', '', implode("\\", $data));
|
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | * @param bool $extension |
| 69 | 69 | * @return mixed |
| 70 | 70 | */ |
| 71 | - public static function getPathFromNamespace($class,$extension=true) |
|
| 71 | + public static function getPathFromNamespace($class, $extension = true) |
|
| 72 | 72 | {
|
| 73 | - if($extension){
|
|
| 74 | - $default=root.'/'.str_replace("\\","/",$class).'.php';
|
|
| 73 | + if ($extension) {
|
|
| 74 | + $default = root.'/'.str_replace("\\", "/", $class).'.php';
|
|
| 75 | 75 | } |
| 76 | - else{
|
|
| 77 | - $default=root.'/'.str_replace("\\","/",$class).'';
|
|
| 76 | + else {
|
|
| 77 | + $default = root.'/'.str_replace("\\", "/", $class).'';
|
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - return str_replace("/App",'/src/app',$default);
|
|
| 80 | + return str_replace("/App", '/src/app', $default);
|
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param $method |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - public static function existMethod($class,$method) |
|
| 97 | + public static function existMethod($class, $method) |
|
| 98 | 98 | {
|
| 99 | - return method_exists($class,$method); |
|
| 99 | + return method_exists($class, $method); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * @param $second |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - public static function isArrayEqual($first,$second) |
|
| 107 | + public static function isArrayEqual($first, $second) |
|
| 108 | 108 | {
|
| 109 | - return (count( $first ) == count( $second ) && !array_diff( $first, $second )); |
|
| 109 | + return (count($first)==count($second) && !array_diff($first, $second)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -123,17 +123,17 @@ discard block |
||
| 123 | 123 | * @param bool $filename |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | - public static function glob($path,$filename=false) |
|
| 126 | + public static function glob($path, $filename = false) |
|
| 127 | 127 | {
|
| 128 | 128 | $configList = []; |
| 129 | 129 | |
| 130 | 130 | foreach (glob($path.'/*.php') as $config) {
|
| 131 | 131 | |
| 132 | - $configArray=str_replace(".php","",explode("/",$config));
|
|
| 133 | - $configList[end($configArray)]=$config; |
|
| 132 | + $configArray = str_replace(".php", "", explode("/", $config));
|
|
| 133 | + $configList[end($configArray)] = $config; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if($filename===true){
|
|
| 136 | + if ($filename===true) {
|
|
| 137 | 137 | return array_keys($configList); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param string $seperator |
| 163 | 163 | * @return mixed |
| 164 | 164 | */ |
| 165 | - public static function getJustClassName($namespace,$seperator="\\") |
|
| 165 | + public static function getJustClassName($namespace, $seperator = "\\") |
|
| 166 | 166 | {
|
| 167 | 167 | $path = explode($seperator, $namespace); |
| 168 | 168 | return array_pop($path); |
@@ -173,23 +173,23 @@ discard block |
||
| 173 | 173 | * @param array $param |
| 174 | 174 | * @return bool |
| 175 | 175 | */ |
| 176 | - public static function changeClass($class,$param=array()) |
|
| 176 | + public static function changeClass($class, $param = array()) |
|
| 177 | 177 | {
|
| 178 | - $executionPath=$class; |
|
| 178 | + $executionPath = $class; |
|
| 179 | 179 | $dt = fopen($executionPath, "r"); |
| 180 | 180 | |
| 181 | - if($dt!==false){
|
|
| 181 | + if ($dt!==false) {
|
|
| 182 | 182 | |
| 183 | 183 | $content = fread($dt, filesize($executionPath)); |
| 184 | 184 | fclose($dt); |
| 185 | 185 | |
| 186 | - foreach ($param as $key=>$value){
|
|
| 187 | - $content=str_replace($key,$value,$content); |
|
| 186 | + foreach ($param as $key=>$value) {
|
|
| 187 | + $content = str_replace($key, $value, $content); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $forWrite = fopen($executionPath, "w"); |
| 191 | 191 | |
| 192 | - if($forWrite!==false){
|
|
| 192 | + if ($forWrite!==false) {
|
|
| 193 | 193 | fwrite($forWrite, $content); |
| 194 | 194 | fclose($forWrite); |
| 195 | 195 | |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | * @param $callback |
| 206 | 206 | * @return mixed |
| 207 | 207 | */ |
| 208 | - public static function returnCallback($data,$callback) |
|
| 208 | + public static function returnCallback($data, $callback) |
|
| 209 | 209 | {
|
| 210 | - return call_user_func_array($callback,[$data]); |
|
| 210 | + return call_user_func_array($callback, [$data]); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public static function getNamespace($namespace) |
| 218 | 218 | {
|
| 219 | - $rootDelete=str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'','',$namespace); |
|
| 219 | + $rootDelete = str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'', '', $namespace); |
|
| 220 | 220 | |
| 221 | 221 | return 'App\\'.self::generatorNamespace( |
| 222 | - explode(''.DIRECTORY_SEPARATOR.'',$rootDelete)
|
|
| 222 | + explode(''.DIRECTORY_SEPARATOR.'', $rootDelete)
|
|
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public static function callbackProcess($callback) |
| 232 | 232 | {
|
| 233 | - return (is_callable($callback)) ? call_user_func_array($callback,[app()]) : $callback; |
|
| 233 | + return (is_callable($callback)) ? call_user_func_array($callback, [app()]) : $callback; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -238,29 +238,29 @@ discard block |
||
| 238 | 238 | * @param $array2 |
| 239 | 239 | * @return bool |
| 240 | 240 | */ |
| 241 | - public static function array_diff_key_recursive ($array1, $array2) |
|
| 241 | + public static function array_diff_key_recursive($array1, $array2) |
|
| 242 | 242 | {
|
| 243 | - if(count($array1)!==count($array2)) self::$bool[]=false; |
|
| 243 | + if (count($array1)!==count($array2)) self::$bool[] = false; |
|
| 244 | 244 | |
| 245 | - foreach ($array1 as $array1_key=>$array1_value){
|
|
| 245 | + foreach ($array1 as $array1_key=>$array1_value) {
|
|
| 246 | 246 | |
| 247 | - if(!is_array($array1_value)){
|
|
| 248 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
| 247 | + if (!is_array($array1_value)) {
|
|
| 248 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
| 249 | 249 | } |
| 250 | - else{
|
|
| 251 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
| 250 | + else {
|
|
| 251 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
| 252 | 252 | |
| 253 | - if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[]; |
|
| 253 | + if (!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key] = []; |
|
| 254 | 254 | |
| 255 | - if(isset($array1_value[0])) $array1_value=$array1_value[0]; |
|
| 255 | + if (isset($array1_value[0])) $array1_value = $array1_value[0]; |
|
| 256 | 256 | |
| 257 | - if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0]; |
|
| 257 | + if (isset($array2[$array1_key][0])) $array2[$array1_key] = $array2[$array1_key][0]; |
|
| 258 | 258 | |
| 259 | - self::array_diff_key_recursive($array1_value,$array2[$array1_key]); |
|
| 259 | + self::array_diff_key_recursive($array1_value, $array2[$array1_key]); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if(in_array(false,self::$bool)){
|
|
| 263 | + if (in_array(false, self::$bool)) {
|
|
| 264 | 264 | return false; |
| 265 | 265 | } |
| 266 | 266 | return true; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public static function slashToBackSlash($data) |
| 274 | 274 | {
|
| 275 | - return str_replace("/","\\",$data);
|
|
| 275 | + return str_replace("/", "\\", $data);
|
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | * @param null|string $key |
| 283 | 283 | * @return mixed |
| 284 | 284 | */ |
| 285 | - public static function trace($debug=0,$key=null) |
|
| 285 | + public static function trace($debug = 0, $key = null) |
|
| 286 | 286 | {
|
| 287 | 287 | $trace = debug_backtrace(); |
| 288 | 288 | |
| 289 | - if($key===null){
|
|
| 289 | + if ($key===null) {
|
|
| 290 | 290 | return $trace[$debug] ?? null; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public static function getServiceConf() |
| 300 | 300 | {
|
| 301 | - if(property_exists(core(),'serviceConf') && defined('methodName')){
|
|
| 301 | + if (property_exists(core(), 'serviceConf') && defined('methodName')) {
|
|
| 302 | 302 | return core()->serviceConf; |
| 303 | 303 | } |
| 304 | 304 | return []; |
@@ -309,18 +309,18 @@ discard block |
||
| 309 | 309 | * @param null|string $reelPath |
| 310 | 310 | * @return array |
| 311 | 311 | */ |
| 312 | - public static function getPathWithPhpExtension($files,$reelPath=null) |
|
| 312 | + public static function getPathWithPhpExtension($files, $reelPath = null) |
|
| 313 | 313 | {
|
| 314 | 314 | $pathWithPhpList = []; |
| 315 | 315 | |
| 316 | - foreach ($files as $file){
|
|
| 316 | + foreach ($files as $file) {
|
|
| 317 | 317 | |
| 318 | - if(preg_match('@(.*).php@is',$file,$pathWithPhp)){
|
|
| 318 | + if (preg_match('@(.*).php@is', $file, $pathWithPhp)) {
|
|
| 319 | 319 | |
| 320 | - if($reelPath===null){
|
|
| 320 | + if ($reelPath===null) {
|
|
| 321 | 321 | $pathWithPhpList[] = $pathWithPhp[0]; |
| 322 | 322 | } |
| 323 | - else{
|
|
| 323 | + else {
|
|
| 324 | 324 | $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0]; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | public static function resolverClass($class) |
| 338 | 338 | {
|
| 339 | - if(self::isNamespaceExists($class)){
|
|
| 339 | + if (self::isNamespaceExists($class)) {
|
|
| 340 | 340 | return app()->resolve($class); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | public static function getRequestPathInfo() |
| 350 | 350 | {
|
| 351 | - if(is_null(BootStaticManager::getRequestPath())){
|
|
| 352 | - return explode("/",request()->getPathInfo());
|
|
| 351 | + if (is_null(BootStaticManager::getRequestPath())) {
|
|
| 352 | + return explode("/", request()->getPathInfo());
|
|
| 353 | 353 | } |
| 354 | 354 | return BootStaticManager::getRequestPath(); |
| 355 | 355 | } |
@@ -359,13 +359,13 @@ discard block |
||
| 359 | 359 | * @param null|string $remove |
| 360 | 360 | * @return array |
| 361 | 361 | */ |
| 362 | - public static function removeTrace($trace,$remove=null) |
|
| 362 | + public static function removeTrace($trace, $remove = null) |
|
| 363 | 363 | {
|
| 364 | 364 | $list = []; |
| 365 | 365 | |
| 366 | - foreach($trace as $key=>$item){
|
|
| 366 | + foreach ($trace as $key=>$item) {
|
|
| 367 | 367 | |
| 368 | - if(isset($item['file']) && !preg_match('@'.$remove.'@',$item['file'])){
|
|
| 368 | + if (isset($item['file']) && !preg_match('@'.$remove.'@', $item['file'])) {
|
|
| 369 | 369 | $list[$key] = $item; |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $path = realpath($path) ?: $path; |
| 131 | 131 | $tempPath = tempnam(dirname($path), basename($path)); |
| 132 | 132 | // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600... |
| 133 | - chmod($tempPath, 0777 - umask()); |
|
| 133 | + chmod($tempPath, 0777-umask()); |
|
| 134 | 134 | file_put_contents($tempPath, $content); |
| 135 | 135 | rename($tempPath, $path); |
| 136 | 136 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $success = true; |
| 190 | 190 | foreach ($paths as $path) { |
| 191 | 191 | try { |
| 192 | - if (! @unlink($path)) { |
|
| 192 | + if (!@unlink($path)) { |
|
| 193 | 193 | $success = false; |
| 194 | 194 | } |
| 195 | 195 | } catch (ErrorException $e) { |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function link($target, $link) |
| 234 | 234 | { |
| 235 | - if (! windows_os()) { |
|
| 235 | + if (!windows_os()) { |
|
| 236 | 236 | return symlink($target, $link); |
| 237 | 237 | } |
| 238 | 238 | $mode = $this->isDirectory($target) ? 'J' : 'H'; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | public function files($directory, $hidden = false) |
| 394 | 394 | { |
| 395 | 395 | return iterator_to_array( |
| 396 | - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0)->sortByName(), |
|
| 396 | + Finder::create()->files()->ignoreDotFiles(!$hidden)->in($directory)->depth(0)->sortByName(), |
|
| 397 | 397 | false |
| 398 | 398 | ); |
| 399 | 399 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | public function allFiles($directory, $hidden = false) |
| 409 | 409 | { |
| 410 | 410 | return iterator_to_array( |
| 411 | - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->sortByName(), |
|
| 411 | + Finder::create()->files()->ignoreDotFiles(!$hidden)->in($directory)->sortByName(), |
|
| 412 | 412 | false |
| 413 | 413 | ); |
| 414 | 414 | } |
@@ -455,10 +455,10 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | public function moveDirectory($from, $to, $overwrite = false) |
| 457 | 457 | { |
| 458 | - if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) { |
|
| 458 | + if ($overwrite && $this->isDirectory($to) && !$this->deleteDirectory($to)) { |
|
| 459 | 459 | return false; |
| 460 | 460 | } |
| 461 | - return @rename($from, $to) === true; |
|
| 461 | + return @rename($from, $to)===true; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | */ |
| 472 | 472 | public function copyDirectory($directory, $destination, $options = null) |
| 473 | 473 | { |
| 474 | - if (! $this->isDirectory($directory)) { |
|
| 474 | + if (!$this->isDirectory($directory)) { |
|
| 475 | 475 | return false; |
| 476 | 476 | } |
| 477 | 477 | $options = $options ?: FilesystemIterator::SKIP_DOTS; |
| 478 | 478 | // If the destination directory does not actually exist, we will go ahead and |
| 479 | 479 | // create it recursively, which just gets the destination prepared to copy |
| 480 | 480 | // the files over. Once we make the directory we'll proceed the copying. |
| 481 | - if (! $this->isDirectory($destination)) { |
|
| 481 | + if (!$this->isDirectory($destination)) { |
|
| 482 | 482 | $this->makeDirectory($destination, 0777, true); |
| 483 | 483 | } |
| 484 | 484 | $items = new FilesystemIterator($directory, $options); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $target = $destination.'/'.$item->getBasename(); |
| 490 | 490 | if ($item->isDir()) { |
| 491 | 491 | $path = $item->getPathname(); |
| 492 | - if (! $this->copyDirectory($path, $target, $options)) { |
|
| 492 | + if (!$this->copyDirectory($path, $target, $options)) { |
|
| 493 | 493 | return false; |
| 494 | 494 | } |
| 495 | 495 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | // location and keep looping. If for some reason the copy fails we'll bail out |
| 498 | 498 | // and return false, so the developer is aware that the copy process failed. |
| 499 | 499 | else { |
| 500 | - if (! $this->copy($item->getPathname(), $target)) { |
|
| 500 | + if (!$this->copy($item->getPathname(), $target)) { |
|
| 501 | 501 | return false; |
| 502 | 502 | } |
| 503 | 503 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | public function deleteDirectory($directory, $preserve = false) |
| 518 | 518 | { |
| 519 | - if (! $this->isDirectory($directory)) { |
|
| 519 | + if (!$this->isDirectory($directory)) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | 522 | $items = new FilesystemIterator($directory); |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | // If the item is a directory, we can just recurse into the function and |
| 525 | 525 | // delete that sub-directory otherwise we'll just delete the file and |
| 526 | 526 | // keep iterating through each file until the directory is cleaned. |
| 527 | - if ($item->isDir() && ! $item->isLink()) { |
|
| 527 | + if ($item->isDir() && !$item->isLink()) { |
|
| 528 | 528 | $this->deleteDirectory($item->getPathname()); |
| 529 | 529 | } |
| 530 | 530 | // If the item is just a file, we can go ahead and delete it since we're |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | $this->delete($item->getPathname()); |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | - if (! $preserve) { |
|
| 537 | + if (!$preserve) { |
|
| 538 | 538 | @rmdir($directory); |
| 539 | 539 | } |
| 540 | 540 | return true; |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | public function deleteDirectories($directory) |
| 550 | 550 | { |
| 551 | 551 | $allDirectories = $this->directories($directory); |
| 552 | - if (! empty($allDirectories)) { |
|
| 552 | + if (!empty($allDirectories)) { |
|
| 553 | 553 | foreach ($allDirectories as $directoryName) { |
| 554 | 554 | $this->deleteDirectory($directoryName); |
| 555 | 555 | } |
@@ -580,17 +580,17 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | public function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false) |
| 582 | 582 | { |
| 583 | - if ($dir == '') {return array();} else {$results = array(); $subresults = array();} |
|
| 584 | - if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent |
|
| 585 | - if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;} |
|
| 583 | + if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); } |
|
| 584 | + if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent |
|
| 585 | + if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; } |
|
| 586 | 586 | |
| 587 | 587 | $files = scandir($dir); |
| 588 | - foreach ($files as $key => $value){ |
|
| 589 | - if ( ($value != '.') && ($value != '..') ) { |
|
| 588 | + foreach ($files as $key => $value) { |
|
| 589 | + if (($value!='.') && ($value!='..')) { |
|
| 590 | 590 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
| 591 | 591 | if (is_dir($path)) { |
| 592 | 592 | // optionally include directories in file list |
| 593 | - if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);} |
|
| 593 | + if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); } |
|
| 594 | 594 | // optionally get file list for all subdirectories |
| 595 | 595 | if ($recursive) { |
| 596 | 596 | $subdirresults = $this->getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | 605 | // merge the subarray to give the list of files then subdirectory files |
| 606 | - if (count($subresults) > 0) {$results = array_merge($subresults, $results);} |
|
| 606 | + if (count($subresults)>0) {$results = array_merge($subresults, $results); } |
|
| 607 | 607 | return $results; |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param null|string $msg |
| 29 | 29 | */ |
| 30 | - public function invalidArgument($msg=null) |
|
| 30 | + public function invalidArgument($msg = null) |
|
| 31 | 31 | {
|
| 32 | 32 | throw new InvalidArgumentException($msg); |
| 33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param null|string $msg |
| 39 | 39 | */ |
| 40 | - public function badFunctionCall($msg=null) |
|
| 40 | + public function badFunctionCall($msg = null) |
|
| 41 | 41 | {
|
| 42 | 42 | throw new BadFunctionCallException($msg); |
| 43 | 43 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param null|string $msg |
| 49 | 49 | */ |
| 50 | - public function badMethodCall($msg=null) |
|
| 50 | + public function badMethodCall($msg = null) |
|
| 51 | 51 | {
|
| 52 | 52 | throw new BadMethodCallException($msg); |
| 53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param null|string $msg |
| 59 | 59 | */ |
| 60 | - public function domain($msg=null) |
|
| 60 | + public function domain($msg = null) |
|
| 61 | 61 | {
|
| 62 | 62 | throw new DomainException($msg); |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param null|string $msg |
| 69 | 69 | */ |
| 70 | - public function length($msg=null) |
|
| 70 | + public function length($msg = null) |
|
| 71 | 71 | {
|
| 72 | 72 | throw new LengthException($msg); |
| 73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param null|string $msg |
| 79 | 79 | */ |
| 80 | - public function logic($msg=null) |
|
| 80 | + public function logic($msg = null) |
|
| 81 | 81 | {
|
| 82 | 82 | throw new LogicException($msg); |
| 83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return null |
| 90 | 90 | * |
| 91 | 91 | */ |
| 92 | - public function notFoundException($msg=null) |
|
| 92 | + public function notFoundException($msg = null) |
|
| 93 | 93 | {
|
| 94 | 94 | return $this->notFound($msg); |
| 95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return mixed|void |
| 102 | 102 | * |
| 103 | 103 | */ |
| 104 | - public function fileNotFoundException($msg=null) |
|
| 104 | + public function fileNotFoundException($msg = null) |
|
| 105 | 105 | {
|
| 106 | 106 | return $this->fileNotFound($msg); |
| 107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @param null|string $msg |
| 113 | 113 | */ |
| 114 | - public function outOfRange($msg=null) |
|
| 114 | + public function outOfRange($msg = null) |
|
| 115 | 115 | {
|
| 116 | 116 | throw new OutOfRangeException($msg); |
| 117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param null|string $msg |
| 123 | 123 | */ |
| 124 | - public function overflow($msg=null) |
|
| 124 | + public function overflow($msg = null) |
|
| 125 | 125 | {
|
| 126 | 126 | throw new OverflowException($msg); |
| 127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @param null|string $msg |
| 133 | 133 | */ |
| 134 | - public function range($msg=null) |
|
| 134 | + public function range($msg = null) |
|
| 135 | 135 | {
|
| 136 | 136 | throw new RangeException($msg); |
| 137 | 137 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param null|string $msg |
| 143 | 143 | */ |
| 144 | - public function runtime($msg=null) |
|
| 144 | + public function runtime($msg = null) |
|
| 145 | 145 | {
|
| 146 | 146 | throw new RuntimeException($msg); |
| 147 | 147 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @param null|string $msg |
| 153 | 153 | */ |
| 154 | - public function underflow($msg=null) |
|
| 154 | + public function underflow($msg = null) |
|
| 155 | 155 | {
|
| 156 | 156 | throw new UnderflowException($msg); |
| 157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @param null|string $msg |
| 163 | 163 | */ |
| 164 | - public function unexpectedValue($msg=null) |
|
| 164 | + public function unexpectedValue($msg = null) |
|
| 165 | 165 | {
|
| 166 | 166 | throw new UnexpectedValueException($msg); |
| 167 | 167 | } |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * @param ApplicationContracts $app |
| 23 | 23 | * @param array $result |
| 24 | 24 | */ |
| 25 | - public function __construct(ApplicationContracts $app,$result=array()) |
|
| 25 | + public function __construct(ApplicationContracts $app, $result = array()) |
|
| 26 | 26 | { |
| 27 | 27 | parent::__construct($app); |
| 28 | 28 | |
| 29 | 29 | $this->result = $result; |
| 30 | 30 | |
| 31 | - foreach($this->extender as $item){ |
|
| 32 | - if(method_exists($this,$item)){ |
|
| 31 | + foreach ($this->extender as $item) { |
|
| 32 | + if (method_exists($this, $item)) { |
|
| 33 | 33 | $this->{$item}(); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | // we will look at the requestExpected container value to show |
| 56 | 56 | // the expected values for the request object in the exception output. |
| 57 | - if($this->app->has('requestExpected') && config('app.requestWithError')===true){ |
|
| 58 | - if($requestExpected = $this->app->get('requestExpected')){ |
|
| 57 | + if ($this->app->has('requestExpected') && config('app.requestWithError')===true) { |
|
| 58 | + if ($requestExpected = $this->app->get('requestExpected')) { |
|
| 59 | 59 | $this->result['request']['expected'] = $requestExpected; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -25,26 +25,26 @@ |
||
| 25 | 25 | * @param null|string $name |
| 26 | 26 | * @return array |
| 27 | 27 | */ |
| 28 | - public function container($name=null) |
|
| 28 | + public function container($name = null) |
|
| 29 | 29 | {
|
| 30 | 30 | //check container value for kernel |
| 31 | - if(isset($this->instances['container'])){
|
|
| 31 | + if (isset($this->instances['container'])) {
|
|
| 32 | 32 | |
| 33 | 33 | // if methoda is a null parameter, |
| 34 | 34 | // then we send direct container values. |
| 35 | - if(is_null($name)){
|
|
| 35 | + if (is_null($name)) {
|
|
| 36 | 36 | return (array)$this->instances['container']; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // if there is an existing value in the container as the method parameter, |
| 40 | 40 | // we send this value directly in the container. |
| 41 | - if(isset($this->container()[$name])){
|
|
| 41 | + if (isset($this->container()[$name])) {
|
|
| 42 | 42 | return $this->container()[$name]; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // if there is no $name value in the container as the method parameter, |
| 46 | 46 | // we check this value directly in the core object. |
| 47 | - if(property_exists(core(),$name)){
|
|
| 47 | + if (property_exists(core(), $name)) {
|
|
| 48 | 48 | return core()->{$name};
|
| 49 | 49 | } |
| 50 | 50 | |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | {
|
| 40 | 40 | if($this->app->has('exceptiontrace')) {
|
| 41 | 41 | $this->data['status'] = (int)$this->app['exceptiontrace']['callNamespace']->getCode(); |
| 42 | - } |
|
| 43 | - else {
|
|
| 42 | + } else {
|
|
| 44 | 43 | $this->data['status'] = (int)$this->exception::exceptionTypeCodes($this->data['errType']); |
| 45 | 44 | } |
| 46 | 45 | } |
@@ -82,8 +81,7 @@ discard block |
||
| 82 | 81 | |
| 83 | 82 | //set as the success object is false |
| 84 | 83 | $this->data['appExceptionSuccess'] = []; |
| 85 | - } |
|
| 86 | - else{
|
|
| 84 | + } else{
|
|
| 87 | 85 | |
| 88 | 86 | //set as the success object is false |
| 89 | 87 | $this->data['appExceptionSuccess'] = ['success'=>(bool)false,'status'=>$this->data['status']]; |
@@ -180,8 +178,7 @@ discard block |
||
| 180 | 178 | $this->app->register('responseStatus',500);
|
| 181 | 179 | |
| 182 | 180 | |
| 183 | - } |
|
| 184 | - else{
|
|
| 181 | + } else{
|
|
| 185 | 182 | |
| 186 | 183 | $this->result = $this->getAppException($environment,$this->data['errStrReal']); |
| 187 | 184 | |
@@ -216,8 +213,7 @@ discard block |
||
| 216 | 213 | |
| 217 | 214 | echo json_encode($this->app->get('out')->outputFormatter($this->result));
|
| 218 | 215 | exit(); |
| 219 | - } |
|
| 220 | - else{
|
|
| 216 | + } else{
|
|
| 221 | 217 | echo $restaOutHandle; |
| 222 | 218 | exit(); |
| 223 | 219 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | private function getStatusAccordingToExceptionTrace() |
| 39 | 39 | {
|
| 40 | - if($this->app->has('exceptiontrace')) {
|
|
| 40 | + if ($this->app->has('exceptiontrace')) {
|
|
| 41 | 41 | $this->data['status'] = (int)$this->app['exceptiontrace']['callNamespace']->getCode(); |
| 42 | 42 | } |
| 43 | 43 | else {
|
@@ -54,21 +54,21 @@ discard block |
||
| 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 | //trace pattern |
| 66 | 66 | $trace = $this->data['errContext']['trace']; |
| 67 | - if(preg_match('@Stack trace:\n#0(.*)\n#1@is',$trace,$traceArray)){
|
|
| 67 | + if (preg_match('@Stack trace:\n#0(.*)\n#1@is', $trace, $traceArray)) {
|
|
| 68 | 68 | |
| 69 | - $traceFile = str_replace(root,'',$traceArray[1]); |
|
| 69 | + $traceFile = str_replace(root, '', $traceArray[1]); |
|
| 70 | 70 | |
| 71 | - if(preg_match('@(.*)\((\d+)\)@is',$traceFile,$traceResolve)){
|
|
| 71 | + if (preg_match('@(.*)\((\d+)\)@is', $traceFile, $traceResolve)) {
|
|
| 72 | 72 | $this->data['errFile'] = $traceResolve[1]; |
| 73 | 73 | $this->data['errLine'] = (int)$traceResolve[2]; |
| 74 | 74 | } |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | $this->data['errType'] = class_basename($this->data['errType']); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(is_array($meta = config('response.meta'))){
|
|
| 81 | + if (is_array($meta = config('response.meta'))) {
|
|
| 82 | 82 | |
| 83 | 83 | //set as the success object is false |
| 84 | 84 | $this->data['appExceptionSuccess'] = []; |
| 85 | 85 | } |
| 86 | - else{
|
|
| 86 | + else {
|
|
| 87 | 87 | |
| 88 | 88 | //set as the success object is false |
| 89 | - $this->data['appExceptionSuccess'] = ['success'=>(bool)false,'status'=>$this->data['status']]; |
|
| 89 | + $this->data['appExceptionSuccess'] = ['success'=>(bool)false, 'status'=>$this->data['status']]; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | //This function can be used for defining your own way of handling errors during runtime, |
| 109 | 109 | //for example in applications in which you need to do cleanup of data/files when a critical error happens, |
| 110 | 110 | //or when you need to trigger an error under certain conditions (using trigger_error()). |
| 111 | - set_error_handler([$this,'setErrorHandler']); |
|
| 111 | + set_error_handler([$this, 'setErrorHandler']); |
|
| 112 | 112 | |
| 113 | 113 | //Registers a callback to be executed after script execution finishes or exit() is called. |
| 114 | 114 | //Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as |
| 115 | 115 | //they were registered. If you call exit() within one registered shutdown function, |
| 116 | 116 | //processing will stop completely and no other registered shutdown functions will be called. |
| 117 | - register_shutdown_function([$this,'fatalErrorShutdownHandler']); |
|
| 117 | + register_shutdown_function([$this, 'fatalErrorShutdownHandler']); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param null|string $errLine |
| 127 | 127 | * @param null|string $errContext |
| 128 | 128 | */ |
| 129 | - public function setErrorHandler($errNo=null, $errStr=null, $errFile=null, $errLine=null, $errContext=null) |
|
| 129 | + public function setErrorHandler($errNo = null, $errStr = null, $errFile = null, $errLine = null, $errContext = null) |
|
| 130 | 130 | {
|
| 131 | 131 | // in case of a deficiency, |
| 132 | 132 | // we need to boot our general needs to be needed for the exception. |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | //get lang message for exception |
| 154 | 154 | $this->getLangMessageForException(); |
| 155 | 155 | |
| 156 | - if($this->app->has('exceptiontrace')){
|
|
| 156 | + if ($this->app->has('exceptiontrace')) {
|
|
| 157 | 157 | |
| 158 | 158 | $customExceptionTrace = $this->app['exceptiontrace']; |
| 159 | 159 | $this->data['errFile'] = $customExceptionTrace['file']; |
@@ -162,37 +162,36 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $environment = $this->app->environment(); |
| 164 | 164 | |
| 165 | - $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'','',$this->data['errFile']); |
|
| 165 | + $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'', '', $this->data['errFile']); |
|
| 166 | 166 | |
| 167 | - if(Str::startsWith($vendorDirectory,'vendor') |
|
| 168 | - && Str::startsWith($vendorDirectory,'vendor/php-resta')===false) |
|
| 167 | + if (Str::startsWith($vendorDirectory, 'vendor') |
|
| 168 | + && Str::startsWith($vendorDirectory, 'vendor/php-resta')===false) |
|
| 169 | 169 | {
|
| 170 | 170 | $externalMessage = ($environment==="production") ? |
| 171 | - 'An unexpected external error has occurred' : |
|
| 172 | - $this->data['errStrReal']; |
|
| 171 | + 'An unexpected external error has occurred' : $this->data['errStrReal']; |
|
| 173 | 172 | |
| 174 | - $this->result = $this->getAppException($environment,$externalMessage); |
|
| 173 | + $this->result = $this->getAppException($environment, $externalMessage); |
|
| 175 | 174 | |
| 176 | 175 | |
| 177 | 176 | //Get or Set the HTTP response code |
| 178 | 177 | http_response_code(500); |
| 179 | 178 | $this->app->terminate('responseStatus');
|
| 180 | - $this->app->register('responseStatus',500);
|
|
| 179 | + $this->app->register('responseStatus', 500);
|
|
| 181 | 180 | |
| 182 | 181 | |
| 183 | 182 | } |
| 184 | - else{
|
|
| 183 | + else {
|
|
| 185 | 184 | |
| 186 | - $this->result = $this->getAppException($environment,$this->data['errStrReal']); |
|
| 185 | + $this->result = $this->getAppException($environment, $this->data['errStrReal']); |
|
| 187 | 186 | |
| 188 | 187 | //Get or Set the HTTP response code |
| 189 | 188 | http_response_code($this->data['status']); |
| 190 | 189 | } |
| 191 | 190 | |
| 192 | - if($environment==="production"){
|
|
| 191 | + if ($environment==="production") {
|
|
| 193 | 192 | |
| 194 | - $productionLogMessage = $this->getAppException('local',$this->data['errStrReal']);
|
|
| 195 | - $this->app->register('productionLogMessage',$this->app->get('out')->outputFormatter($productionLogMessage));
|
|
| 193 | + $productionLogMessage = $this->getAppException('local', $this->data['errStrReal']);
|
|
| 194 | + $this->app->register('productionLogMessage', $this->app->get('out')->outputFormatter($productionLogMessage));
|
|
| 196 | 195 | } |
| 197 | 196 | |
| 198 | 197 | // exception extender The exception information |
@@ -201,15 +200,15 @@ discard block |
||
| 201 | 200 | |
| 202 | 201 | |
| 203 | 202 | //set json app exception |
| 204 | - $this->app->register('routerResult',$this->result);
|
|
| 203 | + $this->app->register('routerResult', $this->result);
|
|
| 205 | 204 | |
| 206 | 205 | $restaOutHandle = null; |
| 207 | 206 | |
| 208 | - if(!defined('responseApp')){
|
|
| 207 | + if (!defined('responseApp')) {
|
|
| 209 | 208 | $restaOutHandle = $this->app->get('out')->handle();
|
| 210 | 209 | } |
| 211 | 210 | |
| 212 | - if($restaOutHandle===null){
|
|
| 211 | + if ($restaOutHandle===null) {
|
|
| 213 | 212 | |
| 214 | 213 | //header set and symfony response call |
| 215 | 214 | header('Content-type:application/json;charset=utf-8');
|
@@ -217,7 +216,7 @@ discard block |
||
| 217 | 216 | echo json_encode($this->app->get('out')->outputFormatter($this->result));
|
| 218 | 217 | exit(); |
| 219 | 218 | } |
| 220 | - else{
|
|
| 219 | + else {
|
|
| 221 | 220 | echo $restaOutHandle; |
| 222 | 221 | exit(); |
| 223 | 222 | } |
@@ -227,7 +226,7 @@ discard block |
||
| 227 | 226 | * @param $environment |
| 228 | 227 | * @return mixed |
| 229 | 228 | */ |
| 230 | - private function getAppException($environment,$message) |
|
| 229 | + private function getAppException($environment, $message) |
|
| 231 | 230 | {
|
| 232 | 231 | return $this->data['appExceptionSuccess']+$this->data['exception']::$environment( |
| 233 | 232 | $this->data['errNo'], |
@@ -247,7 +246,7 @@ discard block |
||
| 247 | 246 | private function getExceptionExtender() |
| 248 | 247 | {
|
| 249 | 248 | return $this->app->resolve( |
| 250 | - $this->app->get('macro')->call('exceptionExtender',function(){
|
|
| 249 | + $this->app->get('macro')->call('exceptionExtender', function() {
|
|
| 251 | 250 | return ExceptionExtender::class; |
| 252 | 251 | }), |
| 253 | 252 | ['result'=>$this->result])->getResult(); |
@@ -265,13 +264,13 @@ discard block |
||
| 265 | 264 | |
| 266 | 265 | $this->inStackTrace($last_error); |
| 267 | 266 | |
| 268 | - if(!is_null($last_error)){
|
|
| 267 | + if (!is_null($last_error)) {
|
|
| 269 | 268 | |
| 270 | - if(!defined('methodName')){
|
|
| 271 | - define('methodName',null);
|
|
| 269 | + if (!defined('methodName')) {
|
|
| 270 | + define('methodName', null);
|
|
| 272 | 271 | } |
| 273 | 272 | |
| 274 | - if($this->app->has('exceptionFile')){
|
|
| 273 | + if ($this->app->has('exceptionFile')) {
|
|
| 275 | 274 | $last_error['file'] = $this->app['exceptionFile']; |
| 276 | 275 | $last_error['line'] = $this->app['exceptionLine']; |
| 277 | 276 | } |
@@ -291,13 +290,13 @@ discard block |
||
| 291 | 290 | */ |
| 292 | 291 | public function inStackTrace($error) |
| 293 | 292 | {
|
| 294 | - if($this->app->has('urlComponent')){
|
|
| 295 | - if(!preg_match('@'.$this->app['urlComponent']['project'].'@',$error['file'])
|
|
| 296 | - && !$this->app->has('exceptionFile')){
|
|
| 297 | - if(preg_match('@ in\s(.*?)\n@is',$error['message'],$result)){
|
|
| 298 | - $errorMessage = explode(":",$result[1]);
|
|
| 299 | - $this->app->register('exceptionFile',$errorMessage[0]);
|
|
| 300 | - $this->app->register('exceptionLine',$errorMessage[1]);
|
|
| 293 | + if ($this->app->has('urlComponent')) {
|
|
| 294 | + if (!preg_match('@'.$this->app['urlComponent']['project'].'@', $error['file'])
|
|
| 295 | + && !$this->app->has('exceptionFile')) {
|
|
| 296 | + if (preg_match('@ in\s(.*?)\n@is', $error['message'], $result)) {
|
|
| 297 | + $errorMessage = explode(":", $result[1]);
|
|
| 298 | + $this->app->register('exceptionFile', $errorMessage[0]);
|
|
| 299 | + $this->app->register('exceptionLine', $errorMessage[1]);
|
|
| 301 | 300 | } |
| 302 | 301 | } |
| 303 | 302 | } |
@@ -310,33 +309,33 @@ discard block |
||
| 310 | 309 | {
|
| 311 | 310 | $clone = clone $this; |
| 312 | 311 | |
| 313 | - if($this->app->has('exceptionTranslate')){
|
|
| 312 | + if ($this->app->has('exceptionTranslate')) {
|
|
| 314 | 313 | |
| 315 | 314 | $langMessage = trans('exception.'.$this->app->get('exceptionTranslate'));
|
| 316 | 315 | |
| 317 | - if(!is_null($langMessage) && $this->app->has('exceptionTranslateParams')){
|
|
| 316 | + if (!is_null($langMessage) && $this->app->has('exceptionTranslateParams')) {
|
|
| 318 | 317 | |
| 319 | - if(count($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']])){
|
|
| 320 | - foreach ($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']] as $key=>$value){
|
|
| 318 | + if (count($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']])) {
|
|
| 319 | + foreach ($this->app['exceptionTranslateParams'][$this->app['exceptionTranslate']] as $key=>$value) {
|
|
| 321 | 320 | |
| 322 | 321 | $valueLangName = !is_null(trans('default.'.$value)) ? trans('default.'.$value) : $value;
|
| 323 | - $langMessage = preg_replace('@\('.$key.'\)@is',$valueLangName,$langMessage);
|
|
| 322 | + $langMessage = preg_replace('@\('.$key.'\)@is', $valueLangName, $langMessage);
|
|
| 324 | 323 | } |
| 325 | 324 | } |
| 326 | 325 | } |
| 327 | 326 | |
| 328 | - if($langMessage!==null){
|
|
| 327 | + if ($langMessage!==null) {
|
|
| 329 | 328 | $this->data['errStrReal'] = $langMessage; |
| 330 | 329 | } |
| 331 | 330 | } |
| 332 | 331 | |
| 333 | - if(class_exists($this->data['errorClassNamespace']) |
|
| 332 | + if (class_exists($this->data['errorClassNamespace']) |
|
| 334 | 333 | && |
| 335 | - (Str::startsWith($this->data['errorClassNamespace'],'App') |
|
| 336 | - || Str::startsWith($this->data['errorClassNamespace'],__NAMESPACE__))){
|
|
| 334 | + (Str::startsWith($this->data['errorClassNamespace'], 'App') |
|
| 335 | + || Str::startsWith($this->data['errorClassNamespace'], __NAMESPACE__))) {
|
|
| 337 | 336 | |
| 338 | 337 | ClosureDispatcher::bind($this->data['errorClassNamespace'])->call(function() use ($clone) {
|
| 339 | - if(property_exists($this,'lang')){
|
|
| 338 | + if (property_exists($this, 'lang')) {
|
|
| 340 | 339 | $clone->setLang($this->lang); |
| 341 | 340 | } |
| 342 | 341 | }); |
@@ -346,7 +345,7 @@ discard block |
||
| 346 | 345 | |
| 347 | 346 | $langMessage = (!is_null($this->data['lang'])) ? trans('exception.'.$this->data['lang']) : null;
|
| 348 | 347 | |
| 349 | - if($langMessage!==null){
|
|
| 348 | + if ($langMessage!==null) {
|
|
| 350 | 349 | $this->data['errStrReal'] = $langMessage; |
| 351 | 350 | } |
| 352 | 351 | } |
@@ -360,14 +359,14 @@ discard block |
||
| 360 | 359 | {
|
| 361 | 360 | // catch exception via preg match |
| 362 | 361 | // and then clear the Uncaught statement from inside. |
| 363 | - if(preg_match('@(.*?):@is',$this->data['errStrReal'],$errArr)){
|
|
| 362 | + if (preg_match('@(.*?):@is', $this->data['errStrReal'], $errArr)) {
|
|
| 364 | 363 | |
| 365 | - $this->data['errType'] = trim(str_replace('Uncaught','',$errArr[1]));
|
|
| 364 | + $this->data['errType'] = trim(str_replace('Uncaught', '', $errArr[1]));
|
|
| 366 | 365 | $this->data['errorClassNamespace'] = $this->data['errType']; |
| 367 | 366 | } |
| 368 | 367 | |
| 369 | - if(preg_match('@Uncaught@is',$this->data['errStrReal'])
|
|
| 370 | - && preg_match('@(.*?):(.*?)\sin\s@is',$this->data['errStrReal'],$errStrRealArray)){
|
|
| 368 | + if (preg_match('@Uncaught@is', $this->data['errStrReal'])
|
|
| 369 | + && preg_match('@(.*?):(.*?)\sin\s@is', $this->data['errStrReal'], $errStrRealArray)) {
|
|
| 371 | 370 | $this->data['errStrReal'] = trim($errStrRealArray[2]); |
| 372 | 371 | } |
| 373 | 372 | |
@@ -387,7 +386,7 @@ discard block |
||
| 387 | 386 | /** |
| 388 | 387 | * @param null|string $lang |
| 389 | 388 | */ |
| 390 | - public function setLang($lang=null) |
|
| 389 | + public function setLang($lang = null) |
|
| 391 | 390 | {
|
| 392 | 391 | $this->lang = $lang; |
| 393 | 392 | } |