Completed
Pull Request — master (#1)
by Fenz
07:21
created
libs/Htsl.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -13,189 +13,189 @@
 block discarded – undo
13 13
 
14 14
 class Htsl implements IConfigProvider
15 15
 {
16
-    use Helper\TGetter;
17
-
18
-    /**
19
-     * Getter of file content.
20
-     *
21
-     * @var callable
22
-     */
23
-    protected $fileGetter;
24
-
25
-    /**
26
-     * The base path.
27
-     *
28
-     * @var string
29
-     */
30
-    protected $basePath;
31
-
32
-    /**
33
-     * Constructor of HTSL.
34
-     *
35
-     * @param array $config
36
-     */
37
-    public function __construct(array $config = [])
38
-    {
39
-        $this->config = array_replace_recursive($this->getDefaultConfigs(), $config);
40
-    }
41
-
42
-    /**
43
-     * Parsing a HTSL code string into HTML or PHP code string.
44
-     *
45
-     * @param string $content
46
-     *
47
-     * @return string
48
-     */
49
-    public function parse(string $content):string
50
-    {
51
-        return $this->execute(new StringBuffer($this, $content));
52
-    }
53
-
54
-    /**
55
-     * Compiling a HTSL file into a HTML or PHP file.
56
-     *
57
-     * @param string $fromFile
58
-     * @param string $toFile
59
-     *
60
-     * @return int|string
61
-     */
62
-    public function compile(string $fromFile, string $toFile = null)
63
-    {
64
-        $fromFile = $this->getFilePath($fromFile);
65
-
66
-        $result = $this->execute(new FileBuffer($this, $fromFile));
67
-
68
-        if ($toFile) {
69
-            return file_put_contents($toFile, $result);
70
-        } else {
71
-            return $result;
72
-        }
73
-    }
74
-
75
-    /**
76
-     * Setting the file getter.
77
-     *
78
-     * @param callable $fileGetter
79
-     */
80
-    public function setFileGetter(callable $fileGetter):self
81
-    {
82
-        $this->fileGetter = $fileGetter;
83
-
84
-        return $this;
85
-    }
86
-
87
-    /**
88
-     * Setting the base path of the HTSL project to parse.
89
-     *
90
-     * @param string $basePath
91
-     *
92
-     * @return self
93
-     */
94
-    public function setBasePath(string $basePath):self
95
-    {
96
-        $this->basePath = '/' === substr($basePath, -1) ? substr($basePath, 0, -1) : $basePath;
97
-
98
-        return $this;
99
-    }
100
-
101
-    /**
102
-     * Returning whether the debug model is on or off.
103
-     *
104
-     * @return bool
105
-     */
106
-    public function isDebug():bool
107
-    {
108
-        return (bool) $this->getConfig('debug');
109
-    }
110
-
111
-    /**
112
-     * Executing the parsing.
113
-     *
114
-     * @param \Htsl\ReadingBuffer\Contracts\ABuffer $buffer
115
-     *
116
-     * @return string
117
-     */
118
-    protected function execute(ABuffer $buffer):string
119
-    {
120
-        return (new Document($this, $buffer))->content;
121
-    }
122
-
123
-    /**
124
-     * Getting the config of Htsl.
125
-     *
126
-     * @param string $key
127
-     *
128
-     * @return mixed
129
-     */
130
-    public function getConfig(string ...$keys)
131
-    {
132
-        $result = $this->config;
133
-
134
-        foreach ($keys as $key) {
135
-            if (!isset($result[$key])) {
136
-                return;
137
-            }
138
-
139
-            $result = $result[$key];
140
-        }
141
-
142
-        return $result;
143
-    }
144
-
145
-    /**
146
-     * Getting the real file path of the HTSL file by relative path.
147
-     *
148
-     * @param string      $filePath
149
-     * @param string|null $path
150
-     *
151
-     * @return string
152
-     */
153
-    public function getFilePath(string $filePath, string $path = null):string
154
-    {
155
-        if (!isset($this->basePath)) {
156
-            throw new \Exception('BasePath musbe set.');
157
-        }
158
-
159
-        if (!strlen($filePath)) {
160
-            throw new \Exception('FilePath cannot be empty.');
161
-        }
162
-
163
-        if ('/' === $filePath[0]) {
164
-            if (is_null($path)) {
165
-                return $filePath;
166
-            } else {
167
-                return $this->basePath.$filePath;
168
-            }
169
-        } else {
170
-            if (!strlen($path)) {
171
-                return $this->basePath.'/'.$filePath;
172
-            } elseif ('/' === substr($path, -1)) {
173
-                return $path.$filePath;
174
-            } else {
175
-                return $path.'/'.$filePath;
176
-            }
177
-        }
178
-    }
179
-
180
-    /**
181
-     * Getting the content of file.
182
-     *
183
-     * @param string $filePath
184
-     *
185
-     * @return string
186
-     */
187
-    public function getFileContent(string $filePath):string
188
-    {
189
-        return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
190
-    }
191
-
192
-    /**
193
-     * Getting default config.
194
-     *
195
-     * @return array
196
-     */
197
-    private function getDefaultConfigs():array
198
-    {
199
-        return DefaultConfigs::get();
200
-    }
16
+	use Helper\TGetter;
17
+
18
+	/**
19
+	 * Getter of file content.
20
+	 *
21
+	 * @var callable
22
+	 */
23
+	protected $fileGetter;
24
+
25
+	/**
26
+	 * The base path.
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected $basePath;
31
+
32
+	/**
33
+	 * Constructor of HTSL.
34
+	 *
35
+	 * @param array $config
36
+	 */
37
+	public function __construct(array $config = [])
38
+	{
39
+		$this->config = array_replace_recursive($this->getDefaultConfigs(), $config);
40
+	}
41
+
42
+	/**
43
+	 * Parsing a HTSL code string into HTML or PHP code string.
44
+	 *
45
+	 * @param string $content
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function parse(string $content):string
50
+	{
51
+		return $this->execute(new StringBuffer($this, $content));
52
+	}
53
+
54
+	/**
55
+	 * Compiling a HTSL file into a HTML or PHP file.
56
+	 *
57
+	 * @param string $fromFile
58
+	 * @param string $toFile
59
+	 *
60
+	 * @return int|string
61
+	 */
62
+	public function compile(string $fromFile, string $toFile = null)
63
+	{
64
+		$fromFile = $this->getFilePath($fromFile);
65
+
66
+		$result = $this->execute(new FileBuffer($this, $fromFile));
67
+
68
+		if ($toFile) {
69
+			return file_put_contents($toFile, $result);
70
+		} else {
71
+			return $result;
72
+		}
73
+	}
74
+
75
+	/**
76
+	 * Setting the file getter.
77
+	 *
78
+	 * @param callable $fileGetter
79
+	 */
80
+	public function setFileGetter(callable $fileGetter):self
81
+	{
82
+		$this->fileGetter = $fileGetter;
83
+
84
+		return $this;
85
+	}
86
+
87
+	/**
88
+	 * Setting the base path of the HTSL project to parse.
89
+	 *
90
+	 * @param string $basePath
91
+	 *
92
+	 * @return self
93
+	 */
94
+	public function setBasePath(string $basePath):self
95
+	{
96
+		$this->basePath = '/' === substr($basePath, -1) ? substr($basePath, 0, -1) : $basePath;
97
+
98
+		return $this;
99
+	}
100
+
101
+	/**
102
+	 * Returning whether the debug model is on or off.
103
+	 *
104
+	 * @return bool
105
+	 */
106
+	public function isDebug():bool
107
+	{
108
+		return (bool) $this->getConfig('debug');
109
+	}
110
+
111
+	/**
112
+	 * Executing the parsing.
113
+	 *
114
+	 * @param \Htsl\ReadingBuffer\Contracts\ABuffer $buffer
115
+	 *
116
+	 * @return string
117
+	 */
118
+	protected function execute(ABuffer $buffer):string
119
+	{
120
+		return (new Document($this, $buffer))->content;
121
+	}
122
+
123
+	/**
124
+	 * Getting the config of Htsl.
125
+	 *
126
+	 * @param string $key
127
+	 *
128
+	 * @return mixed
129
+	 */
130
+	public function getConfig(string ...$keys)
131
+	{
132
+		$result = $this->config;
133
+
134
+		foreach ($keys as $key) {
135
+			if (!isset($result[$key])) {
136
+				return;
137
+			}
138
+
139
+			$result = $result[$key];
140
+		}
141
+
142
+		return $result;
143
+	}
144
+
145
+	/**
146
+	 * Getting the real file path of the HTSL file by relative path.
147
+	 *
148
+	 * @param string      $filePath
149
+	 * @param string|null $path
150
+	 *
151
+	 * @return string
152
+	 */
153
+	public function getFilePath(string $filePath, string $path = null):string
154
+	{
155
+		if (!isset($this->basePath)) {
156
+			throw new \Exception('BasePath musbe set.');
157
+		}
158
+
159
+		if (!strlen($filePath)) {
160
+			throw new \Exception('FilePath cannot be empty.');
161
+		}
162
+
163
+		if ('/' === $filePath[0]) {
164
+			if (is_null($path)) {
165
+				return $filePath;
166
+			} else {
167
+				return $this->basePath.$filePath;
168
+			}
169
+		} else {
170
+			if (!strlen($path)) {
171
+				return $this->basePath.'/'.$filePath;
172
+			} elseif ('/' === substr($path, -1)) {
173
+				return $path.$filePath;
174
+			} else {
175
+				return $path.'/'.$filePath;
176
+			}
177
+		}
178
+	}
179
+
180
+	/**
181
+	 * Getting the content of file.
182
+	 *
183
+	 * @param string $filePath
184
+	 *
185
+	 * @return string
186
+	 */
187
+	public function getFileContent(string $filePath):string
188
+	{
189
+		return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
190
+	}
191
+
192
+	/**
193
+	 * Getting default config.
194
+	 *
195
+	 * @return array
196
+	 */
197
+	private function getDefaultConfigs():array
198
+	{
199
+		return DefaultConfigs::get();
200
+	}
201 201
 }
Please login to merge, or discard this patch.
libs/Helper/TGetter.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 
7 7
 trait TGetter
8 8
 {
9
-    /**
10
-     * Allow setting fooBar getter with getFooBar().
11
-     *
12
-     * @param string $attribute
13
-     *
14
-     * @return mixed
15
-     */
16
-    public function __get($attribute)
17
-    {
18
-        if (is_callable([static::class, $getter = 'get'.implode('', array_map('ucfirst', explode('_', $attribute)))])) {
19
-            return static::$getter();
20
-        } else {
21
-            throw new \Exception(static::class.' has no attribute named '.$attribute);
22
-        }
23
-    }
9
+	/**
10
+	 * Allow setting fooBar getter with getFooBar().
11
+	 *
12
+	 * @param string $attribute
13
+	 *
14
+	 * @return mixed
15
+	 */
16
+	public function __get($attribute)
17
+	{
18
+		if (is_callable([static::class, $getter = 'get'.implode('', array_map('ucfirst', explode('_', $attribute)))])) {
19
+			return static::$getter();
20
+		} else {
21
+			throw new \Exception(static::class.' has no attribute named '.$attribute);
22
+		}
23
+	}
24 24
 }
Please login to merge, or discard this patch.
libs/Helper/DefaultConfigs.php 1 patch
Indentation   +397 added lines, -397 removed lines patch added patch discarded remove patch
@@ -6,406 +6,406 @@
 block discarded – undo
6 6
 
7 7
 class DefaultConfigs
8 8
 {
9
-    /**
10
-     * Getting default configurations of HTSL and Htsl.php.
11
-     *
12
-     * @return array
13
-     */
14
-    public static function get():array
15
-    {
16
-        return [
17
-            'debug'     => false,
18
-            'doc_types' => [
19
-                'HTML5'  => '<!DOCTYPE html>',
20
-                'XML1'   => '<?xml version="1.0" encoding="%s"?>',
21
-                'SVG1.1' => "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">",
22
-            ],
23
-            'ENT_flags' => [
24
-                'HTML5'  => ENT_HTML5,
25
-                'XML1'   => ENT_XML1,
26
-                'SVG1.1' => ENT_XML1,
27
-                'XHTML'  => ENT_XHTML,
28
-                'HTML4'  => ENT_HTML401,
29
-            ],
30
-            'control_nodes' => [
31
-                '' => [
32
-                    'opener' => '<?php %s?>',
33
-                ],
34
-                'for' => [
35
-                    'opener'   => '<?php $$_FLAG_$=false; for( %s/[^;]*$|;$|;[^ ]/\_/ ): $$_FLAG_$=true;?>',
36
-                    'close_by' => [
37
-                        '/else|then/' => '<?php endfor; if( $$_FLAG_$ ):?>',
38
-                    ],
39
-                    'closer' => '<?php endfor;?>',
40
-                ],
41
-                'while' => [
42
-                    'opener'   => '<?php $$_FLAG_$=false; while( %s ): $$_FLAG_$=true;?>',
43
-                    'close_by' => [
44
-                        '/else|then/' => '<?php endwhile; if( $$_FLAG_$ ):?>',
45
-                    ],
46
-                    'closer' => '<?php endwhile;?>',
47
-                ],
48
-                'do-while' => [
49
-                    'opener'   => '<?php $$_FLAG_$=0; do{ ++$$_FLAG_$;?>',
50
-                    'closer'   => '<?php }while( %s );?>',
51
-                    'close_by' => [
52
-                        '/else|then/' => '<?php }while( %s ); if( $$_FLAG_$>1 ):?>',
53
-                    ],
54
-                    'closer' => '<?php }while( %s );?>',
55
-                ],
56
-                'for-each' => [
57
-                    'opener'   => '<?php $$_FLAG_$=false; foreach( %s ): $$_FLAG_$=true;?>',
58
-                    'close_by' => [
59
-                        '/else|then/' => '<?php endforeach; if( $$_FLAG_$ ):?>',
60
-                    ],
61
-                    'closer' => '<?php endforeach;?>',
62
-                ],
63
-                'continue' => [
64
-                    'multiple' => [
65
-                        [
66
-                            'pattern' => '/\)$/',
67
-                            'opener'  => '<?php if( %s ) continue;?>',
68
-                            'closer'  => '',
69
-                        ],
70
-                        [
71
-                            'pattern' => '/\\w$/',
72
-                            'opener'  => '<?php continue;?>',
73
-                            'closer'  => '',
74
-                        ],
75
-                    ],
76
-                ],
77
-                'break' => [
78
-                    'multiple' => [
79
-                        [
80
-                            'pattern' => '/\)$/',
81
-                            'opener'  => '<?php if( %s ) break;?>',
82
-                            'closer'  => '',
83
-                        ],
84
-                        [
85
-                            'pattern' => '/\\w$/',
86
-                            'opener'  => '<?php break;?>',
87
-                            'closer'  => '',
88
-                        ],
89
-                    ],
90
-                ],
91
-                'if' => [
92
-                    'opener'   => '<?php if( %s ):?>',
93
-                    'close_by' => [
94
-                        '/else|then/' => '',
95
-                    ],
96
-                    'closer' => '<?php endif;?>',
97
-                ],
98
-                'if-not' => [
99
-                    'opener'   => '<?php if( !(%s) ):?>',
100
-                    'close_by' => [
101
-                        '/else|then/' => '',
102
-                    ],
103
-                    'closer' => '<?php endif;?>',
104
-                ],
105
-                'if-all' => [
106
-                    'opener'   => '<?php if( %s/[^;]*$/\_//^/( //; / )and( //;$/ )/ ):?>',
107
-                    'close_by' => [
108
-                        '/else|then/' => '<?php endif; if( %s/[^;]*$/\_//^/( //; / )or( //;$/ )/ ):?>',
109
-                    ],
110
-                    'closer' => '<?php endif;?>',
111
-                ],
112
-                'else-if' => [
113
-                    'opener'   => '<?php elseif( %s ):?>',
114
-                    'close_by' => [
115
-                        '/else|then/' => '',
116
-                    ],
117
-                    'closer' => '<?php endif;?>',
118
-                ],
119
-                'else' => [
120
-                    'opener' => '<?php else:?>',
121
-                    'closer' => '<?php endif;?>',
122
-                ],
123
-                'then' => [
124
-                    'opener'   => '',
125
-                    'close_by' => [
126
-                        '/else|then/' => '',
127
-                    ],
128
-                    'closer' => '<?php endif;?>',
129
-                ],
130
-                'switch' => [
131
-                    'opener' => '<?php switch( %s ):?>',
132
-                    'closer' => '<?php endswitch;?>',
133
-                    'scope'  => 'switch',
134
-                ],
135
-                'default' => [
136
-                    'in' => [
137
-                        'switch' => [
138
-                            'opener' => '<?php default:?>',
139
-                            'closer' => '<?php break;?>',
140
-                            'scope'  => 'root-default',
141
-                        ],
142
-                        'root-case' => [
143
-                            'opener' => '<?php default:?>',
144
-                            'closer' => '',
145
-                            'scope'  => 'default-in-case',
146
-                        ],
147
-                    ],
148
-                ],
149
-                'case' => [
150
-                    'in' => [
151
-                        'switch' => [
152
-                            'opener' => '<?php case %s:?>',
153
-                            'closer' => '<?php break;?>',
154
-                            'scope'  => 'root-case',
155
-                        ],
156
-                        'root-case' => [
157
-                            'opener' => '<?php case %s:?>',
158
-                            'closer' => '',
159
-                            'scope'  => 'case-in-case',
160
-                        ],
161
-                        'root-default' => [
162
-                            'opener' => '<?php case %s:?>',
163
-                            'closer' => '',
164
-                            'scope'  => 'case-in-case',
165
-                        ],
166
-                    ],
167
-                ],
168
-            ],
169
-            'tag_nodes' => [
170
-                'SVG1.1' => $svgTags = [
171
-                    'svg' => [
172
-                        'out' => [
173
-                            'default_attributes' => ['xmlns' => 'http://www.w3.org/2000/svg', 'version' => '1.1'],
174
-                            'params'             => ['viewBox'],
175
-                            'scope'              => 'svg',
176
-                        ],
177
-                        'in' => [
178
-                            'svg' => [
179
-                                'params' => ['x', 'y', 'width', 'height'],
180
-                            ],
181
-                        ],
182
-                    ],
183
-                    '*'       => [],
184
-                    'polygon' => [
185
-                        'params'  => ['points'],
186
-                        'only_in' => ['svg'],
187
-                    ],
188
-                    'polyline' => [
189
-                        'params'  => ['points'],
190
-                        'only_in' => ['svg'],
191
-                    ],
192
-                    'path' => [
193
-                        'params'  => ['d'],
194
-                        'only_in' => ['svg'],
195
-                    ],
196
-                    'line' => [
197
-                        'params'  => ['x1', 'y1', 'x2', 'y2'],
198
-                        'only_in' => ['svg'],
199
-                    ],
200
-                    'rect' => [
201
-                        'params'  => ['x', 'y', 'width', 'height'],
202
-                        'only_in' => ['svg'],
203
-                    ],
204
-                    'circle' => [
205
-                        'params'  => ['cx', 'cy', 'r'],
206
-                        'only_in' => ['svg'],
207
-                    ],
208
-                    'ellipse' => [
209
-                        'params'  => ['cx', 'cy', 'rx', 'ry'],
210
-                        'only_in' => ['svg'],
211
-                    ],
212
-                    'text' => [
213
-                        'params'  => ['x', 'y'],
214
-                        'only_in' => ['svg'],
215
-                    ],
216
-                ],
217
-                'HTML5' => [
218
-                    '*'       => [],
219
-                    'charset' => [
220
-                        'name'   => 'meta',
221
-                        'params' => ['charset'],
222
-                    ],
223
-                    'equiv' => [
224
-                        'name'       => 'meta',
225
-                        'name_value' => ['http-equiv', 'content', 'scheme'],
226
-                    ],
227
-                    'meta' => [
228
-                        'name'       => 'meta',
229
-                        'name_value' => ['name', 'content', 'scheme'],
230
-                    ],
231
-                    'php' => [
232
-                        'opener'    => '<?php ',
233
-                        'closer'    => '?>',
234
-                        'embedding' => 'php',
235
-                    ],
236
-                    'code' => [
237
-                        'name'     => 'code',
238
-                        'multiple' => [
239
-                            [
240
-                                'pattern'            => '/\{>$/',
241
-                                'params'             => ['type'],
242
-                                'default_attributes' => ['codeset' => 'codeset'],
243
-                                'embedding'          => 'code',
244
-                            ],
245
-                            [
246
-                                'pattern' => '/.?/',
247
-                                'name'    => 'code',
248
-                                'params'  => ['type'],
249
-                            ],
250
-                        ],
251
-                    ],
252
-                    'js' => [
253
-                        'multiple' => [
254
-                            [
255
-                                'pattern'            => '/^-js @/',
256
-                                'name'               => 'script',
257
-                                'default_attributes' => ['type' => 'text/javascript'],
258
-                                'link'               => 'src',
259
-                            ],
260
-                            [
261
-                                'pattern'            => '/^-js\{>/',
262
-                                'name'               => 'script',
263
-                                'default_attributes' => ['type' => 'text/javascript'],
264
-                                'embedding'          => 'js',
265
-                            ],
266
-                        ],
267
-                    ],
268
-                    'css' => [
269
-                        'multiple' => [
270
-                            [
271
-                                'pattern'            => '/^-css @/',
272
-                                'name'               => 'link',
273
-                                'default_attributes' => ['rel' => 'stylesheet', 'type' => 'text/css'],
274
-                                'link'               => 'href',
275
-                            ],
276
-                            [
277
-                                'pattern'            => '/^-css\{>/',
278
-                                'name'               => 'style',
279
-                                'default_attributes' => ['type' => 'text/css'],
280
-                                'embedding'          => 'css',
281
-                            ],
282
-                        ],
283
-                    ],
284
-                    'icon' => [
285
-                        'name'               => 'link',
286
-                        'default_attributes' => ['rel' => 'icon'],
287
-                        'params'             => ['sizes'],
288
-                        'link'               => 'href',
289
-                    ],
290
-                    'shortcut' => [
291
-                        'name'               => 'link',
292
-                        'default_attributes' => ['rel' => 'shortcut icon', 'type' => 'image/x-icon'],
293
-                        'link'               => 'href',
294
-                    ],
295
-                    'link' => [
296
-                        'name'   => 'link',
297
-                        'params' => ['rel'],
298
-                        'link'   => 'href',
299
-                    ],
300
-                    'a' => [
301
-                        'link'       => 'href',
302
-                        'name_value' => ['name'],
303
-                        'target'     => 'target',
304
-                    ],
305
-                    'iframe' => [
306
-                        'link'               => 'src',
307
-                        'default_attributes' => ['frameborder' => '0'],
308
-                        'name_value'         => ['name'],
309
-                    ],
310
-                    'img' => [
311
-                        'link' => 'src',
312
-                        'alt'  => 'alt',
313
-                    ],
314
-                    'form'   => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post']],
315
-                    'post'   => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post']],
316
-                    'upload' => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post', 'enctype' => 'multipart/form-data']],
317
-                    'get'    => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'get']],
9
+	/**
10
+	 * Getting default configurations of HTSL and Htsl.php.
11
+	 *
12
+	 * @return array
13
+	 */
14
+	public static function get():array
15
+	{
16
+		return [
17
+			'debug'     => false,
18
+			'doc_types' => [
19
+				'HTML5'  => '<!DOCTYPE html>',
20
+				'XML1'   => '<?xml version="1.0" encoding="%s"?>',
21
+				'SVG1.1' => "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">",
22
+			],
23
+			'ENT_flags' => [
24
+				'HTML5'  => ENT_HTML5,
25
+				'XML1'   => ENT_XML1,
26
+				'SVG1.1' => ENT_XML1,
27
+				'XHTML'  => ENT_XHTML,
28
+				'HTML4'  => ENT_HTML401,
29
+			],
30
+			'control_nodes' => [
31
+				'' => [
32
+					'opener' => '<?php %s?>',
33
+				],
34
+				'for' => [
35
+					'opener'   => '<?php $$_FLAG_$=false; for( %s/[^;]*$|;$|;[^ ]/\_/ ): $$_FLAG_$=true;?>',
36
+					'close_by' => [
37
+						'/else|then/' => '<?php endfor; if( $$_FLAG_$ ):?>',
38
+					],
39
+					'closer' => '<?php endfor;?>',
40
+				],
41
+				'while' => [
42
+					'opener'   => '<?php $$_FLAG_$=false; while( %s ): $$_FLAG_$=true;?>',
43
+					'close_by' => [
44
+						'/else|then/' => '<?php endwhile; if( $$_FLAG_$ ):?>',
45
+					],
46
+					'closer' => '<?php endwhile;?>',
47
+				],
48
+				'do-while' => [
49
+					'opener'   => '<?php $$_FLAG_$=0; do{ ++$$_FLAG_$;?>',
50
+					'closer'   => '<?php }while( %s );?>',
51
+					'close_by' => [
52
+						'/else|then/' => '<?php }while( %s ); if( $$_FLAG_$>1 ):?>',
53
+					],
54
+					'closer' => '<?php }while( %s );?>',
55
+				],
56
+				'for-each' => [
57
+					'opener'   => '<?php $$_FLAG_$=false; foreach( %s ): $$_FLAG_$=true;?>',
58
+					'close_by' => [
59
+						'/else|then/' => '<?php endforeach; if( $$_FLAG_$ ):?>',
60
+					],
61
+					'closer' => '<?php endforeach;?>',
62
+				],
63
+				'continue' => [
64
+					'multiple' => [
65
+						[
66
+							'pattern' => '/\)$/',
67
+							'opener'  => '<?php if( %s ) continue;?>',
68
+							'closer'  => '',
69
+						],
70
+						[
71
+							'pattern' => '/\\w$/',
72
+							'opener'  => '<?php continue;?>',
73
+							'closer'  => '',
74
+						],
75
+					],
76
+				],
77
+				'break' => [
78
+					'multiple' => [
79
+						[
80
+							'pattern' => '/\)$/',
81
+							'opener'  => '<?php if( %s ) break;?>',
82
+							'closer'  => '',
83
+						],
84
+						[
85
+							'pattern' => '/\\w$/',
86
+							'opener'  => '<?php break;?>',
87
+							'closer'  => '',
88
+						],
89
+					],
90
+				],
91
+				'if' => [
92
+					'opener'   => '<?php if( %s ):?>',
93
+					'close_by' => [
94
+						'/else|then/' => '',
95
+					],
96
+					'closer' => '<?php endif;?>',
97
+				],
98
+				'if-not' => [
99
+					'opener'   => '<?php if( !(%s) ):?>',
100
+					'close_by' => [
101
+						'/else|then/' => '',
102
+					],
103
+					'closer' => '<?php endif;?>',
104
+				],
105
+				'if-all' => [
106
+					'opener'   => '<?php if( %s/[^;]*$/\_//^/( //; / )and( //;$/ )/ ):?>',
107
+					'close_by' => [
108
+						'/else|then/' => '<?php endif; if( %s/[^;]*$/\_//^/( //; / )or( //;$/ )/ ):?>',
109
+					],
110
+					'closer' => '<?php endif;?>',
111
+				],
112
+				'else-if' => [
113
+					'opener'   => '<?php elseif( %s ):?>',
114
+					'close_by' => [
115
+						'/else|then/' => '',
116
+					],
117
+					'closer' => '<?php endif;?>',
118
+				],
119
+				'else' => [
120
+					'opener' => '<?php else:?>',
121
+					'closer' => '<?php endif;?>',
122
+				],
123
+				'then' => [
124
+					'opener'   => '',
125
+					'close_by' => [
126
+						'/else|then/' => '',
127
+					],
128
+					'closer' => '<?php endif;?>',
129
+				],
130
+				'switch' => [
131
+					'opener' => '<?php switch( %s ):?>',
132
+					'closer' => '<?php endswitch;?>',
133
+					'scope'  => 'switch',
134
+				],
135
+				'default' => [
136
+					'in' => [
137
+						'switch' => [
138
+							'opener' => '<?php default:?>',
139
+							'closer' => '<?php break;?>',
140
+							'scope'  => 'root-default',
141
+						],
142
+						'root-case' => [
143
+							'opener' => '<?php default:?>',
144
+							'closer' => '',
145
+							'scope'  => 'default-in-case',
146
+						],
147
+					],
148
+				],
149
+				'case' => [
150
+					'in' => [
151
+						'switch' => [
152
+							'opener' => '<?php case %s:?>',
153
+							'closer' => '<?php break;?>',
154
+							'scope'  => 'root-case',
155
+						],
156
+						'root-case' => [
157
+							'opener' => '<?php case %s:?>',
158
+							'closer' => '',
159
+							'scope'  => 'case-in-case',
160
+						],
161
+						'root-default' => [
162
+							'opener' => '<?php case %s:?>',
163
+							'closer' => '',
164
+							'scope'  => 'case-in-case',
165
+						],
166
+					],
167
+				],
168
+			],
169
+			'tag_nodes' => [
170
+				'SVG1.1' => $svgTags = [
171
+					'svg' => [
172
+						'out' => [
173
+							'default_attributes' => ['xmlns' => 'http://www.w3.org/2000/svg', 'version' => '1.1'],
174
+							'params'             => ['viewBox'],
175
+							'scope'              => 'svg',
176
+						],
177
+						'in' => [
178
+							'svg' => [
179
+								'params' => ['x', 'y', 'width', 'height'],
180
+							],
181
+						],
182
+					],
183
+					'*'       => [],
184
+					'polygon' => [
185
+						'params'  => ['points'],
186
+						'only_in' => ['svg'],
187
+					],
188
+					'polyline' => [
189
+						'params'  => ['points'],
190
+						'only_in' => ['svg'],
191
+					],
192
+					'path' => [
193
+						'params'  => ['d'],
194
+						'only_in' => ['svg'],
195
+					],
196
+					'line' => [
197
+						'params'  => ['x1', 'y1', 'x2', 'y2'],
198
+						'only_in' => ['svg'],
199
+					],
200
+					'rect' => [
201
+						'params'  => ['x', 'y', 'width', 'height'],
202
+						'only_in' => ['svg'],
203
+					],
204
+					'circle' => [
205
+						'params'  => ['cx', 'cy', 'r'],
206
+						'only_in' => ['svg'],
207
+					],
208
+					'ellipse' => [
209
+						'params'  => ['cx', 'cy', 'rx', 'ry'],
210
+						'only_in' => ['svg'],
211
+					],
212
+					'text' => [
213
+						'params'  => ['x', 'y'],
214
+						'only_in' => ['svg'],
215
+					],
216
+				],
217
+				'HTML5' => [
218
+					'*'       => [],
219
+					'charset' => [
220
+						'name'   => 'meta',
221
+						'params' => ['charset'],
222
+					],
223
+					'equiv' => [
224
+						'name'       => 'meta',
225
+						'name_value' => ['http-equiv', 'content', 'scheme'],
226
+					],
227
+					'meta' => [
228
+						'name'       => 'meta',
229
+						'name_value' => ['name', 'content', 'scheme'],
230
+					],
231
+					'php' => [
232
+						'opener'    => '<?php ',
233
+						'closer'    => '?>',
234
+						'embedding' => 'php',
235
+					],
236
+					'code' => [
237
+						'name'     => 'code',
238
+						'multiple' => [
239
+							[
240
+								'pattern'            => '/\{>$/',
241
+								'params'             => ['type'],
242
+								'default_attributes' => ['codeset' => 'codeset'],
243
+								'embedding'          => 'code',
244
+							],
245
+							[
246
+								'pattern' => '/.?/',
247
+								'name'    => 'code',
248
+								'params'  => ['type'],
249
+							],
250
+						],
251
+					],
252
+					'js' => [
253
+						'multiple' => [
254
+							[
255
+								'pattern'            => '/^-js @/',
256
+								'name'               => 'script',
257
+								'default_attributes' => ['type' => 'text/javascript'],
258
+								'link'               => 'src',
259
+							],
260
+							[
261
+								'pattern'            => '/^-js\{>/',
262
+								'name'               => 'script',
263
+								'default_attributes' => ['type' => 'text/javascript'],
264
+								'embedding'          => 'js',
265
+							],
266
+						],
267
+					],
268
+					'css' => [
269
+						'multiple' => [
270
+							[
271
+								'pattern'            => '/^-css @/',
272
+								'name'               => 'link',
273
+								'default_attributes' => ['rel' => 'stylesheet', 'type' => 'text/css'],
274
+								'link'               => 'href',
275
+							],
276
+							[
277
+								'pattern'            => '/^-css\{>/',
278
+								'name'               => 'style',
279
+								'default_attributes' => ['type' => 'text/css'],
280
+								'embedding'          => 'css',
281
+							],
282
+						],
283
+					],
284
+					'icon' => [
285
+						'name'               => 'link',
286
+						'default_attributes' => ['rel' => 'icon'],
287
+						'params'             => ['sizes'],
288
+						'link'               => 'href',
289
+					],
290
+					'shortcut' => [
291
+						'name'               => 'link',
292
+						'default_attributes' => ['rel' => 'shortcut icon', 'type' => 'image/x-icon'],
293
+						'link'               => 'href',
294
+					],
295
+					'link' => [
296
+						'name'   => 'link',
297
+						'params' => ['rel'],
298
+						'link'   => 'href',
299
+					],
300
+					'a' => [
301
+						'link'       => 'href',
302
+						'name_value' => ['name'],
303
+						'target'     => 'target',
304
+					],
305
+					'iframe' => [
306
+						'link'               => 'src',
307
+						'default_attributes' => ['frameborder' => '0'],
308
+						'name_value'         => ['name'],
309
+					],
310
+					'img' => [
311
+						'link' => 'src',
312
+						'alt'  => 'alt',
313
+					],
314
+					'form'   => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post']],
315
+					'post'   => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post']],
316
+					'upload' => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'post', 'enctype' => 'multipart/form-data']],
317
+					'get'    => ['name' => 'form', 'link' => 'action', 'target' => 'target', 'name_value' => ['name'], 'default_attributes' => ['method' => 'get']],
318 318
 
319
-                    'input'          => ['name' => 'input',  'default_attributes' => ['type' => 'hidden'],         'name_value' => ['name', 'value', 'form']],
320
-                    'text'           => ['out' => ['name' => 'input',  'default_attributes' => ['type' => 'text'],           'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'], 'in' => ['svg' => ['params' => ['x', 'y']]]],
321
-                    'search'         => ['name' => 'input',  'default_attributes' => ['type' => 'search'],         'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
322
-                    'password'       => ['name' => 'input',  'default_attributes' => ['type' => 'password'],       'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
323
-                    'email'          => ['name' => 'input',  'default_attributes' => ['type' => 'email'],          'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
324
-                    'url'            => ['name' => 'input',  'default_attributes' => ['type' => 'url'],            'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
325
-                    'tel'            => ['name' => 'input',  'default_attributes' => ['type' => 'tel'],            'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
326
-                    'number'         => ['name' => 'input',  'default_attributes' => ['type' => 'number'],         'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder', 'params' => ['min', 'step', 'max']],
327
-                    'range'          => ['name' => 'input',  'default_attributes' => ['type' => 'range'],          'name_value' => ['name', 'value', 'form'],                'params' => ['min', 'step', 'max']],
328
-                    'radio'          => ['name' => 'input',  'default_attributes' => ['type' => 'radio'],          'name_value' => ['name', 'value', 'form']],
329
-                    'checkbox'       => ['name' => 'input',  'default_attributes' => ['type' => 'checkbox'],       'name_value' => ['name', 'value', 'form']],
330
-                    'date'           => ['name' => 'input',  'default_attributes' => ['type' => 'date'],           'name_value' => ['name', 'value', 'form']],
331
-                    'month'          => ['name' => 'input',  'default_attributes' => ['type' => 'month'],          'name_value' => ['name', 'value', 'form']],
332
-                    'week'           => ['name' => 'input',  'default_attributes' => ['type' => 'week'],           'name_value' => ['name', 'value', 'form']],
333
-                    'time'           => ['name' => 'input',  'default_attributes' => ['type' => 'time'],           'name_value' => ['name', 'value', 'form']],
334
-                    'datetime'       => ['name' => 'input',  'default_attributes' => ['type' => 'datetime'],       'name_value' => ['name', 'value', 'form']],
335
-                    'datetime-local' => ['name' => 'input',  'default_attributes' => ['type' => 'datetime-local'], 'name_value' => ['name', 'value', 'form']],
336
-                    'color'          => ['name' => 'input',  'default_attributes' => ['type' => 'color'],          'name_value' => ['name', 'value', 'form']],
337
-                    'file'           => ['name' => 'input',  'default_attributes' => ['type' => 'file'],           'name_value' => ['name', 'form'], 'params' => ['accept']],
319
+					'input'          => ['name' => 'input',  'default_attributes' => ['type' => 'hidden'],         'name_value' => ['name', 'value', 'form']],
320
+					'text'           => ['out' => ['name' => 'input',  'default_attributes' => ['type' => 'text'],           'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'], 'in' => ['svg' => ['params' => ['x', 'y']]]],
321
+					'search'         => ['name' => 'input',  'default_attributes' => ['type' => 'search'],         'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
322
+					'password'       => ['name' => 'input',  'default_attributes' => ['type' => 'password'],       'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
323
+					'email'          => ['name' => 'input',  'default_attributes' => ['type' => 'email'],          'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
324
+					'url'            => ['name' => 'input',  'default_attributes' => ['type' => 'url'],            'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
325
+					'tel'            => ['name' => 'input',  'default_attributes' => ['type' => 'tel'],            'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
326
+					'number'         => ['name' => 'input',  'default_attributes' => ['type' => 'number'],         'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder', 'params' => ['min', 'step', 'max']],
327
+					'range'          => ['name' => 'input',  'default_attributes' => ['type' => 'range'],          'name_value' => ['name', 'value', 'form'],                'params' => ['min', 'step', 'max']],
328
+					'radio'          => ['name' => 'input',  'default_attributes' => ['type' => 'radio'],          'name_value' => ['name', 'value', 'form']],
329
+					'checkbox'       => ['name' => 'input',  'default_attributes' => ['type' => 'checkbox'],       'name_value' => ['name', 'value', 'form']],
330
+					'date'           => ['name' => 'input',  'default_attributes' => ['type' => 'date'],           'name_value' => ['name', 'value', 'form']],
331
+					'month'          => ['name' => 'input',  'default_attributes' => ['type' => 'month'],          'name_value' => ['name', 'value', 'form']],
332
+					'week'           => ['name' => 'input',  'default_attributes' => ['type' => 'week'],           'name_value' => ['name', 'value', 'form']],
333
+					'time'           => ['name' => 'input',  'default_attributes' => ['type' => 'time'],           'name_value' => ['name', 'value', 'form']],
334
+					'datetime'       => ['name' => 'input',  'default_attributes' => ['type' => 'datetime'],       'name_value' => ['name', 'value', 'form']],
335
+					'datetime-local' => ['name' => 'input',  'default_attributes' => ['type' => 'datetime-local'], 'name_value' => ['name', 'value', 'form']],
336
+					'color'          => ['name' => 'input',  'default_attributes' => ['type' => 'color'],          'name_value' => ['name', 'value', 'form']],
337
+					'file'           => ['name' => 'input',  'default_attributes' => ['type' => 'file'],           'name_value' => ['name', 'form'], 'params' => ['accept']],
338 338
 
339
-                    'submit' => ['name' => 'button', 'default_attributes' => ['type' => 'submit'],         'name_value' => ['name', 'value', 'form'], 'link' => ' formaction', 'target' => 'formtarget'],
340
-                    'reset'  => ['name' => 'button', 'default_attributes' => ['type' => 'reset'],          'name_value' => ['form']],
341
-                    'button' => ['name' => 'button', 'default_attributes' => ['type' => 'button']],
339
+					'submit' => ['name' => 'button', 'default_attributes' => ['type' => 'submit'],         'name_value' => ['name', 'value', 'form'], 'link' => ' formaction', 'target' => 'formtarget'],
340
+					'reset'  => ['name' => 'button', 'default_attributes' => ['type' => 'reset'],          'name_value' => ['form']],
341
+					'button' => ['name' => 'button', 'default_attributes' => ['type' => 'button']],
342 342
 
343
-                    'textarea' => ['name' => 'textarea', 'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
343
+					'textarea' => ['name' => 'textarea', 'name_value' => ['name', 'value', 'form'], 'alt' => 'placeholder'],
344 344
 //*
345
-                    'select' => [
346
-                        'name_value' => ['name', 'value', 'form'],
347
-                        'scope'      => 'select',
348
-                    ],
349
-                    'datalist' => [
350
-                        'params' => ['id'],
351
-                        'scope'  => 'datalist',
352
-                    ],
353
-                    'optgroup' => [
354
-                        'in' => [
355
-                            'select' => [
356
-                                'name_value' => ['label'],
357
-                            ],
358
-                        ],
359
-                    ],
360
-                    'option' => [
361
-                        'in' => [
362
-                            'select' => [
363
-                                'scope_function' => function ($scope) {
364
-                                    if ($scope['value'] === $this['value']) {
365
-                                        $this['selected'] = 'selected';
366
-                                    }
367
-                                },
368
-                                'name_value' => ['value', 'label'],
369
-                            ],
370
-                            'datalist' => [
371
-                                'name_value' => ['value'],
372
-                            ],
373
-                        ],
374
-                    ],
345
+					'select' => [
346
+						'name_value' => ['name', 'value', 'form'],
347
+						'scope'      => 'select',
348
+					],
349
+					'datalist' => [
350
+						'params' => ['id'],
351
+						'scope'  => 'datalist',
352
+					],
353
+					'optgroup' => [
354
+						'in' => [
355
+							'select' => [
356
+								'name_value' => ['label'],
357
+							],
358
+						],
359
+					],
360
+					'option' => [
361
+						'in' => [
362
+							'select' => [
363
+								'scope_function' => function ($scope) {
364
+									if ($scope['value'] === $this['value']) {
365
+										$this['selected'] = 'selected';
366
+									}
367
+								},
368
+								'name_value' => ['value', 'label'],
369
+							],
370
+							'datalist' => [
371
+								'name_value' => ['value'],
372
+							],
373
+						],
374
+					],
375 375
 //*/
376
-                    'param' => [
377
-                        'name_value' => ['name', 'value'],
378
-                    ],
379
-                ] + $svgTags,
380
-            ],
381
-            'empty_tags' => [
382
-                'HTML5' => [
383
-                    'br'     => true,
384
-                    'hr'     => true,
385
-                    'img'    => true,
386
-                    'input'  => true,
387
-                    'link'   => true,
388
-                    'meta'   => true,
389
-                    'option' => true,
390
-                    'param'  => true,
391
-                ],
392
-                'SVG1.1' => [
393
-                    'polygon'  => true,
394
-                    'polyline' => true,
395
-                    'path'     => true,
396
-                    'line'     => true,
397
-                    'rect'     => true,
398
-                    'circle'   => true,
399
-                    'ellipse'  => true,
400
-                ],
401
-            ],
402
-            'indentation' => [
403
-                'HTML5'  => false,
404
-                'HTML4'  => false,
405
-                'XHTML'  => false,
406
-                'XML1'   => "\t",
407
-                'SVG1.1' => "\t",
408
-            ],
409
-        ];
410
-    }
376
+					'param' => [
377
+						'name_value' => ['name', 'value'],
378
+					],
379
+				] + $svgTags,
380
+			],
381
+			'empty_tags' => [
382
+				'HTML5' => [
383
+					'br'     => true,
384
+					'hr'     => true,
385
+					'img'    => true,
386
+					'input'  => true,
387
+					'link'   => true,
388
+					'meta'   => true,
389
+					'option' => true,
390
+					'param'  => true,
391
+				],
392
+				'SVG1.1' => [
393
+					'polygon'  => true,
394
+					'polyline' => true,
395
+					'path'     => true,
396
+					'line'     => true,
397
+					'rect'     => true,
398
+					'circle'   => true,
399
+					'ellipse'  => true,
400
+				],
401
+			],
402
+			'indentation' => [
403
+				'HTML5'  => false,
404
+				'HTML4'  => false,
405
+				'XHTML'  => false,
406
+				'XML1'   => "\t",
407
+				'SVG1.1' => "\t",
408
+			],
409
+		];
410
+	}
411 411
 }
Please login to merge, or discard this patch.
libs/Helper/IConfigProvider.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 
7 7
 interface IConfigProvider
8 8
 {
9
-    /**
10
-     * Getting configuration with cascaded keys.
11
-     *
12
-     * @param  string ...$key
13
-     *
14
-     * @return mixed
15
-     */
16
-    public function getConfig(string ...$key);
9
+	/**
10
+	 * Getting configuration with cascaded keys.
11
+	 *
12
+	 * @param  string ...$key
13
+	 *
14
+	 * @return mixed
15
+	 */
16
+	public function getConfig(string ...$key);
17 17
 }
Please login to merge, or discard this patch.
libs/Helper/TSetter.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 
7 7
 trait TSetter
8 8
 {
9
-    /**
10
-     * Allow setting fooBar setter with setFooBar().
11
-     *
12
-     * @param string $attribute
13
-     * @param mixed  $value
14
-     */
15
-    public function __set($attribute, $value)
16
-    {
17
-        if (is_callable([static::class, $setter = 'set'.implode('', array_map('ucfirst', explode('_', $attribute)))])) {
18
-            return static::$setter($value);
19
-        } else {
20
-            throw new \Exception(static::class.' has no attribute named '.$attribute);
21
-        }
22
-    }
9
+	/**
10
+	 * Allow setting fooBar setter with setFooBar().
11
+	 *
12
+	 * @param string $attribute
13
+	 * @param mixed  $value
14
+	 */
15
+	public function __set($attribute, $value)
16
+	{
17
+		if (is_callable([static::class, $setter = 'set'.implode('', array_map('ucfirst', explode('_', $attribute)))])) {
18
+			return static::$setter($value);
19
+		} else {
20
+			throw new \Exception(static::class.' has no attribute named '.$attribute);
21
+		}
22
+	}
23 23
 }
Please login to merge, or discard this patch.