Passed
Push — dev ( 78e864...8c8a72 )
by 世昌
02:43
created
suda/src/application/template/compiler/Compiler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @var Tag[]
28 28
      */
29
-    protected $tags=[];
29
+    protected $tags = [];
30 30
 
31 31
     /**
32 32
      * 命令对象
33 33
      *
34 34
      * @var CommandInterface[]
35 35
      */
36
-    protected $commands=[];
36
+    protected $commands = [];
37 37
 
38 38
     public function init()
39 39
     {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function registerTag(Tag $tag)
64 64
     {
65
-        $this->tags[$tag->getName()] =$tag;
65
+        $this->tags[$tag->getName()] = $tag;
66 66
     }
67 67
 
68 68
     /**
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
     public function compileText(string $text, array $tagConfig = []):string
77 77
     {
78 78
         $this->applyTagConfig($tagConfig);
79
-        $result  = '';
79
+        $result = '';
80 80
         foreach (token_get_all($text) as $token) {
81 81
             if (is_array($token)) {
82 82
                 list($tag, $content) = $token;
83 83
                 // 所有将要编译的文本
84 84
                 // 跳过各种的PHP
85 85
                 if ($tag == T_INLINE_HTML) {
86
-                    $content=$this->processTags($content);
87
-                    $content=$this->processCommands($content);
86
+                    $content = $this->processTags($content);
87
+                    $content = $this->processCommands($content);
88 88
                 }
89 89
                 $result .= $content;
90 90
             } else {
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     {
109 109
         foreach ($this->tags as $tag) {
110 110
             $pregExp = sprintf('/(!)?%s\s*(.+?)\s*%s/', preg_quote($tag->getOpen()), preg_quote($tag->getClose()));
111
-            $text = preg_replace_callback($pregExp, function ($match) use ($tag) {
111
+            $text = preg_replace_callback($pregExp, function($match) use ($tag) {
112 112
                 if ($match[1] === '!') {
113 113
                     return substr($match[0], 1);
114 114
                 } else {
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function processCommands(string $text):string
128 128
     {
129
-        $pregExp ='/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux';
130
-        $code = preg_replace_callback($pregExp, [$this,'doMatchCommand'], $text);
129
+        $pregExp = '/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux';
130
+        $code = preg_replace_callback($pregExp, [$this, 'doMatchCommand'], $text);
131 131
         $error = preg_last_error();
132 132
         if ($error !== PREG_NO_ERROR) {
133 133
             throw new Exception($error);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             list($input, $ignore, $name, $space) = $match;
144 144
             $params = '';
145 145
         }
146
-        if ($ignore ==='!') {
146
+        if ($ignore === '!') {
147 147
             return str_replace('@!', '@', $input);
148 148
         } else {
149 149
             foreach ($this->commands as $command) {
Please login to merge, or discard this patch.
suda/src/application/template/ModuleTemplate.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $subfix = $this->config['subfix'] ?? '.tpl.html';
24 24
         $path = $this
25 25
             ->getResource($this->module)
26
-            ->getResourcePath($this->getTemplatePath() . '/' . $this->name . $subfix);
26
+            ->getResourcePath($this->getTemplatePath().'/'.$this->name.$subfix);
27 27
         $this->loadDynamicTemplateConfig($path.'.ini');
28 28
         return $path;
29 29
     }
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getPath()
50 50
     {
51
-        $output = $this->config['output'] ?? $this->application->getDataPath() . '/template/' . $this->uriName;
51
+        $output = $this->config['output'] ?? $this->application->getDataPath().'/template/'.$this->uriName;
52 52
         FileSystem::make($output);
53
-        return $output . '/' . $this->name . '.php';
53
+        return $output.'/'.$this->name.'.php';
54 54
     }
55 55
 
56 56
     /**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getRenderedString()
76 76
     {
77
-        $this->application->debug()->time('render ' . $this->name);
77
+        $this->application->debug()->time('render '.$this->name);
78 78
         $code = parent::getRenderedString();
79
-        $this->application->debug()->timeEnd('render ' . $this->name);
79
+        $this->application->debug()->timeEnd('render '.$this->name);
80 80
         return $code;
81 81
     }
82 82
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
     protected function compile()
88 88
     {
89 89
         if ($this->isCompiled() === false) {
90
-            $this->application->debug()->time('compile ' . $this->name);
90
+            $this->application->debug()->time('compile '.$this->name);
91 91
             $result = parent::compile();
92
-            $this->application->debug()->timeEnd('compile ' . $this->name);
92
+            $this->application->debug()->timeEnd('compile '.$this->name);
93 93
             return $result;
94 94
         }
95 95
         return true;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             }
114 114
             return $this->application->getUrl($this->request, $name, $values ?? [], true, $this->module, $this->group);
115 115
         } elseif (is_string($defaultName)) {
116
-            $parameter = is_array($name)?array_merge($query, $name):$query;
116
+            $parameter = is_array($name) ?array_merge($query, $name) : $query;
117 117
             return $this->application->getUrl(
118 118
                 $this->request,
119 119
                 $defaultName,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 $this->group
124 124
             );
125 125
         }
126
-        return '#' . $defaultName;
126
+        return '#'.$defaultName;
127 127
     }
128 128
 
129 129
 
Please login to merge, or discard this patch.