Passed
Pull Request — 5.1 (#2217)
by
unknown
13:33
created
library/think/template/taglib/Cx.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function tagPhp($tag, $content)
64 64
     {
65
-        $parseStr = '<?php ' . $content . ' ?>';
65
+        $parseStr = '<?php '.$content.' ?>';
66 66
         return $parseStr;
67 67
     }
68 68
 
@@ -93,28 +93,28 @@  discard block
 block discarded – undo
93 93
 
94 94
         if (':' == $flag) {
95 95
             $name = $this->autoBuildVar($name);
96
-            $parseStr .= '$_result=' . $name . ';';
96
+            $parseStr .= '$_result='.$name.';';
97 97
             $name = '$_result';
98 98
         } else {
99 99
             $name = $this->autoBuildVar($name);
100 100
         }
101 101
 
102
-        $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): $' . $key . ' = 0;';
102
+        $parseStr .= 'if(is_array('.$name.') || '.$name.' instanceof \think\Collection || '.$name.' instanceof \think\Paginator): $'.$key.' = 0;';
103 103
 
104 104
         // 设置了输出数组长度
105 105
         if (0 != $offset || 'null' != $length) {
106
-            $parseStr .= '$__LIST__ = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); ';
106
+            $parseStr .= '$__LIST__ = is_array('.$name.') ? array_slice('.$name.','.$offset.','.$length.', true) : '.$name.'->slice('.$offset.','.$length.', true); ';
107 107
         } else {
108
-            $parseStr .= ' $__LIST__ = ' . $name . ';';
108
+            $parseStr .= ' $__LIST__ = '.$name.';';
109 109
         }
110 110
 
111
-        $parseStr .= 'if( count($__LIST__)==0 ) : echo "' . $empty . '" ;';
111
+        $parseStr .= 'if( count($__LIST__)==0 ) : echo "'.$empty.'" ;';
112 112
         $parseStr .= 'else: ';
113
-        $parseStr .= 'foreach($__LIST__ as $key=>$' . $id . '): ';
114
-        $parseStr .= '$mod = ($' . $key . ' % ' . $mod . ' );';
115
-        $parseStr .= '++$' . $key . ';?>';
113
+        $parseStr .= 'foreach($__LIST__ as $key=>$'.$id.'): ';
114
+        $parseStr .= '$mod = ($'.$key.' % '.$mod.' );';
115
+        $parseStr .= '++$'.$key.';?>';
116 116
         $parseStr .= $content;
117
-        $parseStr .= '<?php endforeach; endif; else: echo "' . $empty . '" ;endif; ?>';
117
+        $parseStr .= '<?php endforeach; endif; else: echo "'.$empty.'" ;endif; ?>';
118 118
 
119 119
         if (!empty($parseStr)) {
120 120
             return $parseStr;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         if (!empty($tag['expression'])) {
141 141
             $expression = ltrim(rtrim($tag['expression'], ')'), '(');
142 142
             $expression = $this->autoBuildVar($expression);
143
-            $parseStr   = '<?php foreach(' . $expression . '): ?>';
143
+            $parseStr   = '<?php foreach('.$expression.'): ?>';
144 144
             $parseStr .= $content;
145 145
             $parseStr .= '<?php endforeach; ?>';
146 146
             return $parseStr;
@@ -157,51 +157,51 @@  discard block
 block discarded – undo
157 157
 
158 158
         // 支持用函数传数组
159 159
         if (':' == substr($name, 0, 1)) {
160
-            $var  = '$_' . uniqid();
160
+            $var  = '$_'.uniqid();
161 161
             $name = $this->autoBuildVar($name);
162
-            $parseStr .= $var . '=' . $name . '; ';
162
+            $parseStr .= $var.'='.$name.'; ';
163 163
             $name = $var;
164 164
         } else {
165 165
             $name = $this->autoBuildVar($name);
166 166
         }
167 167
 
168
-        $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): ';
168
+        $parseStr .= 'if(is_array('.$name.') || '.$name.' instanceof \think\Collection || '.$name.' instanceof \think\Paginator): ';
169 169
 
170 170
         // 设置了输出数组长度
171 171
         if (0 != $offset || 'null' != $length) {
172 172
             if (!isset($var)) {
173
-                $var = '$_' . uniqid();
173
+                $var = '$_'.uniqid();
174 174
             }
175
-            $parseStr .= $var . ' = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); ';
175
+            $parseStr .= $var.' = is_array('.$name.') ? array_slice('.$name.','.$offset.','.$length.', true) : '.$name.'->slice('.$offset.','.$length.', true); ';
176 176
         } else {
177 177
             $var = &$name;
178 178
         }
179 179
 
180
-        $parseStr .= 'if( count(' . $var . ')==0 ) : echo "' . $empty . '" ;';
180
+        $parseStr .= 'if( count('.$var.')==0 ) : echo "'.$empty.'" ;';
181 181
         $parseStr .= 'else: ';
182 182
 
183 183
         // 设置了索引项
184 184
         if (isset($tag['index'])) {
185 185
             $index = $tag['index'];
186
-            $parseStr .= '$' . $index . '=0; ';
186
+            $parseStr .= '$'.$index.'=0; ';
187 187
         }
188 188
 
189
-        $parseStr .= 'foreach(' . $var . ' as $' . $key . '=>$' . $item . '): ';
189
+        $parseStr .= 'foreach('.$var.' as $'.$key.'=>$'.$item.'): ';
190 190
 
191 191
         // 设置了索引项
192 192
         if (isset($tag['index'])) {
193 193
             $index = $tag['index'];
194 194
             if (isset($tag['mod'])) {
195 195
                 $mod = (int) $tag['mod'];
196
-                $parseStr .= '$mod = ($' . $index . ' % ' . $mod . '); ';
196
+                $parseStr .= '$mod = ($'.$index.' % '.$mod.'); ';
197 197
             }
198
-            $parseStr .= '++$' . $index . '; ';
198
+            $parseStr .= '++$'.$index.'; ';
199 199
         }
200 200
 
201 201
         $parseStr .= '?>';
202 202
         // 循环体中的内容
203 203
         $parseStr .= $content;
204
-        $parseStr .= '<?php endforeach; endif; else: echo "' . $empty . '" ;endif; ?>';
204
+        $parseStr .= '<?php endforeach; endif; else: echo "'.$empty.'" ;endif; ?>';
205 205
 
206 206
         if (!empty($parseStr)) {
207 207
             return $parseStr;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
229 229
         $condition = $this->parseCondition($condition);
230
-        $parseStr  = '<?php if(' . $condition . '): ?>' . $content . '<?php endif; ?>';
230
+        $parseStr  = '<?php if('.$condition.'): ?>'.$content.'<?php endif; ?>';
231 231
 
232 232
         return $parseStr;
233 233
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     {
245 245
         $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
246 246
         $condition = $this->parseCondition($condition);
247
-        $parseStr  = '<?php elseif(' . $condition . '): ?>';
247
+        $parseStr  = '<?php elseif('.$condition.'): ?>';
248 248
 
249 249
         return $parseStr;
250 250
     }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     {
281 281
         $name     = !empty($tag['expression']) ? $tag['expression'] : $tag['name'];
282 282
         $name     = $this->autoBuildVar($name);
283
-        $parseStr = '<?php switch(' . $name . '): ?>' . $content . '<?php endswitch; ?>';
283
+        $parseStr = '<?php switch('.$name.'): ?>'.$content.'<?php endswitch; ?>';
284 284
 
285 285
         return $parseStr;
286 286
     }
@@ -299,18 +299,18 @@  discard block
 block discarded – undo
299 299
 
300 300
         if ('$' == $flag || ':' == $flag) {
301 301
             $value = $this->autoBuildVar($value);
302
-            $value = 'case ' . $value . ':';
302
+            $value = 'case '.$value.':';
303 303
         } elseif (strpos($value, '|')) {
304 304
             $values = explode('|', $value);
305 305
             $value  = '';
306 306
             foreach ($values as $val) {
307
-                $value .= 'case "' . addslashes($val) . '":';
307
+                $value .= 'case "'.addslashes($val).'":';
308 308
             }
309 309
         } else {
310
-            $value = 'case "' . $value . '":';
310
+            $value = 'case "'.$value.'":';
311 311
         }
312 312
 
313
-        $parseStr = '<?php ' . $value . ' ?>' . $content;
313
+        $parseStr = '<?php '.$value.' ?>'.$content;
314 314
         $isBreak  = isset($tag['break']) ? $tag['break'] : '';
315 315
 
316 316
         if ('' == $isBreak || $isBreak) {
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         if ('$' == $flag || ':' == $flag) {
356 356
             $value = $this->autoBuildVar($value);
357 357
         } else {
358
-            $value = '\'' . $value . '\'';
358
+            $value = '\''.$value.'\'';
359 359
         }
360 360
 
361 361
         switch ($type) {
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
                 $type = 'neq';
367 367
                 break;
368 368
         }
369
-        $type     = $this->parseCondition(' ' . $type . ' ');
370
-        $parseStr = '<?php if(' . $name . ' ' . $type . ' ' . $value . '): ?>' . $content . '<?php endif; ?>';
369
+        $type     = $this->parseCondition(' '.$type.' ');
370
+        $parseStr = '<?php if('.$name.' '.$type.' '.$value.'): ?>'.$content.'<?php endif; ?>';
371 371
 
372 372
         return $parseStr;
373 373
     }
@@ -393,19 +393,19 @@  discard block
 block discarded – undo
393 393
 
394 394
         if ('$' == $flag || ':' == $flag) {
395 395
             $value = $this->autoBuildVar($value);
396
-            $str   = 'is_array(' . $value . ')?' . $value . ':explode(\',\',' . $value . ')';
396
+            $str   = 'is_array('.$value.')?'.$value.':explode(\',\','.$value.')';
397 397
         } else {
398
-            $value = '"' . $value . '"';
399
-            $str   = 'explode(\',\',' . $value . ')';
398
+            $value = '"'.$value.'"';
399
+            $str   = 'explode(\',\','.$value.')';
400 400
         }
401 401
 
402 402
         if ('between' == $type) {
403
-            $parseStr = '<?php $_RANGE_VAR_=' . $str . ';if(' . $name . '>= $_RANGE_VAR_[0] && ' . $name . '<= $_RANGE_VAR_[1]):?>' . $content . '<?php endif; ?>';
403
+            $parseStr = '<?php $_RANGE_VAR_='.$str.';if('.$name.'>= $_RANGE_VAR_[0] && '.$name.'<= $_RANGE_VAR_[1]):?>'.$content.'<?php endif; ?>';
404 404
         } elseif ('notbetween' == $type) {
405
-            $parseStr = '<?php $_RANGE_VAR_=' . $str . ';if(' . $name . '<$_RANGE_VAR_[0] || ' . $name . '>$_RANGE_VAR_[1]):?>' . $content . '<?php endif; ?>';
405
+            $parseStr = '<?php $_RANGE_VAR_='.$str.';if('.$name.'<$_RANGE_VAR_[0] || '.$name.'>$_RANGE_VAR_[1]):?>'.$content.'<?php endif; ?>';
406 406
         } else {
407 407
             $fun      = ('in' == $type) ? 'in_array' : '!in_array';
408
-            $parseStr = '<?php if(' . $fun . '((' . $name . '), ' . $str . ')): ?>' . $content . '<?php endif; ?>';
408
+            $parseStr = '<?php if('.$fun.'(('.$name.'), '.$str.')): ?>'.$content.'<?php endif; ?>';
409 409
         }
410 410
 
411 411
         return $parseStr;
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     {
425 425
         $name     = $tag['name'];
426 426
         $name     = $this->autoBuildVar($name);
427
-        $parseStr = '<?php if(isset(' . $name . ')): ?>' . $content . '<?php endif; ?>';
427
+        $parseStr = '<?php if(isset('.$name.')): ?>'.$content.'<?php endif; ?>';
428 428
 
429 429
         return $parseStr;
430 430
     }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     {
443 443
         $name     = $tag['name'];
444 444
         $name     = $this->autoBuildVar($name);
445
-        $parseStr = '<?php if(!isset(' . $name . ')): ?>' . $content . '<?php endif; ?>';
445
+        $parseStr = '<?php if(!isset('.$name.')): ?>'.$content.'<?php endif; ?>';
446 446
 
447 447
         return $parseStr;
448 448
     }
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
     {
461 461
         $name     = $tag['name'];
462 462
         $name     = $this->autoBuildVar($name);
463
-        $parseStr = '<?php if(empty(' . $name . ') || ((' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator ) && ' . $name . '->isEmpty())): ?>' . $content . '<?php endif; ?>';
463
+        $parseStr = '<?php if(empty('.$name.') || (('.$name.' instanceof \think\Collection || '.$name.' instanceof \think\Paginator ) && '.$name.'->isEmpty())): ?>'.$content.'<?php endif; ?>';
464 464
 
465 465
         return $parseStr;
466 466
     }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     {
479 479
         $name     = $tag['name'];
480 480
         $name     = $this->autoBuildVar($name);
481
-        $parseStr = '<?php if(!(empty(' . $name . ') || ((' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator ) && ' . $name . '->isEmpty()))): ?>' . $content . '<?php endif; ?>';
481
+        $parseStr = '<?php if(!(empty('.$name.') || (('.$name.' instanceof \think\Collection || '.$name.' instanceof \think\Paginator ) && '.$name.'->isEmpty()))): ?>'.$content.'<?php endif; ?>';
482 482
 
483 483
         return $parseStr;
484 484
     }
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     public function tagDefined($tag, $content)
495 495
     {
496 496
         $name     = $tag['name'];
497
-        $parseStr = '<?php if(defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
497
+        $parseStr = '<?php if(defined("'.$name.'")): ?>'.$content.'<?php endif; ?>';
498 498
 
499 499
         return $parseStr;
500 500
     }
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
     public function tagNotdefined($tag, $content)
511 511
     {
512 512
         $name     = $tag['name'];
513
-        $parseStr = '<?php if(!defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
513
+        $parseStr = '<?php if(!defined("'.$name.'")): ?>'.$content.'<?php endif; ?>';
514 514
 
515 515
         return $parseStr;
516 516
     }
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
         if (isset($tag['value'])) {
536 536
             $name = $tag['value'];
537 537
             $name = $this->autoBuildVar($name);
538
-            $name = 'isset(' . $name . ')';
539
-            $parseStr .= '<?php if(' . $name . '): ?>';
538
+            $name = 'isset('.$name.')';
539
+            $parseStr .= '<?php if('.$name.'): ?>';
540 540
             $endStr = '<?php endif; ?>';
541 541
         }
542 542
 
@@ -547,18 +547,18 @@  discard block
 block discarded – undo
547 547
             $type = strtolower(substr(strrchr($val, '.'), 1));
548 548
             switch ($type) {
549 549
                 case 'js':
550
-                    $parseStr .= '<script type="text/javascript" src="' . $val . '"></script>';
550
+                    $parseStr .= '<script type="text/javascript" src="'.$val.'"></script>';
551 551
                     break;
552 552
                 case 'css':
553
-                    $parseStr .= '<link rel="stylesheet" type="text/css" href="' . $val . '" />';
553
+                    $parseStr .= '<link rel="stylesheet" type="text/css" href="'.$val.'" />';
554 554
                     break;
555 555
                 case 'php':
556
-                    $parseStr .= '<?php include "' . $val . '"; ?>';
556
+                    $parseStr .= '<?php include "'.$val.'"; ?>';
557 557
                     break;
558 558
             }
559 559
         }
560 560
 
561
-        return $parseStr . $endStr;
561
+        return $parseStr.$endStr;
562 562
     }
563 563
 
564 564
     /**
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
         if ('$' == $flag || ':' == $flag) {
579 579
             $value = $this->autoBuildVar($tag['value']);
580 580
         } else {
581
-            $value = '\'' . $tag['value'] . '\'';
581
+            $value = '\''.$tag['value'].'\'';
582 582
         }
583 583
 
584
-        $parseStr = '<?php ' . $name . ' = ' . $value . '; ?>';
584
+        $parseStr = '<?php '.$name.' = '.$value.'; ?>';
585 585
 
586 586
         return $parseStr;
587 587
     }
@@ -597,16 +597,16 @@  discard block
 block discarded – undo
597 597
      */
598 598
     public function tagDefine($tag, $content)
599 599
     {
600
-        $name = '\'' . $tag['name'] . '\'';
600
+        $name = '\''.$tag['name'].'\'';
601 601
         $flag = substr($tag['value'], 0, 1);
602 602
 
603 603
         if ('$' == $flag || ':' == $flag) {
604 604
             $value = $this->autoBuildVar($tag['value']);
605 605
         } else {
606
-            $value = '\'' . $tag['value'] . '\'';
606
+            $value = '\''.$tag['value'].'\'';
607 607
         }
608 608
 
609
-        $parseStr = '<?php define(' . $name . ', ' . $value . '); ?>';
609
+        $parseStr = '<?php define('.$name.', '.$value.'); ?>';
610 610
 
611 611
         return $parseStr;
612 612
     }
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
             }
660 660
         }
661 661
 
662
-        $parseStr = '<?php $__FOR_START_' . $rand . '__=' . $start . ';$__FOR_END_' . $rand . '__=' . $end . ';';
663
-        $parseStr .= 'for($' . $name . '=$__FOR_START_' . $rand . '__;' . $this->parseCondition('$' . $name . ' ' . $comparison . ' $__FOR_END_' . $rand . '__') . ';$' . $name . '+=' . $step . '){ ?>';
662
+        $parseStr = '<?php $__FOR_START_'.$rand.'__='.$start.';$__FOR_END_'.$rand.'__='.$end.';';
663
+        $parseStr .= 'for($'.$name.'=$__FOR_START_'.$rand.'__;'.$this->parseCondition('$'.$name.' '.$comparison.' $__FOR_END_'.$rand.'__').';$'.$name.'+='.$step.'){ ?>';
664 664
         $parseStr .= $content;
665 665
         $parseStr .= '<?php } ?>';
666 666
 
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
         $suffix = isset($tag['suffix']) ? $tag['suffix'] : 'true';
683 683
         $domain = isset($tag['domain']) ? $tag['domain'] : 'false';
684 684
 
685
-        return '<?php echo url("' . $url . '","' . $vars . '",' . $suffix . ',' . $domain . ');?>';
685
+        return '<?php echo url("'.$url.'","'.$vars.'",'.$suffix.','.$domain.');?>';
686 686
     }
687 687
 
688 688
     /**
@@ -707,17 +707,17 @@  discard block
 block discarded – undo
707 707
         $name = !empty($tag['name']) ? $tag['name'] : 'func';
708 708
         $vars = !empty($tag['vars']) ? $tag['vars'] : '';
709 709
         $call = !empty($tag['call']) ? $tag['call'] : '';
710
-        $use  = ['&$' . $name];
710
+        $use  = ['&$'.$name];
711 711
 
712 712
         if (!empty($tag['use'])) {
713 713
             foreach (explode(',', $tag['use']) as $val) {
714
-                $use[] = '&' . ltrim(trim($val), '&');
714
+                $use[] = '&'.ltrim(trim($val), '&');
715 715
             }
716 716
         }
717 717
 
718
-        $parseStr = '<?php $' . $name . '=function(' . $vars . ') use(' . implode(',', $use) . ') {';
719
-        $parseStr .= ' ?>' . $content . '<?php }; ';
720
-        $parseStr .= $call ? '$' . $name . '(' . $call . '); ?>' : '?>';
718
+        $parseStr = '<?php $'.$name.'=function('.$vars.') use('.implode(',', $use).') {';
719
+        $parseStr .= ' ?>'.$content.'<?php }; ';
720
+        $parseStr .= $call ? '$'.$name.'('.$call.'); ?>' : '?>';
721 721
 
722 722
         return $parseStr;
723 723
     }
Please login to merge, or discard this patch.
library/think/template/driver/File.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
         // 生成模板缓存文件
37 37
         if (false === file_put_contents($cacheFile, $content)) {
38
-            throw new Exception('cache write error:' . $cacheFile, 11602);
38
+            throw new Exception('cache write error:'.$cacheFile, 11602);
39 39
         }
40 40
     }
41 41
 
Please login to merge, or discard this patch.
library/think/template/TagLib.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
     public function parseTag(&$content, $lib = '')
88 88
     {
89 89
         $tags = [];
90
-        $lib  = $lib ? strtolower($lib) . ':' : '';
90
+        $lib  = $lib ? strtolower($lib).':' : '';
91 91
 
92 92
         foreach ($this->tags as $name => $val) {
93 93
             $close                      = !isset($val['close']) || $val['close'] ? 1 : 0;
94
-            $tags[$close][$lib . $name] = $name;
94
+            $tags[$close][$lib.$name] = $name;
95 95
             if (isset($val['alias'])) {
96 96
                 // 别名设置
97 97
                 $array = (array) $val['alias'];
98 98
                 foreach (explode(',', $array[0]) as $v) {
99
-                    $tags[$close][$lib . $v] = $name;
99
+                    $tags[$close][$lib.$v] = $name;
100 100
                 }
101 101
             }
102 102
         }
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
                 foreach ($nodes as $pos => $node) {
137 137
                     // 对应的标签名
138 138
                     $name  = $tags[1][$node['name']];
139
-                    $alias = $lib . $name != $node['name'] ? ($lib ? strstr($node['name'], $lib) : $node['name']) : '';
139
+                    $alias = $lib.$name != $node['name'] ? ($lib ? strstr($node['name'], $lib) : $node['name']) : '';
140 140
 
141 141
                     // 解析标签属性
142 142
                     $attrs  = $this->parseAttr($node['begin'][0], $name, $alias);
143
-                    $method = 'tag' . $name;
143
+                    $method = 'tag'.$name;
144 144
 
145 145
                     // 读取标签库中对应的标签内容 replace[0]用来替换标签头,replace[1]用来替换标签尾
146 146
                     $replace = explode($break, $this->$method($attrs, $break));
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
         // 自闭合标签
176 176
         if (!empty($tags[0])) {
177 177
             $regex   = $this->getRegex(array_keys($tags[0]), 0);
178
-            $content = preg_replace_callback($regex, function ($matches) use (&$tags, &$lib) {
178
+            $content = preg_replace_callback($regex, function($matches) use (&$tags, &$lib) {
179 179
                 // 对应的标签名
180 180
                 $name  = $tags[0][strtolower($matches[1])];
181
-                $alias = $lib . $name != $matches[1] ? ($lib ? strstr($matches[1], $lib) : $matches[1]) : '';
181
+                $alias = $lib.$name != $matches[1] ? ($lib ? strstr($matches[1], $lib) : $matches[1]) : '';
182 182
                 // 解析标签属性
183 183
                 $attrs  = $this->parseAttr($matches[0], $name, $alias);
184
-                $method = 'tag' . $name;
184
+                $method = 'tag'.$name;
185 185
                 return $this->$method($attrs, '');
186 186
             }, $content);
187 187
         }
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
         if ($single) {
207 207
             if ($close) {
208 208
                 // 如果是闭合标签
209
-                $regex = $begin . '(?:(' . $tagName . ')\b(?>[^' . $end . ']*)|\/(' . $tagName . '))' . $end;
209
+                $regex = $begin.'(?:('.$tagName.')\b(?>[^'.$end.']*)|\/('.$tagName.'))'.$end;
210 210
             } else {
211
-                $regex = $begin . '(' . $tagName . ')\b(?>[^' . $end . ']*)' . $end;
211
+                $regex = $begin.'('.$tagName.')\b(?>[^'.$end.']*)'.$end;
212 212
             }
213 213
         } else {
214 214
             if ($close) {
215 215
                 // 如果是闭合标签
216
-                $regex = $begin . '(?:(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)|\/(' . $tagName . '))' . $end;
216
+                $regex = $begin.'(?:('.$tagName.')\b(?>(?:(?!'.$end.').)*)|\/('.$tagName.'))'.$end;
217 217
             } else {
218
-                $regex = $begin . '(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)' . $end;
218
+                $regex = $begin.'('.$tagName.')\b(?>(?:(?!'.$end.').)*)'.$end;
219 219
             }
220 220
         }
221 221
 
222
-        return '/' . $regex . '/is';
222
+        return '/'.$regex.'/is';
223 223
     }
224 224
 
225 225
     /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                 $must = explode(',', $tag['must']);
267 267
                 foreach ($must as $name) {
268 268
                     if (!isset($result[$name])) {
269
-                        throw new Exception('tag attr must:' . $name);
269
+                        throw new Exception('tag attr must:'.$name);
270 270
                     }
271 271
                 }
272 272
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             if (!empty($this->tags[$name]['expression'])) {
276 276
                 static $_taglibs;
277 277
                 if (!isset($_taglibs[$name])) {
278
-                    $_taglibs[$name][0] = strlen($this->tpl->config('taglib_begin_origin') . $name);
278
+                    $_taglibs[$name][0] = strlen($this->tpl->config('taglib_begin_origin').$name);
279 279
                     $_taglibs[$name][1] = strlen($this->tpl->config('taglib_end_origin'));
280 280
                 }
281 281
                 $result['expression'] = substr($str, $_taglibs[$name][0], -$_taglibs[$name][1]);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 $result['expression'] = rtrim($result['expression'], '/');
284 284
                 $result['expression'] = trim($result['expression']);
285 285
             } elseif (empty($this->tags[$name]) || !empty($this->tags[$name]['attr'])) {
286
-                throw new Exception('tag error:' . $name);
286
+                throw new Exception('tag error:'.$name);
287 287
             }
288 288
         }
289 289
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     public function parseCondition($condition)
300 300
     {
301 301
         if (!strpos($condition, '::') && strpos($condition, ':')) {
302
-            $condition = ' ' . substr(strstr($condition, ':'), 1);
302
+            $condition = ' '.substr(strstr($condition, ':'), 1);
303 303
         }
304 304
 
305 305
         $condition = str_ireplace(array_keys($this->comparison), array_values($this->comparison), $condition);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             }
331 331
 
332 332
             // 不以$开头并且也不是常量,自动补上$前缀
333
-            $name = '$' . $name;
333
+            $name = '$'.$name;
334 334
         }
335 335
 
336 336
         $this->tpl->parseVar($name);
Please login to merge, or discard this patch.
library/think/Middleware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             if (isset($this->config[$middleware])) {
155 155
                 $middleware = $this->config[$middleware];
156 156
             } else {
157
-                $middleware = $this->config['default_namespace'] . $middleware;
157
+                $middleware = $this->config['default_namespace'].$middleware;
158 158
             }
159 159
         }
160 160
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     protected function resolve($type = 'route')
173 173
     {
174
-        return function (Request $request) use ($type) {
174
+        return function(Request $request) use ($type) {
175 175
 
176 176
             $middleware = array_shift($this->queue[$type]);
177 177
 
Please login to merge, or discard this patch.
library/think/cache/driver/Redis.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             $this->handler = new \Redis;
50 50
 
51 51
             if ($this->options['persistent']) {
52
-                $this->handler->pconnect($this->options['host'], $this->options['port'], $this->options['timeout'], 'persistent_id_' . $this->options['select']);
52
+                $this->handler->pconnect($this->options['host'], $this->options['port'], $this->options['timeout'], 'persistent_id_'.$this->options['select']);
53 53
             } else {
54 54
                 $this->handler->connect($this->options['host'], $this->options['port'], $this->options['timeout']);
55 55
             }
Please login to merge, or discard this patch.
library/think/cache/driver/Sqlite.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     protected function getCacheKey($name)
59 59
     {
60
-        return $this->options['prefix'] . sqlite_escape_string($name);
60
+        return $this->options['prefix'].sqlite_escape_string($name);
61 61
     }
62 62
 
63 63
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $name = $this->getCacheKey($name);
72 72
 
73
-        $sql    = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1';
73
+        $sql    = 'SELECT value FROM '.$this->options['table'].' WHERE var=\''.$name.'\' AND (expire=0 OR expire >'.time().') LIMIT 1';
74 74
         $result = sqlite_query($this->handler, $sql);
75 75
 
76 76
         return sqlite_num_rows($result);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $name = $this->getCacheKey($name);
91 91
 
92
-        $sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1';
92
+        $sql = 'SELECT value FROM '.$this->options['table'].' WHERE var=\''.$name.'\' AND (expire=0 OR expire >'.time().') LIMIT 1';
93 93
 
94 94
         $result = sqlite_query($this->handler, $sql);
95 95
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $tag = '';
145 145
         }
146 146
 
147
-        $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value, expire, tag) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\', \'' . $tag . '\')';
147
+        $sql = 'REPLACE INTO '.$this->options['table'].' (var, value, expire, tag) VALUES (\''.$name.'\', \''.$value.'\', \''.$expire.'\', \''.$tag.'\')';
148 148
 
149 149
         if (sqlite_query($this->handler, $sql)) {
150 150
             return true;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
         $name = $this->getCacheKey($name);
203 203
 
204
-        $sql = 'DELETE FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\'';
204
+        $sql = 'DELETE FROM '.$this->options['table'].' WHERE var=\''.$name.'\'';
205 205
         sqlite_query($this->handler, $sql);
206 206
 
207 207
         return true;
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
     {
218 218
         if ($tag) {
219 219
             $name = sqlite_escape_string($this->getTagKey($tag));
220
-            $sql  = 'DELETE FROM ' . $this->options['table'] . ' WHERE tag=\'' . $name . '\'';
220
+            $sql  = 'DELETE FROM '.$this->options['table'].' WHERE tag=\''.$name.'\'';
221 221
             sqlite_query($this->handler, $sql);
222 222
             return true;
223 223
         }
224 224
 
225 225
         $this->writeTimes++;
226 226
 
227
-        $sql = 'DELETE FROM ' . $this->options['table'];
227
+        $sql = 'DELETE FROM '.$this->options['table'];
228 228
 
229 229
         sqlite_query($this->handler, $sql);
230 230
 
Please login to merge, or discard this patch.
library/think/cache/driver/Memcache.php 1 patch
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@  discard block
 block discarded – undo
55 55
         foreach ((array) $hosts as $i => $host) {
56 56
             $port = isset($ports[$i]) ? $ports[$i] : $ports[0];
57 57
             $this->options['timeout'] > 0 ?
58
-            $this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) :
59
-            $this->handler->addServer($host, $port, $this->options['persistent'], 1);
58
+            $this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) : $this->handler->addServer($host, $port, $this->options['persistent'], 1);
60 59
         }
61 60
     }
62 61
 
@@ -173,8 +172,7 @@  discard block
 block discarded – undo
173 172
         $key = $this->getCacheKey($name);
174 173
 
175 174
         return false === $ttl ?
176
-        $this->handler->delete($key) :
177
-        $this->handler->delete($key, $ttl);
175
+        $this->handler->delete($key) : $this->handler->delete($key, $ttl);
178 176
     }
179 177
 
180 178
     /**
Please login to merge, or discard this patch.
library/think/cache/driver/Lite.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected function getCacheKey($name)
53 53
     {
54
-        return $this->options['path'] . $this->options['prefix'] . md5($name) . '.php';
54
+        return $this->options['path'].$this->options['prefix'].md5($name).'.php';
55 55
     }
56 56
 
57 57
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             $first = true;
124 124
         }
125 125
 
126
-        $ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
126
+        $ret = file_put_contents($filename, ("<?php return ".var_export($value, true).";"));
127 127
 
128 128
         // 通过设置修改时间实现有效期
129 129
         if ($ret) {
@@ -204,6 +204,6 @@  discard block
 block discarded – undo
204 204
 
205 205
         $this->writeTimes++;
206 206
 
207
-        array_map("unlink", glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DIRECTORY_SEPARATOR : '') . '*.php'));
207
+        array_map("unlink", glob($this->options['path'].($this->options['prefix'] ? $this->options['prefix'].DIRECTORY_SEPARATOR : '').'*.php'));
208 208
     }
209 209
 }
Please login to merge, or discard this patch.
library/think/cache/Driver.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     protected function getCacheKey($name)
140 140
     {
141
-        return $this->options['prefix'] . $name;
141
+        return $this->options['prefix'].$name;
142 142
     }
143 143
 
144 144
     /**
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
     {
172 172
         if (!$this->has($name)) {
173 173
             $time = time();
174
-            while ($time + 5 > time() && $this->has($name . '_lock')) {
174
+            while ($time + 5 > time() && $this->has($name.'_lock')) {
175 175
                 // 存在锁定则等待
176 176
                 usleep(200000);
177 177
             }
178 178
 
179 179
             try {
180 180
                 // 锁定
181
-                $this->set($name . '_lock', true);
181
+                $this->set($name.'_lock', true);
182 182
 
183 183
                 if ($value instanceof \Closure) {
184 184
                     // 获取缓存数据
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
                 $this->set($name, $value, $expire);
190 190
 
191 191
                 // 解锁
192
-                $this->rm($name . '_lock');
192
+                $this->rm($name.'_lock');
193 193
             } catch (\Exception $e) {
194
-                $this->rm($name . '_lock');
194
+                $this->rm($name.'_lock');
195 195
                 throw $e;
196 196
             } catch (\throwable $e) {
197
-                $this->rm($name . '_lock');
197
+                $this->rm($name.'_lock');
198 198
                 throw $e;
199 199
             }
200 200
         } else {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
     protected function getTagKey($tag)
290 290
     {
291
-        return 'tag_' . md5($tag);
291
+        return 'tag_'.md5($tag);
292 292
     }
293 293
 
294 294
     /**
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
         $serialize = self::$serialize[0];
307 307
 
308
-        return self::$serialize[2] . $serialize($data);
308
+        return self::$serialize[2].$serialize($data);
309 309
     }
310 310
 
311 311
     /**
Please login to merge, or discard this patch.