@@ -21,7 +21,6 @@ class Think
21
21
{
22
22
// 模板引擎实例
23
23
private $ template ;
24
- private $ app ;
25
24
26
25
// 模板引擎参数
27
26
protected $ config = [
@@ -39,10 +38,8 @@ class Think
39
38
'tpl_cache ' => true ,
40
39
];
41
40
42
- public function __construct (App $ app , array $ config = [])
41
+ public function __construct (private App $ app , array $ config = [])
43
42
{
44
- $ this ->app = $ app ;
45
-
46
43
$ this ->config = array_merge ($ this ->config , (array ) $ config );
47
44
48
45
if (empty ($ this ->config ['cache_path ' ])) {
@@ -55,30 +52,15 @@ public function __construct(App $app, array $config = [])
55
52
$ type = strtoupper (trim (array_shift ($ vars )));
56
53
$ param = implode ('. ' , $ vars );
57
54
58
- switch ($ type ) {
59
- case 'CONST ' :
60
- $ parseStr = strtoupper ($ param );
61
- break ;
62
- case 'CONFIG ' :
63
- $ parseStr = 'config( \'' . $ param . '\') ' ;
64
- break ;
65
- case 'LANG ' :
66
- $ parseStr = 'lang( \'' . $ param . '\') ' ;
67
- break ;
68
- case 'NOW ' :
69
- $ parseStr = "date('Y-m-d g:i a',time()) " ;
70
- break ;
71
- case 'LDELIM ' :
72
- $ parseStr = '\'' . ltrim ($ this ->getConfig ('tpl_begin ' ), '\\' ) . '\'' ;
73
- break ;
74
- case 'RDELIM ' :
75
- $ parseStr = '\'' . ltrim ($ this ->getConfig ('tpl_end ' ), '\\' ) . '\'' ;
76
- break ;
77
- default :
78
- $ parseStr = defined ($ type ) ? $ type : '\'\'' ;
79
- }
80
-
81
- return $ parseStr ;
55
+ return match ($ type ) {
56
+ 'CONST ' => strtoupper ($ param ),
57
+ 'CONFIG ' => 'config( \'' . $ param . '\') ' ,
58
+ 'LANG ' => 'lang( \'' . $ param . '\') ' ,
59
+ 'NOW ' => "date('Y-m-d g:i a',time()) " ,
60
+ 'LDELIM ' => '\'' . ltrim ($ this ->getConfig ('tpl_begin ' ), '\\' ) . '\'' ,
61
+ 'RDELIM ' => '\'' . ltrim ($ this ->getConfig ('tpl_end ' ), '\\' ) . '\'' ,
62
+ default => defined ($ type ) ? $ type : '\'\'' ,
63
+ };
82
64
});
83
65
84
66
$ this ->template ->extend ('$Request ' , function (array $ vars ) {
0 commit comments