1 | <?php |
||
21 | class Htsl implements IConfigProvider |
||
22 | { |
||
23 | /** |
||
24 | * Getter of file content. |
||
25 | * |
||
26 | * @var callable |
||
27 | * |
||
28 | * @access protected |
||
29 | */ |
||
30 | protected $fileGetter; |
||
31 | |||
32 | /** |
||
33 | * The base path. |
||
34 | * |
||
35 | * @var string |
||
36 | * |
||
37 | * @access protected |
||
38 | */ |
||
39 | protected $basePath; |
||
40 | |||
41 | /** |
||
42 | * Configurations. |
||
43 | * |
||
44 | * @var array |
||
45 | * |
||
46 | * @access protected |
||
47 | */ |
||
48 | protected $config; |
||
49 | |||
50 | /** |
||
51 | * Constructor of HTSL |
||
52 | * |
||
53 | * @api |
||
54 | * |
||
55 | * @access public |
||
56 | * |
||
57 | * @param array $config |
||
58 | */ |
||
59 | public function __construct( array$config=[] ) |
||
63 | |||
64 | /** |
||
65 | * Parsing a HTSL code string into HTML or PHP code string. |
||
66 | * |
||
67 | * @api |
||
68 | * |
||
69 | * @access public |
||
70 | * |
||
71 | * @param string $content |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function parse( string$content ):string |
||
79 | |||
80 | /** |
||
81 | * Compiling a HTSL file into a HTML or PHP file. |
||
82 | * |
||
83 | * @api |
||
84 | * |
||
85 | * @access public |
||
86 | * |
||
87 | * @param string $fromFile |
||
88 | * @param string $toFile |
||
89 | * |
||
90 | * @return int|string |
||
91 | */ |
||
92 | public function compile( string$fromFile, string$toFile='' ) |
||
104 | |||
105 | /** |
||
106 | * Setting the file getter. |
||
107 | * |
||
108 | * @api |
||
109 | * |
||
110 | * @access public |
||
111 | * |
||
112 | * @param callable $fileGetter |
||
113 | */ |
||
114 | public function setFileGetter( callable$fileGetter ):self |
||
120 | |||
121 | /** |
||
122 | * Setting the base path of the HTSL project to parse. |
||
123 | * |
||
124 | * @api |
||
125 | * |
||
126 | * @access public |
||
127 | * |
||
128 | * @param string $basePath |
||
129 | * |
||
130 | * @return self |
||
131 | */ |
||
132 | public function setBasePath( string$basePath ):self |
||
138 | |||
139 | /** |
||
140 | * Returning whether the debug model is on or off. |
||
141 | * |
||
142 | * @api |
||
143 | * |
||
144 | * @access public |
||
145 | * |
||
146 | * @return boolean |
||
147 | */ |
||
148 | public function isDebug():bool |
||
152 | |||
153 | /** |
||
154 | * Executing the parsing. |
||
155 | * |
||
156 | * @internal |
||
157 | * |
||
158 | * @access protected |
||
159 | * |
||
160 | * @param \Htsl\ReadingBuffer\Contracts\ABuffer $buffer |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | protected function execute( ABuffer$buffer ):string |
||
168 | |||
169 | /** |
||
170 | * Getting the config of Htsl. |
||
171 | * |
||
172 | * @internal |
||
173 | * |
||
174 | * @access public |
||
175 | * |
||
176 | * @param string $keys |
||
177 | * |
||
178 | * @return mixed |
||
179 | */ |
||
180 | public function getConfig( string...$keys ) |
||
193 | |||
194 | /** |
||
195 | * Getting the real file path of the HTSL file by relative path. |
||
196 | * |
||
197 | * @internal |
||
198 | * |
||
199 | * @access public |
||
200 | * |
||
201 | * @param string $filePath |
||
202 | * @param string|null $path |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | public function getFilePath( string$filePath, string$path=null ):string |
||
229 | |||
230 | /** |
||
231 | * Getting the content of file. |
||
232 | * |
||
233 | * @internal |
||
234 | * |
||
235 | * @access public |
||
236 | * |
||
237 | * @param string $filePath |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | public function getFileContent( string$filePath ):string |
||
245 | |||
246 | /** |
||
247 | * Getting default config. |
||
248 | * |
||
249 | * @internal |
||
250 | * |
||
251 | * @access private |
||
252 | * |
||
253 | * @return array |
||
254 | */ |
||
255 | private function getDefaultConfigs():array |
||
259 | } |
||
260 |
This check looks for improperly formatted assignments.
Every assignment must have exactly one space before and one space after the equals operator.
To illustrate:
will have no issues, while
will report issues in lines 1 and 2.