@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * The end of line character used in the INI source string. |
|
67 | - * @return string |
|
68 | - */ |
|
65 | + /** |
|
66 | + * The end of line character used in the INI source string. |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public function getEOLChar() : string |
70 | 70 | { |
71 | 71 | return $this->eol; |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | ); |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Factory method: Creates a new ini helper instance from an ini string. |
|
104 | - * |
|
105 | - * @param string $iniContent |
|
106 | - * @return IniHelper |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Factory method: Creates a new ini helper instance from an ini string. |
|
104 | + * |
|
105 | + * @param string $iniContent |
|
106 | + * @return IniHelper |
|
107 | + */ |
|
108 | 108 | public static function createFromString(string $iniContent) : IniHelper |
109 | 109 | { |
110 | 110 | return new IniHelper($iniContent); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Factory method: Creates a new empty ini helper. |
|
115 | - * |
|
116 | - * @return IniHelper |
|
117 | - */ |
|
113 | + /** |
|
114 | + * Factory method: Creates a new empty ini helper. |
|
115 | + * |
|
116 | + * @return IniHelper |
|
117 | + */ |
|
118 | 118 | public static function createNew() : IniHelper |
119 | 119 | { |
120 | 120 | return self::createFromString(''); |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Adds a new data section, and returns the section instance. |
|
125 | - * If a section with the name already exists, returns that |
|
126 | - * section instead of creating a new one. |
|
127 | - * |
|
128 | - * @param string $name |
|
129 | - * @return IniHelper_Section |
|
130 | - */ |
|
123 | + /** |
|
124 | + * Adds a new data section, and returns the section instance. |
|
125 | + * If a section with the name already exists, returns that |
|
126 | + * section instead of creating a new one. |
|
127 | + * |
|
128 | + * @param string $name |
|
129 | + * @return IniHelper_Section |
|
130 | + */ |
|
131 | 131 | public function addSection(string $name) : IniHelper_Section |
132 | 132 | { |
133 | 133 | if(!isset($this->sections[$name])) { |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | return $this->sections[$name]; |
138 | 138 | } |
139 | 139 | |
140 | - /** |
|
141 | - * Retrieves a section by its name, if it exists. |
|
142 | - * |
|
143 | - * @param string $name |
|
144 | - * @return IniHelper_Section|NULL |
|
145 | - */ |
|
140 | + /** |
|
141 | + * Retrieves a section by its name, if it exists. |
|
142 | + * |
|
143 | + * @param string $name |
|
144 | + * @return IniHelper_Section|NULL |
|
145 | + */ |
|
146 | 146 | public function getSection(string $name) : ?IniHelper_Section |
147 | 147 | { |
148 | 148 | return $this->sections[$name] ?? null; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * Gets the data from the INI file as an associative array. |
|
153 | - * |
|
154 | - * @return array<string,mixed> |
|
155 | - */ |
|
151 | + /** |
|
152 | + * Gets the data from the INI file as an associative array. |
|
153 | + * |
|
154 | + * @return array<string,mixed> |
|
155 | + */ |
|
156 | 156 | public function toArray() : array |
157 | 157 | { |
158 | 158 | $result = array(); |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | return $result; |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Saves the INI content to the target file. |
|
177 | - * |
|
178 | - * @param string $filePath |
|
179 | - * @return IniHelper |
|
180 | - * @throws FileHelper_Exception |
|
181 | - * |
|
182 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
183 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
184 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
185 | - */ |
|
175 | + /** |
|
176 | + * Saves the INI content to the target file. |
|
177 | + * |
|
178 | + * @param string $filePath |
|
179 | + * @return IniHelper |
|
180 | + * @throws FileHelper_Exception |
|
181 | + * |
|
182 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
183 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
184 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
185 | + */ |
|
186 | 186 | public function saveToFile(string $filePath) : IniHelper |
187 | 187 | { |
188 | 188 | FileHelper::saveFile($filePath, $this->saveToString()); |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * Returns the INI content as string. |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
193 | + /** |
|
194 | + * Returns the INI content as string. |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | 198 | public function saveToString() : string |
199 | 199 | { |
200 | 200 | $parts = array(); |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | return implode($this->eol, $parts); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Sets or adds the value of a setting in the INI content. |
|
212 | - * If the setting does not exist, it is added. Otherwise, |
|
213 | - * the existing value is overwritten. |
|
214 | - * |
|
215 | - * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
216 | - * @param mixed $value |
|
217 | - * @return IniHelper |
|
218 | - */ |
|
210 | + /** |
|
211 | + * Sets or adds the value of a setting in the INI content. |
|
212 | + * If the setting does not exist, it is added. Otherwise, |
|
213 | + * the existing value is overwritten. |
|
214 | + * |
|
215 | + * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
216 | + * @param mixed $value |
|
217 | + * @return IniHelper |
|
218 | + */ |
|
219 | 219 | public function setValue(string $path, $value) : IniHelper |
220 | 220 | { |
221 | 221 | $info = $this->parsePath($path); |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | return $this; |
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
243 | - * Checks whether a section with the specified name exists. |
|
244 | - * |
|
245 | - * @param string $name |
|
246 | - * @return bool |
|
247 | - */ |
|
242 | + /** |
|
243 | + * Checks whether a section with the specified name exists. |
|
244 | + * |
|
245 | + * @param string $name |
|
246 | + * @return bool |
|
247 | + */ |
|
248 | 248 | public function sectionExists(string $name) : bool |
249 | 249 | { |
250 | 250 | foreach($this->sections as $section) { |
@@ -256,23 +256,23 @@ discard block |
||
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
259 | - /** |
|
260 | - * Retrieves the default section, which is used to add |
|
261 | - * values in the root of the document. |
|
262 | - * |
|
263 | - * @return IniHelper_Section |
|
264 | - */ |
|
259 | + /** |
|
260 | + * Retrieves the default section, which is used to add |
|
261 | + * values in the root of the document. |
|
262 | + * |
|
263 | + * @return IniHelper_Section |
|
264 | + */ |
|
265 | 265 | public function getDefaultSection() : IniHelper_Section |
266 | 266 | { |
267 | 267 | return $this->addSection(self::SECTION_DEFAULT); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Retrieves all variable lines for the specified path. |
|
272 | - * |
|
273 | - * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
274 | - * @return INILine[] |
|
275 | - */ |
|
270 | + /** |
|
271 | + * Retrieves all variable lines for the specified path. |
|
272 | + * |
|
273 | + * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
274 | + * @return INILine[] |
|
275 | + */ |
|
276 | 276 | public function getLinesByVariable(string $path) : array |
277 | 277 | { |
278 | 278 | $info = $this->parsePath($path); |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | protected IniHelper $ini; |
27 | 27 | protected string $name; |
28 | 28 | |
29 | - /** |
|
30 | - * @var INILine[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var INILine[] |
|
31 | + */ |
|
32 | 32 | protected array $lines = array(); |
33 | 33 | |
34 | 34 | public function __construct(IniHelper $ini, string $name) |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | $this->name = $name; |
38 | 38 | } |
39 | 39 | |
40 | - /** |
|
41 | - * The section's name. |
|
42 | - * @return string |
|
43 | - */ |
|
40 | + /** |
|
41 | + * The section's name. |
|
42 | + * @return string |
|
43 | + */ |
|
44 | 44 | public function getName() : string |
45 | 45 | { |
46 | 46 | return $this->name; |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Whether this is the default section: this |
|
51 | - * is used internally to store all variables that |
|
52 | - * are not in any specific section. |
|
53 | - * |
|
54 | - * @return bool |
|
55 | - */ |
|
49 | + /** |
|
50 | + * Whether this is the default section: this |
|
51 | + * is used internally to store all variables that |
|
52 | + * are not in any specific section. |
|
53 | + * |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | 56 | public function isDefault() : bool |
57 | 57 | { |
58 | 58 | return $this->name === IniHelper::SECTION_DEFAULT; |
59 | 59 | } |
60 | 60 | |
61 | - /** |
|
62 | - * Adds a line instance to the section. |
|
63 | - * |
|
64 | - * @param INILine $line |
|
65 | - * @return IniHelper_Section |
|
66 | - */ |
|
61 | + /** |
|
62 | + * Adds a line instance to the section. |
|
63 | + * |
|
64 | + * @param INILine $line |
|
65 | + * @return IniHelper_Section |
|
66 | + */ |
|
67 | 67 | public function addLine(INILine $line) : IniHelper_Section |
68 | 68 | { |
69 | 69 | $this->lines[] = $line; |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Converts the values contained in the section into |
|
76 | - * an associative array. |
|
77 | - * |
|
78 | - * @return array<string,array<int,string>> |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Converts the values contained in the section into |
|
76 | + * an associative array. |
|
77 | + * |
|
78 | + * @return array<string,array<int,string>> |
|
79 | + */ |
|
80 | 80 | public function toArray() : array |
81 | 81 | { |
82 | 82 | $result = array(); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | return implode($this->ini->getEOLChar(), $lines); |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * Deletes a line from the section. |
|
141 | - * |
|
142 | - * @param INILine $toDelete |
|
143 | - * @return IniHelper_Section |
|
144 | - */ |
|
139 | + /** |
|
140 | + * Deletes a line from the section. |
|
141 | + * |
|
142 | + * @param INILine $toDelete |
|
143 | + * @return IniHelper_Section |
|
144 | + */ |
|
145 | 145 | public function deleteLine(INILine $toDelete) : IniHelper_Section |
146 | 146 | { |
147 | 147 | $keep = array(); |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | return $this; |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * Adds a variable value to the section. Unlike setValue(), this |
|
231 | - * will not overwrite any existing value. If the name is an existing |
|
232 | - * variable name, it will be converted to duplicate keys. |
|
233 | - * |
|
234 | - * @param string $name |
|
235 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
236 | - * @return IniHelper_Section |
|
237 | - */ |
|
229 | + /** |
|
230 | + * Adds a variable value to the section. Unlike setValue(), this |
|
231 | + * will not overwrite any existing value. If the name is an existing |
|
232 | + * variable name, it will be converted to duplicate keys. |
|
233 | + * |
|
234 | + * @param string $name |
|
235 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
236 | + * @return IniHelper_Section |
|
237 | + */ |
|
238 | 238 | public function addValue(string $name, $value) : IniHelper_Section |
239 | 239 | { |
240 | 240 | // array value? Treat it as duplicate keys. |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | |
300 | - /** |
|
301 | - * Retrieves all lines for the specified variable name. |
|
302 | - * |
|
303 | - * @param string $name |
|
304 | - * @return INILine[] |
|
305 | - */ |
|
300 | + /** |
|
301 | + * Retrieves all lines for the specified variable name. |
|
302 | + * |
|
303 | + * @param string $name |
|
304 | + * @return INILine[] |
|
305 | + */ |
|
306 | 306 | public function getLinesByVariable(string $name) : array |
307 | 307 | { |
308 | 308 | $result = array(); |
@@ -27,9 +27,9 @@ |
||
27 | 27 | protected RequestParam $param; |
28 | 28 | protected bool $isSubvalue = false; |
29 | 29 | |
30 | - /** |
|
31 | - * @var mixed|NULL |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var mixed|NULL |
|
32 | + */ |
|
33 | 33 | protected $value; |
34 | 34 | |
35 | 35 | public function __construct(RequestParam $param, bool $subval) |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | protected bool $isValid = false; |
43 | 43 | protected bool $encodeUTF = false; |
44 | 44 | |
45 | - /** |
|
46 | - * @var array{code:int,message:string}|NULL |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var array{code:int,message:string}|NULL |
|
47 | + */ |
|
48 | 48 | protected ?array $error = null; |
49 | 49 | |
50 | - /** |
|
51 | - * Stores a list of all unicode characters in the URL |
|
52 | - * that have been filtered out before parsing it with |
|
53 | - * parse_url. |
|
54 | - * |
|
55 | - * @var array<string,string> |
|
56 | - */ |
|
50 | + /** |
|
51 | + * Stores a list of all unicode characters in the URL |
|
52 | + * that have been filtered out before parsing it with |
|
53 | + * parse_url. |
|
54 | + * |
|
55 | + * @var array<string,string> |
|
56 | + */ |
|
57 | 57 | protected array $unicodeChars = array(); |
58 | 58 | |
59 | 59 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | ); |
79 | 79 | |
80 | 80 | /** |
81 | - * |
|
82 | - * @param string $url The target URL. |
|
83 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
84 | - */ |
|
81 | + * |
|
82 | + * @param string $url The target URL. |
|
83 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
84 | + */ |
|
85 | 85 | public function __construct(string $url, bool $encodeUTF) |
86 | 86 | { |
87 | 87 | $this->url = $url; |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $this->validate(); |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Retrieves the array as parsed by PHP's parse_url, |
|
97 | - * filtered and adjusted as necessary. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
95 | + /** |
|
96 | + * Retrieves the array as parsed by PHP's parse_url, |
|
97 | + * filtered and adjusted as necessary. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | 101 | public function getInfo() : array |
102 | 102 | { |
103 | 103 | return $this->info; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Finds any non-url encoded unicode characters in |
|
124 | - * the URL, and encodes them before the URL is |
|
125 | - * passed to parse_url. |
|
126 | - */ |
|
122 | + /** |
|
123 | + * Finds any non-url encoded unicode characters in |
|
124 | + * the URL, and encodes them before the URL is |
|
125 | + * passed to parse_url. |
|
126 | + */ |
|
127 | 127 | protected function filterUnicodeChars() : void |
128 | 128 | { |
129 | 129 | $chars = ConvertHelper::string2array($this->url); |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | $this->isValid = true; |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Goes through all information in the parse_url result |
|
199 | - * array, and attempts to fix any user errors in formatting |
|
200 | - * that can be recovered from, mostly regarding stray spaces. |
|
201 | - */ |
|
197 | + /** |
|
198 | + * Goes through all information in the parse_url result |
|
199 | + * array, and attempts to fix any user errors in formatting |
|
200 | + * that can be recovered from, mostly regarding stray spaces. |
|
201 | + */ |
|
202 | 202 | protected function filterParsed() : void |
203 | 203 | { |
204 | 204 | $this->info = (new ParsedInfoFilter($this->url, $this->info))->filter(); |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * Recursively goes through the array, and converts all previously |
|
209 | - * URL encoded characters with their unicode character counterparts. |
|
210 | - * |
|
211 | - * @param array $subject |
|
212 | - * @return array |
|
213 | - */ |
|
207 | + /** |
|
208 | + * Recursively goes through the array, and converts all previously |
|
209 | + * URL encoded characters with their unicode character counterparts. |
|
210 | + * |
|
211 | + * @param array $subject |
|
212 | + * @return array |
|
213 | + */ |
|
214 | 214 | protected function restoreUnicodeChars(array $subject) : array |
215 | 215 | { |
216 | 216 | $result = array(); |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | return $result; |
235 | 235 | } |
236 | 236 | |
237 | - /** |
|
238 | - * Replaces all URL encoded unicode characters |
|
239 | - * in the string with the unicode character. |
|
240 | - * |
|
241 | - * @param string $string |
|
242 | - * @return string |
|
243 | - */ |
|
237 | + /** |
|
238 | + * Replaces all URL encoded unicode characters |
|
239 | + * in the string with the unicode character. |
|
240 | + * |
|
241 | + * @param string $string |
|
242 | + * @return string |
|
243 | + */ |
|
244 | 244 | protected function restoreUnicodeChar(string $string) : string |
245 | 245 | { |
246 | 246 | if(strpos($string, '%') !== false) |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | ); |
262 | 262 | } |
263 | 263 | |
264 | - /** |
|
265 | - * Checks whether the URL that was parsed is valid. |
|
266 | - * @return bool |
|
267 | - */ |
|
264 | + /** |
|
265 | + * Checks whether the URL that was parsed is valid. |
|
266 | + * @return bool |
|
267 | + */ |
|
268 | 268 | public function isValid() : bool |
269 | 269 | { |
270 | 270 | return $this->isValid; |
271 | 271 | } |
272 | 272 | |
273 | - /** |
|
274 | - * If the validation failed, retrieves the validation |
|
275 | - * error message. |
|
276 | - * |
|
277 | - * @return string |
|
278 | - */ |
|
273 | + /** |
|
274 | + * If the validation failed, retrieves the validation |
|
275 | + * error message. |
|
276 | + * |
|
277 | + * @return string |
|
278 | + */ |
|
279 | 279 | public function getErrorMessage() : string |
280 | 280 | { |
281 | 281 | return $this->error['message'] ?? ''; |
282 | 282 | } |
283 | 283 | |
284 | - /** |
|
285 | - * If the validation failed, retrieves the validation |
|
286 | - * error code. |
|
287 | - * |
|
288 | - * @return int |
|
289 | - */ |
|
284 | + /** |
|
285 | + * If the validation failed, retrieves the validation |
|
286 | + * error code. |
|
287 | + * |
|
288 | + * @return int |
|
289 | + */ |
|
290 | 290 | public function getErrorCode() : int |
291 | 291 | { |
292 | 292 | return $this->error['code'] ?? -1; |