@@ -26,14 +26,14 @@ discard block |
||
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 __construct() |
39 | 39 | { |
@@ -62,7 +62,7 @@ discard block |
||
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 | /** |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | public function compileText(string $text, array $tagConfig = []):string |
76 | 76 | { |
77 | 77 | $this->applyTagConfig($tagConfig); |
78 | - $result = ''; |
|
78 | + $result = ''; |
|
79 | 79 | foreach (token_get_all($text) as $token) { |
80 | 80 | if (is_array($token)) { |
81 | 81 | list($tag, $content) = $token; |
82 | 82 | // 所有将要编译的文本 |
83 | 83 | // 跳过各种的PHP |
84 | 84 | if ($tag == T_INLINE_HTML) { |
85 | - $content=$this->proccesTags($content); |
|
86 | - $content=$this->proccesCommands($content); |
|
85 | + $content = $this->proccesTags($content); |
|
86 | + $content = $this->proccesCommands($content); |
|
87 | 87 | } |
88 | 88 | $result .= $content; |
89 | 89 | } else { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | foreach ($this->tags as $tag) { |
109 | 109 | $pregExp = sprintf('/(!)?%s\s*(.+?)\s*%s/', preg_quote($tag->getOpen()), preg_quote($tag->getClose())); |
110 | - $text = \preg_replace_callback($pregExp, function ($match) use ($tag) { |
|
110 | + $text = \preg_replace_callback($pregExp, function($match) use ($tag) { |
|
111 | 111 | if ($match[1] === '!') { |
112 | 112 | return substr($match[0], 1); |
113 | 113 | } else { |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | |
121 | 121 | protected function proccesCommands(string $text):string |
122 | 122 | { |
123 | - $pregExp ='/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
124 | - $code = preg_replace_callback($pregExp, [$this,'doMatchCommand'], $text); |
|
123 | + $pregExp = '/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
124 | + $code = preg_replace_callback($pregExp, [$this, 'doMatchCommand'], $text); |
|
125 | 125 | $error = preg_last_error(); |
126 | 126 | if ($error !== PREG_NO_ERROR) { |
127 | 127 | throw new \Exception($error); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | list($input, $ignore, $name, $space) = $match; |
138 | 138 | $params = ''; |
139 | 139 | } |
140 | - if ($ignore ==='!') { |
|
140 | + if ($ignore === '!') { |
|
141 | 141 | return \str_replace('@!', '@', $input); |
142 | 142 | } else { |
143 | 143 | foreach ($this->commands as $command) { |