@@ -57,7 +57,7 @@ |
||
| 57 | 57 | throw new \InvalidArgumentException(json_last_error_msg()); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $data = $handler . '(' . $data . ');'; |
|
| 60 | + $data = $handler.'('.$data.');'; |
|
| 61 | 61 | |
| 62 | 62 | return $data; |
| 63 | 63 | } catch (\Exception $e) { |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | if (0 !== strpos($data, '<?xml')) { |
| 49 | 49 | $encoding = $this->options['encoding']; |
| 50 | 50 | $xml = "<?xml version=\"1.0\" encoding=\"{$encoding}\"?>"; |
| 51 | - $data = $xml . $data; |
|
| 51 | + $data = $xml.$data; |
|
| 52 | 52 | } |
| 53 | 53 | return $data; |
| 54 | 54 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | protected function output($data) |
| 32 | 32 | { |
| 33 | 33 | if (!$this->isContent && !is_file($data)) { |
| 34 | - throw new Exception('file not exists:' . $data); |
|
| 34 | + throw new Exception('file not exists:'.$data); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ob_end_clean(); |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $this->header['Pragma'] = 'public'; |
| 54 | 54 | $this->header['Content-Type'] = $mimeType ?: 'application/octet-stream'; |
| 55 | - $this->header['Cache-control'] = 'max-age=' . $this->expire; |
|
| 56 | - $this->header['Content-Disposition'] = $this->openinBrowser ? 'inline' : 'attachment; filename="' . $name . '"'; |
|
| 55 | + $this->header['Cache-control'] = 'max-age='.$this->expire; |
|
| 56 | + $this->header['Content-Disposition'] = $this->openinBrowser ? 'inline' : 'attachment; filename="'.$name.'"'; |
|
| 57 | 57 | $this->header['Content-Length'] = $size; |
| 58 | 58 | $this->header['Content-Transfer-Encoding'] = 'binary'; |
| 59 | - $this->header['Expires'] = gmdate("D, d M Y H:i:s", time() + $this->expire) . ' GMT'; |
|
| 59 | + $this->header['Expires'] = gmdate("D, d M Y H:i:s", time() + $this->expire).' GMT'; |
|
| 60 | 60 | |
| 61 | - $this->lastModified(gmdate('D, d M Y H:i:s', time()) . ' GMT'); |
|
| 61 | + $this->lastModified(gmdate('D, d M Y H:i:s', time()).' GMT'); |
|
| 62 | 62 | |
| 63 | 63 | $data = $this->isContent ? $data : file_get_contents($data); |
| 64 | 64 | return $data; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $this->name = $filename; |
| 130 | 130 | |
| 131 | 131 | if ($extension && false === strpos($filename, '.')) { |
| 132 | - $this->name .= '.' . pathinfo($this->data, PATHINFO_EXTENSION); |
|
| 132 | + $this->name .= '.'.pathinfo($this->data, PATHINFO_EXTENSION); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $this; |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | foreach ($file as $_file) { |
| 120 | 120 | if (is_file($_file)) { |
| 121 | 121 | // 记录加载信息 |
| 122 | - $this->app->log('[ LANG ] ' . $_file); |
|
| 122 | + $this->app->log('[ LANG ] '.$_file); |
|
| 123 | 123 | $_lang = include $_file; |
| 124 | 124 | if (is_array($_lang)) { |
| 125 | 125 | $lang = array_change_key_case($_lang) + $lang; |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | $commandline = $this->commandline; |
| 222 | 222 | |
| 223 | 223 | if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) { |
| 224 | - $commandline = 'cmd /V:ON /E:ON /C "(' . $commandline . ')'; |
|
| 224 | + $commandline = 'cmd /V:ON /E:ON /C "('.$commandline.')'; |
|
| 225 | 225 | foreach ($this->processPipes->getFiles() as $offset => $filename) { |
| 226 | - $commandline .= ' ' . $offset . '>' . Utils::escapeArgument($filename); |
|
| 226 | + $commandline .= ' '.$offset.'>'.Utils::escapeArgument($filename); |
|
| 227 | 227 | } |
| 228 | 228 | $commandline .= '"'; |
| 229 | 229 | |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | */ |
| 862 | 862 | public function setEnv(array $env) |
| 863 | 863 | { |
| 864 | - $env = array_filter($env, function ($value) { |
|
| 864 | + $env = array_filter($env, function($value) { |
|
| 865 | 865 | return !is_array($value); |
| 866 | 866 | }); |
| 867 | 867 | |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | |
| 1037 | 1037 | $descriptors = array_merge($descriptors, [['pipe', 'w']]); |
| 1038 | 1038 | |
| 1039 | - $this->commandline = '(' . $this->commandline . ') 3>/dev/null; code=$?; echo $code >&3; exit $code'; |
|
| 1039 | + $this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code'; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | return $descriptors; |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | protected function buildCallback($callback) |
| 1052 | 1052 | { |
| 1053 | 1053 | $out = self::OUT; |
| 1054 | - $callback = function ($type, $data) use ($callback, $out) { |
|
| 1054 | + $callback = function($type, $data) use ($callback, $out) { |
|
| 1055 | 1055 | if ($out == $type) { |
| 1056 | 1056 | $this->addOutput($data); |
| 1057 | 1057 | } else { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function __construct(App $app, array $config = []) |
| 88 | 88 | { |
| 89 | 89 | $this->app = $app; |
| 90 | - $this->config['cache_path'] = $app->getRuntimePath() . 'temp/'; |
|
| 90 | + $this->config['cache_path'] = $app->getRuntimePath().'temp/'; |
|
| 91 | 91 | $this->config = array_merge($this->config, $config); |
| 92 | 92 | |
| 93 | 93 | $this->config['taglib_begin_origin'] = $this->config['taglib_begin']; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $template = $this->parseTemplateFile($template); |
| 211 | 211 | |
| 212 | 212 | if ($template) { |
| 213 | - $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($this->config['layout_on'] . $this->config['layout_name'] . $template) . '.' . ltrim($this->config['cache_suffix'], '.'); |
|
| 213 | + $cacheFile = $this->config['cache_path'].$this->config['cache_prefix'].md5($this->config['layout_on'].$this->config['layout_name'].$template).'.'.ltrim($this->config['cache_suffix'], '.'); |
|
| 214 | 214 | |
| 215 | 215 | if (!$this->checkCache($cacheFile)) { |
| 216 | 216 | // 缓存无效 重新模板编译 |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | $this->config($config); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . '.' . ltrim($this->config['cache_suffix'], '.'); |
|
| 258 | + $cacheFile = $this->config['cache_path'].$this->config['cache_prefix'].md5($content).'.'.ltrim($this->config['cache_suffix'], '.'); |
|
| 259 | 259 | |
| 260 | 260 | if (!$this->checkCache($cacheFile)) { |
| 261 | 261 | // 缓存无效 模板编译 |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $content = str_replace(array_keys($replace), array_values($replace), $content); |
| 395 | 395 | |
| 396 | 396 | // 添加安全代码及模板引用记录 |
| 397 | - $content = '<?php /*' . serialize($this->includeFile) . '*/ ?>' . "\n" . $content; |
|
| 397 | + $content = '<?php /*'.serialize($this->includeFile).'*/ ?>'."\n".$content; |
|
| 398 | 398 | // 编译存储 |
| 399 | 399 | $this->storage->write($cacheFile, $content); |
| 400 | 400 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | private function parsePhp(&$content) |
| 483 | 483 | { |
| 484 | 484 | // 短标签的情况要将<?标签用echo方式输出 否则无法正常输出xml标识 |
| 485 | - $content = preg_replace('/(<\?(?!php|=|$))/i', '<?php echo \'\\1\'; ?>' . "\n", $content); |
|
| 485 | + $content = preg_replace('/(<\?(?!php|=|$))/i', '<?php echo \'\\1\'; ?>'."\n", $content); |
|
| 486 | 486 | |
| 487 | 487 | // PHP语法检查 |
| 488 | 488 | if ($this->config['tpl_deny_php'] && false !== strpos($content, '<?php')) { |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | private function parseInclude(&$content) |
| 530 | 530 | { |
| 531 | 531 | $regex = $this->getRegex('include'); |
| 532 | - $func = function ($template) use (&$func, &$regex, &$content) { |
|
| 532 | + $func = function($template) use (&$func, &$regex, &$content) { |
|
| 533 | 533 | if (preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) { |
| 534 | 534 | foreach ($matches as $match) { |
| 535 | 535 | $array = $this->parseAttr($match[0]); |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | $v = $this->get(substr($v, 1)); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $parseStr = str_replace('[' . $k . ']', $v, $parseStr); |
|
| 548 | + $parseStr = str_replace('['.$k.']', $v, $parseStr); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $content = str_replace($match[0], $parseStr, $content); |
@@ -569,10 +569,10 @@ discard block |
||
| 569 | 569 | private function parseExtend(&$content) |
| 570 | 570 | { |
| 571 | 571 | $regex = $this->getRegex('extend'); |
| 572 | - $array = $blocks = $baseBlocks = []; |
|
| 572 | + $array = $blocks = $baseBlocks = []; |
|
| 573 | 573 | $extend = ''; |
| 574 | 574 | |
| 575 | - $func = function ($template) use (&$func, &$regex, &$array, &$extend, &$blocks, &$baseBlocks) { |
|
| 575 | + $func = function($template) use (&$func, &$regex, &$array, &$extend, &$blocks, &$baseBlocks) { |
|
| 576 | 576 | if (preg_match($regex, $template, $matches)) { |
| 577 | 577 | if (!isset($array[$matches['name']])) { |
| 578 | 578 | $array[$matches['name']] = 1; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | if (!empty($children[$name])) { |
| 610 | 610 | // 如果包含有子block标签 |
| 611 | 611 | foreach ($children[$name] as $key) { |
| 612 | - $replace = str_replace($baseBlocks[$key]['begin'] . $baseBlocks[$key]['content'] . $baseBlocks[$key]['end'], $blocks[$key]['content'], $replace); |
|
| 612 | + $replace = str_replace($baseBlocks[$key]['begin'].$baseBlocks[$key]['content'].$baseBlocks[$key]['end'], $blocks[$key]['content'], $replace); |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | $parent = $val['parent']; |
| 623 | 623 | |
| 624 | 624 | if (isset($blocks[$parent])) { |
| 625 | - $blocks[$parent]['content'] = str_replace($blocks[$name]['begin'] . $blocks[$name]['content'] . $blocks[$name]['end'], $replace, $blocks[$parent]['content']); |
|
| 625 | + $blocks[$parent]['content'] = str_replace($blocks[$name]['begin'].$blocks[$name]['content'].$blocks[$name]['end'], $replace, $blocks[$parent]['content']); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $blocks[$name]['content'] = $replace; |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | |
| 639 | 639 | if (!$val['parent']) { |
| 640 | 640 | // 替换模板中的顶级block标签 |
| 641 | - $extend = str_replace($val['begin'] . $val['content'] . $val['end'], $replace, $extend); |
|
| 641 | + $extend = str_replace($val['begin'].$val['content'].$val['end'], $replace, $extend); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | } |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | $className = $tagLib; |
| 769 | 769 | $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1); |
| 770 | 770 | } else { |
| 771 | - $className = '\\think\\template\\taglib\\' . ucwords($tagLib); |
|
| 771 | + $className = '\\think\\template\\taglib\\'.ucwords($tagLib); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | $tLib = new $className($this); |
@@ -837,25 +837,25 @@ discard block |
||
| 837 | 837 | // $name为对象或是自动识别,或者含有函数 |
| 838 | 838 | if (isset($array[1])) { |
| 839 | 839 | $this->parseVar($array[2]); |
| 840 | - $name .= $array[1] . $array[2]; |
|
| 840 | + $name .= $array[1].$array[2]; |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | switch ($first) { |
| 844 | 844 | case '?': |
| 845 | 845 | $this->parseVarFunction($name); |
| 846 | - $str = '<?php echo (' . $name . ') ? ' . $name . ' : ' . substr($str, 1) . '; ?>'; |
|
| 846 | + $str = '<?php echo ('.$name.') ? '.$name.' : '.substr($str, 1).'; ?>'; |
|
| 847 | 847 | break; |
| 848 | 848 | case '=': |
| 849 | - $str = '<?php if(' . $name . ') echo ' . substr($str, 1) . '; ?>'; |
|
| 849 | + $str = '<?php if('.$name.') echo '.substr($str, 1).'; ?>'; |
|
| 850 | 850 | break; |
| 851 | 851 | default: |
| 852 | - $str = '<?php echo ' . $name . '?' . $str . '; ?>'; |
|
| 852 | + $str = '<?php echo '.$name.'?'.$str.'; ?>'; |
|
| 853 | 853 | } |
| 854 | 854 | } else { |
| 855 | 855 | if (isset($array[1])) { |
| 856 | 856 | $express = true; |
| 857 | 857 | $this->parseVar($array[2]); |
| 858 | - $express = $name . $array[1] . $array[2]; |
|
| 858 | + $express = $name.$array[1].$array[2]; |
|
| 859 | 859 | } else { |
| 860 | 860 | $express = false; |
| 861 | 861 | } |
@@ -871,15 +871,15 @@ discard block |
||
| 871 | 871 | switch ($first) { |
| 872 | 872 | case '?': |
| 873 | 873 | // {$varname??'xxx'} $varname有定义则输出$varname,否则输出xxx |
| 874 | - $str = '<?php echo ' . ($express ?: 'isset(' . $name . ')') . ' ? ' . $this->parseVarFunction($name) . ' : ' . $str . '; ?>'; |
|
| 874 | + $str = '<?php echo '.($express ?: 'isset('.$name.')').' ? '.$this->parseVarFunction($name).' : '.$str.'; ?>'; |
|
| 875 | 875 | break; |
| 876 | 876 | case '=': |
| 877 | 877 | // {$varname?='xxx'} $varname为真时才输出xxx |
| 878 | - $str = '<?php if(' . ($express ?: '!empty(' . $name . ')') . ') echo ' . $str . '; ?>'; |
|
| 878 | + $str = '<?php if('.($express ?: '!empty('.$name.')').') echo '.$str.'; ?>'; |
|
| 879 | 879 | break; |
| 880 | 880 | case ':': |
| 881 | 881 | // {$varname?:'xxx'} $varname为真时输出$varname,否则输出xxx |
| 882 | - $str = '<?php echo ' . ($express ?: '!empty(' . $name . ')') . ' ? ' . $this->parseVarFunction($name) . ' : ' . $str . '; ?>'; |
|
| 882 | + $str = '<?php echo '.($express ?: '!empty('.$name.')').' ? '.$this->parseVarFunction($name).' : '.$str.'; ?>'; |
|
| 883 | 883 | break; |
| 884 | 884 | default: |
| 885 | 885 | if (strpos($str, ':')) { |
@@ -891,32 +891,32 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | $str = implode(' : ', $array); |
| 893 | 893 | } |
| 894 | - $str = '<?php echo ' . ($express ?: '!empty(' . $name . ')') . ' ? ' . $str . '; ?>'; |
|
| 894 | + $str = '<?php echo '.($express ?: '!empty('.$name.')').' ? '.$str.'; ?>'; |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | } else { |
| 898 | 898 | $this->parseVar($str); |
| 899 | 899 | $this->parseVarFunction($str); |
| 900 | - $str = '<?php echo ' . $str . '; ?>'; |
|
| 900 | + $str = '<?php echo '.$str.'; ?>'; |
|
| 901 | 901 | } |
| 902 | 902 | break; |
| 903 | 903 | case ':': |
| 904 | 904 | // 输出某个函数的结果 |
| 905 | 905 | $str = substr($str, 1); |
| 906 | 906 | $this->parseVar($str); |
| 907 | - $str = '<?php echo ' . $str . '; ?>'; |
|
| 907 | + $str = '<?php echo '.$str.'; ?>'; |
|
| 908 | 908 | break; |
| 909 | 909 | case '~': |
| 910 | 910 | // 执行某个函数 |
| 911 | 911 | $str = substr($str, 1); |
| 912 | 912 | $this->parseVar($str); |
| 913 | - $str = '<?php ' . $str . '; ?>'; |
|
| 913 | + $str = '<?php '.$str.'; ?>'; |
|
| 914 | 914 | break; |
| 915 | 915 | case '-': |
| 916 | 916 | case '+': |
| 917 | 917 | // 输出计算 |
| 918 | 918 | $this->parseVar($str); |
| 919 | - $str = '<?php echo ' . $str . '; ?>'; |
|
| 919 | + $str = '<?php echo '.$str.'; ?>'; |
|
| 920 | 920 | break; |
| 921 | 921 | case '/': |
| 922 | 922 | // 注释标签 |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | break; |
| 928 | 928 | default: |
| 929 | 929 | // 未识别的标签直接返回 |
| 930 | - $str = $this->config['tpl_begin'] . $str . $this->config['tpl_end']; |
|
| 930 | + $str = $this->config['tpl_begin'].$str.$this->config['tpl_end']; |
|
| 931 | 931 | break; |
| 932 | 932 | } |
| 933 | 933 | |
@@ -972,23 +972,23 @@ discard block |
||
| 972 | 972 | if (!empty($vars)) { |
| 973 | 973 | $params = implode('.', $vars); |
| 974 | 974 | if ('true' != $params) { |
| 975 | - $params = '\'' . $params . '\''; |
|
| 975 | + $params = '\''.$params.'\''; |
|
| 976 | 976 | } |
| 977 | 977 | } else { |
| 978 | 978 | $params = ''; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - $parseStr = 'app(\'request\')->' . $method . '(' . $params . ')'; |
|
| 981 | + $parseStr = 'app(\'request\')->'.$method.'('.$params.')'; |
|
| 982 | 982 | } else { |
| 983 | 983 | switch ($this->config['tpl_var_identify']) { |
| 984 | 984 | case 'array': // 识别为数组 |
| 985 | - $parseStr = $first . '[\'' . implode('\'][\'', $vars) . '\']'; |
|
| 985 | + $parseStr = $first.'[\''.implode('\'][\'', $vars).'\']'; |
|
| 986 | 986 | break; |
| 987 | 987 | case 'obj': // 识别为对象 |
| 988 | - $parseStr = $first . '->' . implode('->', $vars); |
|
| 988 | + $parseStr = $first.'->'.implode('->', $vars); |
|
| 989 | 989 | break; |
| 990 | 990 | default: // 自动判断数组或对象 |
| 991 | - $parseStr = '(is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars) . ')'; |
|
| 991 | + $parseStr = '(is_array('.$first.')?'.$first.'[\''.implode('\'][\'', $vars).'\']:'.$first.'->'.implode('->', $vars).')'; |
|
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | } else { |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | if (!$autoescape && false === strpos($varStr, '|')) { |
| 1018 | 1018 | return $varStr; |
| 1019 | 1019 | } elseif ($autoescape && !preg_match('/\|(\s)?raw(\||\s)?/i', $varStr)) { |
| 1020 | - $varStr .= '|' . $this->config['default_filter']; |
|
| 1020 | + $varStr .= '|'.$this->config['default_filter']; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | static $_varFunctionList = []; |
@@ -1052,28 +1052,28 @@ discard block |
||
| 1052 | 1052 | case 'raw': |
| 1053 | 1053 | break; |
| 1054 | 1054 | case 'date': |
| 1055 | - $name = 'date(' . $args[1] . ',!is_numeric(' . $name . ')? strtotime(' . $name . ') : ' . $name . ')'; |
|
| 1055 | + $name = 'date('.$args[1].',!is_numeric('.$name.')? strtotime('.$name.') : '.$name.')'; |
|
| 1056 | 1056 | break; |
| 1057 | 1057 | case 'first': |
| 1058 | - $name = 'current(' . $name . ')'; |
|
| 1058 | + $name = 'current('.$name.')'; |
|
| 1059 | 1059 | break; |
| 1060 | 1060 | case 'last': |
| 1061 | - $name = 'end(' . $name . ')'; |
|
| 1061 | + $name = 'end('.$name.')'; |
|
| 1062 | 1062 | break; |
| 1063 | 1063 | case 'upper': |
| 1064 | - $name = 'strtoupper(' . $name . ')'; |
|
| 1064 | + $name = 'strtoupper('.$name.')'; |
|
| 1065 | 1065 | break; |
| 1066 | 1066 | case 'lower': |
| 1067 | - $name = 'strtolower(' . $name . ')'; |
|
| 1067 | + $name = 'strtolower('.$name.')'; |
|
| 1068 | 1068 | break; |
| 1069 | 1069 | case 'format': |
| 1070 | - $name = 'sprintf(' . $args[1] . ',' . $name . ')'; |
|
| 1070 | + $name = 'sprintf('.$args[1].','.$name.')'; |
|
| 1071 | 1071 | break; |
| 1072 | 1072 | case 'default': // 特殊模板函数 |
| 1073 | 1073 | if (false === strpos($name, '(')) { |
| 1074 | - $name = '(isset(' . $name . ') && (' . $name . ' !== \'\')?' . $name . ':' . $args[1] . ')'; |
|
| 1074 | + $name = '(isset('.$name.') && ('.$name.' !== \'\')?'.$name.':'.$args[1].')'; |
|
| 1075 | 1075 | } else { |
| 1076 | - $name = '(' . $name . ' ?: ' . $args[1] . ')'; |
|
| 1076 | + $name = '('.$name.' ?: '.$args[1].')'; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | break; |
| 1079 | 1079 | default: // 通用模板函数 |
@@ -1113,34 +1113,34 @@ discard block |
||
| 1113 | 1113 | if ($vars) { |
| 1114 | 1114 | switch ($type) { |
| 1115 | 1115 | case 'SERVER': |
| 1116 | - $parseStr = 'app(\'request\')->server(\'' . $param . '\')'; |
|
| 1116 | + $parseStr = 'app(\'request\')->server(\''.$param.'\')'; |
|
| 1117 | 1117 | break; |
| 1118 | 1118 | case 'GET': |
| 1119 | - $parseStr = 'app(\'request\')->get(\'' . $param . '\')'; |
|
| 1119 | + $parseStr = 'app(\'request\')->get(\''.$param.'\')'; |
|
| 1120 | 1120 | break; |
| 1121 | 1121 | case 'POST': |
| 1122 | - $parseStr = 'app(\'request\')->post(\'' . $param . '\')'; |
|
| 1122 | + $parseStr = 'app(\'request\')->post(\''.$param.'\')'; |
|
| 1123 | 1123 | break; |
| 1124 | 1124 | case 'COOKIE': |
| 1125 | - $parseStr = 'app(\'cookie\')->get(\'' . $param . '\')'; |
|
| 1125 | + $parseStr = 'app(\'cookie\')->get(\''.$param.'\')'; |
|
| 1126 | 1126 | break; |
| 1127 | 1127 | case 'SESSION': |
| 1128 | - $parseStr = 'app(\'session\')->get(\'' . $param . '\')'; |
|
| 1128 | + $parseStr = 'app(\'session\')->get(\''.$param.'\')'; |
|
| 1129 | 1129 | break; |
| 1130 | 1130 | case 'ENV': |
| 1131 | - $parseStr = 'app(\'request\')->env(\'' . $param . '\')'; |
|
| 1131 | + $parseStr = 'app(\'request\')->env(\''.$param.'\')'; |
|
| 1132 | 1132 | break; |
| 1133 | 1133 | case 'REQUEST': |
| 1134 | - $parseStr = 'app(\'request\')->request(\'' . $param . '\')'; |
|
| 1134 | + $parseStr = 'app(\'request\')->request(\''.$param.'\')'; |
|
| 1135 | 1135 | break; |
| 1136 | 1136 | case 'CONST': |
| 1137 | 1137 | $parseStr = strtoupper($param); |
| 1138 | 1138 | break; |
| 1139 | 1139 | case 'LANG': |
| 1140 | - $parseStr = 'app(\'lang\')->get(\'' . $param . '\')'; |
|
| 1140 | + $parseStr = 'app(\'lang\')->get(\''.$param.'\')'; |
|
| 1141 | 1141 | break; |
| 1142 | 1142 | case 'CONFIG': |
| 1143 | - $parseStr = 'app(\'config\')->get(\'' . $param . '\')'; |
|
| 1143 | + $parseStr = 'app(\'config\')->get(\''.$param.'\')'; |
|
| 1144 | 1144 | break; |
| 1145 | 1145 | default: |
| 1146 | 1146 | $parseStr = '\'\''; |
@@ -1155,10 +1155,10 @@ discard block |
||
| 1155 | 1155 | $parseStr = 'app()->version()'; |
| 1156 | 1156 | break; |
| 1157 | 1157 | case 'LDELIM': |
| 1158 | - $parseStr = '\'' . ltrim($this->config['tpl_begin'], '\\') . '\''; |
|
| 1158 | + $parseStr = '\''.ltrim($this->config['tpl_begin'], '\\').'\''; |
|
| 1159 | 1159 | break; |
| 1160 | 1160 | case 'RDELIM': |
| 1161 | - $parseStr = '\'' . ltrim($this->config['tpl_end'], '\\') . '\''; |
|
| 1161 | + $parseStr = '\''.ltrim($this->config['tpl_end'], '\\').'\''; |
|
| 1162 | 1162 | break; |
| 1163 | 1163 | default: |
| 1164 | 1164 | if (defined($type)) { |
@@ -1225,12 +1225,12 @@ discard block |
||
| 1225 | 1225 | |
| 1226 | 1226 | if ($this->config['view_base']) { |
| 1227 | 1227 | $module = isset($module) ? $module : $this->app['request']->module(); |
| 1228 | - $path = $this->config['view_base'] . ($module ? $module . DIRECTORY_SEPARATOR : ''); |
|
| 1228 | + $path = $this->config['view_base'].($module ? $module.DIRECTORY_SEPARATOR : ''); |
|
| 1229 | 1229 | } else { |
| 1230 | - $path = isset($module) ? $this->app->getAppPath() . $module . DIRECTORY_SEPARATOR . basename($this->config['view_path']) . DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
| 1230 | + $path = isset($module) ? $this->app->getAppPath().$module.DIRECTORY_SEPARATOR.basename($this->config['view_path']).DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | - $template = $path . $template . '.' . ltrim($this->config['view_suffix'], '.'); |
|
| 1233 | + $template = $path.$template.'.'.ltrim($this->config['view_suffix'], '.'); |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | 1236 | if (is_file($template)) { |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | return $template; |
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | - throw new TemplateNotFoundException('template not exists:' . $template, $template); |
|
| 1243 | + throw new TemplateNotFoundException('template not exists:'.$template, $template); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1257,9 +1257,9 @@ discard block |
||
| 1257 | 1257 | $end = $this->config['tpl_end']; |
| 1258 | 1258 | |
| 1259 | 1259 | if (strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1) { |
| 1260 | - $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>[^' . $end . ']*))' . $end; |
|
| 1260 | + $regex = $begin.'((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>[^'.$end.']*))'.$end; |
|
| 1261 | 1261 | } else { |
| 1262 | - $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>(?:(?!' . $end . ').)*))' . $end; |
|
| 1262 | + $regex = $begin.'((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>(?:(?!'.$end.').)*))'.$end; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | } else { |
| 1265 | 1265 | $begin = $this->config['taglib_begin']; |
@@ -1269,20 +1269,20 @@ discard block |
||
| 1269 | 1269 | switch ($tagName) { |
| 1270 | 1270 | case 'block': |
| 1271 | 1271 | if ($single) { |
| 1272 | - $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P<name>[\$\w\-\/\.]+)\\1(?>[^' . $end . ']*)|\/' . $tagName . ')' . $end; |
|
| 1272 | + $regex = $begin.'(?:'.$tagName.'\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P<name>[\$\w\-\/\.]+)\\1(?>[^'.$end.']*)|\/'.$tagName.')'.$end; |
|
| 1273 | 1273 | } else { |
| 1274 | - $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P<name>[\$\w\-\/\.]+)\\1(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end; |
|
| 1274 | + $regex = $begin.'(?:'.$tagName.'\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P<name>[\$\w\-\/\.]+)\\1(?>(?:(?!'.$end.').)*)|\/'.$tagName.')'.$end; |
|
| 1275 | 1275 | } |
| 1276 | 1276 | break; |
| 1277 | 1277 | case 'literal': |
| 1278 | 1278 | if ($single) { |
| 1279 | - $regex = '(' . $begin . $tagName . '\b(?>[^' . $end . ']*)' . $end . ')'; |
|
| 1280 | - $regex .= '(?:(?>[^' . $begin . ']*)(?>(?!' . $begin . '(?>' . $tagName . '\b[^' . $end . ']*|\/' . $tagName . ')' . $end . ')' . $begin . '[^' . $begin . ']*)*)'; |
|
| 1281 | - $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; |
|
| 1279 | + $regex = '('.$begin.$tagName.'\b(?>[^'.$end.']*)'.$end.')'; |
|
| 1280 | + $regex .= '(?:(?>[^'.$begin.']*)(?>(?!'.$begin.'(?>'.$tagName.'\b[^'.$end.']*|\/'.$tagName.')'.$end.')'.$begin.'[^'.$begin.']*)*)'; |
|
| 1281 | + $regex .= '('.$begin.'\/'.$tagName.$end.')'; |
|
| 1282 | 1282 | } else { |
| 1283 | - $regex = '(' . $begin . $tagName . '\b(?>(?:(?!' . $end . ').)*)' . $end . ')'; |
|
| 1284 | - $regex .= '(?:(?>(?:(?!' . $begin . ').)*)(?>(?!' . $begin . '(?>' . $tagName . '\b(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end . ')' . $begin . '(?>(?:(?!' . $begin . ').)*))*)'; |
|
| 1285 | - $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; |
|
| 1283 | + $regex = '('.$begin.$tagName.'\b(?>(?:(?!'.$end.').)*)'.$end.')'; |
|
| 1284 | + $regex .= '(?:(?>(?:(?!'.$begin.').)*)(?>(?!'.$begin.'(?>'.$tagName.'\b(?>(?:(?!'.$end.').)*)|\/'.$tagName.')'.$end.')'.$begin.'(?>(?:(?!'.$begin.').)*))*)'; |
|
| 1285 | + $regex .= '('.$begin.'\/'.$tagName.$end.')'; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | break; |
| 1288 | 1288 | case 'restoreliteral': |
@@ -1297,15 +1297,15 @@ discard block |
||
| 1297 | 1297 | $name = 'name'; |
| 1298 | 1298 | } |
| 1299 | 1299 | if ($single) { |
| 1300 | - $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P<name>[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^' . $end . ']*)' . $end; |
|
| 1300 | + $regex = $begin.$tagName.'\b\s+(?>(?:(?!'.$name.'=).)*)\b'.$name.'=([\'\"])(?P<name>[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^'.$end.']*)'.$end; |
|
| 1301 | 1301 | } else { |
| 1302 | - $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P<name>[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!' . $end . ').)*)' . $end; |
|
| 1302 | + $regex = $begin.$tagName.'\b\s+(?>(?:(?!'.$name.'=).)*)\b'.$name.'=([\'\"])(?P<name>[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!'.$end.').)*)'.$end; |
|
| 1303 | 1303 | } |
| 1304 | 1304 | break; |
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - return '/' . $regex . '/is'; |
|
| 1308 | + return '/'.$regex.'/is'; |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | public function __debugInfo() |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function hidden($hidden = [], $override = false) |
| 43 | 43 | { |
| 44 | - $this->each(function ($model) use ($hidden, $override) { |
|
| 44 | + $this->each(function($model) use ($hidden, $override) { |
|
| 45 | 45 | /** @var Model $model */ |
| 46 | 46 | $model->hidden($hidden, $override); |
| 47 | 47 | }); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function visible($visible = [], $override = false) |
| 60 | 60 | { |
| 61 | - $this->each(function ($model) use ($visible, $override) { |
|
| 61 | + $this->each(function($model) use ($visible, $override) { |
|
| 62 | 62 | /** @var Model $model */ |
| 63 | 63 | $model->visible($visible, $override); |
| 64 | 64 | }); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function append($append = [], $override = false) |
| 77 | 77 | { |
| 78 | - $this->each(function ($model) use ($append, $override) { |
|
| 78 | + $this->each(function($model) use ($append, $override) { |
|
| 79 | 79 | /** @var Model $model */ |
| 80 | 80 | $model && $model->append($append, $override); |
| 81 | 81 | }); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function withAttr($name, $callback = null) |
| 94 | 94 | { |
| 95 | - $this->each(function ($model) use ($name, $callback) { |
|
| 95 | + $this->each(function($model) use ($name, $callback) { |
|
| 96 | 96 | /** @var Model $model */ |
| 97 | 97 | $model && $model->withAttribute($name, $callback); |
| 98 | 98 | }); |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | foreach ($fields as &$field) { |
| 119 | 119 | if (false === strpos($field, '.')) { |
| 120 | - $field = $model . '.' . $field; |
|
| 120 | + $field = $model.'.'.$field; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } else { |
| 124 | - $fields = $model . '.*'; |
|
| 124 | + $fields = $model.'.*'; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $fields; |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | foreach ($where as $key => &$val) { |
| 133 | 133 | if (is_string($key)) { |
| 134 | - $where[] = [false === strpos($key, '.') ? $relation . '.' . $key : $key, '=', $val]; |
|
| 134 | + $where[] = [false === strpos($key, '.') ? $relation.'.'.$key : $key, '=', $val]; |
|
| 135 | 135 | unset($where[$key]); |
| 136 | 136 | } elseif (isset($val[0]) && false === strpos($val[0], '.')) { |
| 137 | - $val[0] = $relation . '.' . $val[0]; |
|
| 137 | + $val[0] = $relation.'.'.$val[0]; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | return $result === $this->query && !in_array(strtolower($method), ['fetchsql', 'fetchpdo']) ? $this : $result; |
| 183 | 183 | } else { |
| 184 | - throw new Exception('method not exists:' . __CLASS__ . '->' . $method); |
|
| 184 | + throw new Exception('method not exists:'.__CLASS__.'->'.$method); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } elseif (array_key_exists($name, $this->relation)) { |
| 272 | 272 | return $this->relation[$name]; |
| 273 | 273 | } |
| 274 | - throw new InvalidArgumentException('property not exists:' . static::class . '->' . $name); |
|
| 274 | + throw new InvalidArgumentException('property not exists:'.static::class.'->'.$name); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if ($this->force) { |
| 285 | 285 | $data = $this->data; |
| 286 | 286 | } else { |
| 287 | - $data = array_udiff_assoc($this->data, $this->origin, function ($a, $b) { |
|
| 287 | + $data = array_udiff_assoc($this->data, $this->origin, function($a, $b) { |
|
| 288 | 288 | if ((empty($a) || empty($b)) && $a !== $b) { |
| 289 | 289 | return 1; |
| 290 | 290 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $value = $this->autoWriteTimestamp($name); |
| 325 | 325 | } else { |
| 326 | 326 | // 检测修改器 |
| 327 | - $method = 'set' . Loader::parseName($name, 1) . 'Attr'; |
|
| 327 | + $method = 'set'.Loader::parseName($name, 1).'Attr'; |
|
| 328 | 328 | |
| 329 | 329 | if (method_exists($this, $method)) { |
| 330 | 330 | $origin = $this->data; |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | // 检测属性获取器 |
| 483 | 483 | $fieldName = Loader::parseName($name); |
| 484 | - $method = 'get' . Loader::parseName($name, 1) . 'Attr'; |
|
| 484 | + $method = 'get'.Loader::parseName($name, 1).'Attr'; |
|
| 485 | 485 | |
| 486 | 486 | if (isset($this->withAttr[$fieldName])) { |
| 487 | 487 | if ($notFound && $relation = $this->isRelationAttr($name)) { |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $key = is_numeric($key) ? $attr : $key; |
| 541 | 541 | |
| 542 | 542 | if (isset($item[$key])) { |
| 543 | - throw new Exception('bind attr has exists:' . $key); |
|
| 543 | + throw new Exception('bind attr has exists:'.$key); |
|
| 544 | 544 | } else { |
| 545 | 545 | $item[$key] = $value ? $value->getAttr($attr) : null; |
| 546 | 546 | } |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - throw new InvalidArgumentException('property not exists:' . static::class . '->' . $name); |
|
| 559 | + throw new InvalidArgumentException('property not exists:'.static::class.'->'.$name); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |