@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | protected function _validate() |
31 | 31 | { |
32 | - if(in_array($this->value, $this->getArrayOption('values'))) { |
|
32 | + if (in_array($this->value, $this->getArrayOption('values'))) { |
|
33 | 33 | return $this->value; |
34 | 34 | } |
35 | 35 |
@@ -6,9 +6,9 @@ |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer_String extends VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected function init() |
@@ -40,7 +40,7 @@ |
||
40 | 40 | str_replace(' ', '-', $this->type) |
41 | 41 | ); |
42 | 42 | |
43 | - if($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
43 | + if ($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
44 | 44 | { |
45 | 45 | $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$this->info->getType().'</span> '; |
46 | 46 | $converted = $typeLabel.' '.$converted; |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | - /** |
|
15 | - * @var VariableInfo |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var VariableInfo |
|
16 | + */ |
|
17 | 17 | protected $info; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | protected $type; |
23 | 23 | |
24 | 24 | public function __construct(VariableInfo $info) |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | abstract protected function init(); |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the value to the target format. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Renders the value to the target format. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | 39 | public function render() |
40 | 40 | { |
41 | 41 | return $this->_render(); |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class XMLHelper_Converter_Decorator implements \JsonSerializable |
23 | 23 | { |
24 | - /** |
|
25 | - * @var \SimpleXMLElement |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var \SimpleXMLElement |
|
26 | + */ |
|
27 | 27 | private $subject; |
28 | 28 | |
29 | 29 | const DEF_DEPTH = 512; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | 34 | private $options = array( |
35 | 35 | '@attributes' => true, |
36 | 36 | '@text' => true, |
37 | 37 | 'depth' => self::DEF_DEPTH |
38 | 38 | ); |
39 | 39 | |
40 | - /** |
|
41 | - * @var array|string|null |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var array|string|null |
|
42 | + */ |
|
43 | 43 | protected $result = array(); |
44 | 44 | |
45 | 45 | public function __construct(\SimpleXMLElement $element) |
@@ -47,36 +47,36 @@ discard block |
||
47 | 47 | $this->subject = $element; |
48 | 48 | } |
49 | 49 | |
50 | - /** |
|
51 | - * Whether to use the `@attributes` key to store element attributes. |
|
52 | - * |
|
53 | - * @param bool $bool |
|
54 | - * @return XMLHelper_Converter_Decorator |
|
55 | - */ |
|
50 | + /** |
|
51 | + * Whether to use the `@attributes` key to store element attributes. |
|
52 | + * |
|
53 | + * @param bool $bool |
|
54 | + * @return XMLHelper_Converter_Decorator |
|
55 | + */ |
|
56 | 56 | public function useAttributes(bool $bool) : XMLHelper_Converter_Decorator |
57 | 57 | { |
58 | 58 | $this->options['@attributes'] = (bool)$bool; |
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Whether to use the `@text` key to store the node text. |
|
64 | - * |
|
65 | - * @param bool $bool |
|
66 | - * @return XMLHelper_Converter_Decorator |
|
67 | - */ |
|
62 | + /** |
|
63 | + * Whether to use the `@text` key to store the node text. |
|
64 | + * |
|
65 | + * @param bool $bool |
|
66 | + * @return XMLHelper_Converter_Decorator |
|
67 | + */ |
|
68 | 68 | public function useText(bool $bool) : XMLHelper_Converter_Decorator |
69 | 69 | { |
70 | 70 | $this->options['@text'] = (bool)$bool; |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Set the maximum depth to parse in the document. |
|
76 | - * |
|
77 | - * @param int $depth |
|
78 | - * @return XMLHelper_Converter_Decorator |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Set the maximum depth to parse in the document. |
|
76 | + * |
|
77 | + * @param int $depth |
|
78 | + * @return XMLHelper_Converter_Decorator |
|
79 | + */ |
|
80 | 80 | public function setDepth(int $depth) : XMLHelper_Converter_Decorator |
81 | 81 | { |
82 | 82 | $this->options['depth'] = (int)max(0, $depth); |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | |
108 | 108 | protected function detectAttributes() |
109 | 109 | { |
110 | - if(!$this->options['@attributes']) { |
|
110 | + if (!$this->options['@attributes']) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $attributes = $this->subject->attributes(); |
115 | 115 | |
116 | - if(!empty($attributes)) |
|
116 | + if (!empty($attributes)) |
|
117 | 117 | { |
118 | 118 | $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes)); |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $children = $this->subject; |
125 | 125 | $depth = $this->options['depth'] - 1; |
126 | 126 | |
127 | - if($depth <= 0) |
|
127 | + if ($depth <= 0) |
|
128 | 128 | { |
129 | 129 | $children = []; |
130 | 130 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | $decorator->options = ['depth' => $depth] + $this->options; |
139 | 139 | |
140 | - if(isset($this->result[$name])) |
|
140 | + if (isset($this->result[$name])) |
|
141 | 141 | { |
142 | - if(!is_array($this->result[$name])) |
|
142 | + if (!is_array($this->result[$name])) |
|
143 | 143 | { |
144 | 144 | $this->result[$name] = [$this->result[$name]]; |
145 | 145 | } |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | // json encode non-whitespace element simplexml text values. |
159 | 159 | $text = trim((string)$this->subject); |
160 | 160 | |
161 | - if(strlen($text)) |
|
161 | + if (strlen($text)) |
|
162 | 162 | { |
163 | - if($this->options['@text']) |
|
163 | + if ($this->options['@text']) |
|
164 | 164 | { |
165 | 165 | $this->result['@text'] = $text; |
166 | 166 | } |
@@ -145,8 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $this->result[$name][] = $decorator; |
148 | - } |
|
149 | - else |
|
148 | + } else |
|
150 | 149 | { |
151 | 150 | $this->result[$name] = $decorator; |
152 | 151 | } |
@@ -163,8 +162,7 @@ discard block |
||
163 | 162 | if($this->options['@text']) |
164 | 163 | { |
165 | 164 | $this->result['@text'] = $text; |
166 | - } |
|
167 | - else |
|
165 | + } else |
|
168 | 166 | { |
169 | 167 | $this->result = $text; |
170 | 168 | } |
@@ -367,8 +367,7 @@ |
||
367 | 367 | if(!in_array($extension, $include)) { |
368 | 368 | return false; |
369 | 369 | } |
370 | - } |
|
371 | - else if(!empty($exclude)) |
|
370 | + } else if(!empty($exclude)) |
|
372 | 371 | { |
373 | 372 | if(in_array($extension, $exclude)) { |
374 | 373 | return false; |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | const OPTION_PATHMODE = 'pathmode'; |
38 | 38 | |
39 | 39 | /** |
40 | - * @var string |
|
41 | - */ |
|
40 | + * @var string |
|
41 | + */ |
|
42 | 42 | protected $path; |
43 | 43 | |
44 | - /** |
|
45 | - * @var string[] |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var string[] |
|
46 | + */ |
|
47 | 47 | protected $found; |
48 | 48 | |
49 | - /** |
|
50 | - * The path must exist when the class is instantiated: its |
|
51 | - * real path will be determined to work with. |
|
52 | - * |
|
53 | - * @param string $path The absolute path to the target folder. |
|
54 | - * @throws FileHelper_Exception |
|
55 | - * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST |
|
56 | - */ |
|
49 | + /** |
|
50 | + * The path must exist when the class is instantiated: its |
|
51 | + * real path will be determined to work with. |
|
52 | + * |
|
53 | + * @param string $path The absolute path to the target folder. |
|
54 | + * @throws FileHelper_Exception |
|
55 | + * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST |
|
56 | + */ |
|
57 | 57 | public function __construct(string $path) |
58 | 58 | { |
59 | 59 | $real = realpath($path); |
@@ -85,66 +85,66 @@ discard block |
||
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - /** |
|
89 | - * Enables extension stripping, to return file names without extension. |
|
90 | - * |
|
91 | - * @return FileHelper_FileFinder |
|
92 | - */ |
|
88 | + /** |
|
89 | + * Enables extension stripping, to return file names without extension. |
|
90 | + * |
|
91 | + * @return FileHelper_FileFinder |
|
92 | + */ |
|
93 | 93 | public function stripExtensions() : FileHelper_FileFinder |
94 | 94 | { |
95 | 95 | return $this->setOption('strip-extensions', true); |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Enables recursing into subfolders. |
|
100 | - * |
|
101 | - * @return FileHelper_FileFinder |
|
102 | - */ |
|
98 | + /** |
|
99 | + * Enables recursing into subfolders. |
|
100 | + * |
|
101 | + * @return FileHelper_FileFinder |
|
102 | + */ |
|
103 | 103 | public function makeRecursive() : FileHelper_FileFinder |
104 | 104 | { |
105 | 105 | return $this->setOption('recursive', true); |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Retrieves all extensions that were added to |
|
110 | - * the include list. |
|
111 | - * |
|
112 | - * @return string[] |
|
113 | - */ |
|
108 | + /** |
|
109 | + * Retrieves all extensions that were added to |
|
110 | + * the include list. |
|
111 | + * |
|
112 | + * @return string[] |
|
113 | + */ |
|
114 | 114 | public function getIncludeExtensions() : array |
115 | 115 | { |
116 | 116 | return $this->getArrayOption(self::OPTION_INCLUDE_EXTENSIONS); |
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * Includes a single extension in the file search: only |
|
121 | - * files with this extension will be used in the results. |
|
122 | - * |
|
123 | - * NOTE: Included extensions take precedence before excluded |
|
124 | - * extensions. If any excluded extensions are specified, they |
|
125 | - * will be ignored. |
|
126 | - * |
|
127 | - * @param string $extension Extension name, without dot (`php` for example). |
|
128 | - * @return FileHelper_FileFinder |
|
129 | - * @see FileHelper_FileFinder::includeExtensions() |
|
130 | - */ |
|
119 | + /** |
|
120 | + * Includes a single extension in the file search: only |
|
121 | + * files with this extension will be used in the results. |
|
122 | + * |
|
123 | + * NOTE: Included extensions take precedence before excluded |
|
124 | + * extensions. If any excluded extensions are specified, they |
|
125 | + * will be ignored. |
|
126 | + * |
|
127 | + * @param string $extension Extension name, without dot (`php` for example). |
|
128 | + * @return FileHelper_FileFinder |
|
129 | + * @see FileHelper_FileFinder::includeExtensions() |
|
130 | + */ |
|
131 | 131 | public function includeExtension(string $extension) : FileHelper_FileFinder |
132 | 132 | { |
133 | 133 | return $this->includeExtensions(array($extension)); |
134 | 134 | } |
135 | 135 | |
136 | - /** |
|
137 | - * Includes several extensions in the file search: only |
|
138 | - * files with these extensions wil be used in the results. |
|
139 | - * |
|
140 | - * NOTE: Included extensions take precedence before excluded |
|
141 | - * extensions. If any excluded extensions are specified, they |
|
142 | - * will be ignored. |
|
143 | - * |
|
144 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
145 | - * @return FileHelper_FileFinder |
|
146 | - * @see FileHelper_FileFinder::includeExtension() |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Includes several extensions in the file search: only |
|
138 | + * files with these extensions wil be used in the results. |
|
139 | + * |
|
140 | + * NOTE: Included extensions take precedence before excluded |
|
141 | + * extensions. If any excluded extensions are specified, they |
|
142 | + * will be ignored. |
|
143 | + * |
|
144 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
145 | + * @return FileHelper_FileFinder |
|
146 | + * @see FileHelper_FileFinder::includeExtension() |
|
147 | + */ |
|
148 | 148 | public function includeExtensions(array $extensions) : FileHelper_FileFinder |
149 | 149 | { |
150 | 150 | $items = $this->getIncludeExtensions(); |
@@ -155,37 +155,37 @@ discard block |
||
155 | 155 | return $this; |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Retrieves a list of all extensions currently set as |
|
160 | - * excluded from the search. |
|
161 | - * |
|
162 | - * @return string[] |
|
163 | - */ |
|
158 | + /** |
|
159 | + * Retrieves a list of all extensions currently set as |
|
160 | + * excluded from the search. |
|
161 | + * |
|
162 | + * @return string[] |
|
163 | + */ |
|
164 | 164 | public function getExcludeExtensions() : array |
165 | 165 | { |
166 | 166 | return $this->getArrayOption(self::OPTION_EXCLUDE_EXTENSIONS); |
167 | 167 | } |
168 | 168 | |
169 | - /** |
|
170 | - * Excludes a single extension from the search. |
|
171 | - * |
|
172 | - * @param string $extension Extension name, without dot (`php` for example). |
|
173 | - * @return FileHelper_FileFinder |
|
174 | - * @see FileHelper_FileFinder::excludeExtensions() |
|
175 | - */ |
|
169 | + /** |
|
170 | + * Excludes a single extension from the search. |
|
171 | + * |
|
172 | + * @param string $extension Extension name, without dot (`php` for example). |
|
173 | + * @return FileHelper_FileFinder |
|
174 | + * @see FileHelper_FileFinder::excludeExtensions() |
|
175 | + */ |
|
176 | 176 | public function excludeExtension(string $extension) : FileHelper_FileFinder |
177 | 177 | { |
178 | 178 | return $this->excludeExtensions(array($extension)); |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Add several extensions to the list of extensions to |
|
183 | - * exclude from the file search. |
|
184 | - * |
|
185 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
186 | - * @return FileHelper_FileFinder |
|
187 | - * @see FileHelper_FileFinder::excludeExtension() |
|
188 | - */ |
|
181 | + /** |
|
182 | + * Add several extensions to the list of extensions to |
|
183 | + * exclude from the file search. |
|
184 | + * |
|
185 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
186 | + * @return FileHelper_FileFinder |
|
187 | + * @see FileHelper_FileFinder::excludeExtension() |
|
188 | + */ |
|
189 | 189 | public function excludeExtensions(array $extensions) : FileHelper_FileFinder |
190 | 190 | { |
191 | 191 | $items = $this->getExcludeExtensions(); |
@@ -196,52 +196,52 @@ discard block |
||
196 | 196 | return $this; |
197 | 197 | } |
198 | 198 | |
199 | - /** |
|
200 | - * In this mode, the entire path to the file will be stripped, |
|
201 | - * leaving only the file name in the files list. |
|
202 | - * |
|
203 | - * @return FileHelper_FileFinder |
|
204 | - */ |
|
199 | + /** |
|
200 | + * In this mode, the entire path to the file will be stripped, |
|
201 | + * leaving only the file name in the files list. |
|
202 | + * |
|
203 | + * @return FileHelper_FileFinder |
|
204 | + */ |
|
205 | 205 | public function setPathmodeStrip() : FileHelper_FileFinder |
206 | 206 | { |
207 | 207 | return $this->setPathmode(self::PATH_MODE_STRIP); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * In this mode, only the path relative to the source folder |
|
212 | - * will be included in the files list. |
|
213 | - * |
|
214 | - * @return FileHelper_FileFinder |
|
215 | - */ |
|
210 | + /** |
|
211 | + * In this mode, only the path relative to the source folder |
|
212 | + * will be included in the files list. |
|
213 | + * |
|
214 | + * @return FileHelper_FileFinder |
|
215 | + */ |
|
216 | 216 | public function setPathmodeRelative() : FileHelper_FileFinder |
217 | 217 | { |
218 | 218 | return $this->setPathmode(self::PATH_MODE_RELATIVE); |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * In this mode, the full, absolute paths to the files will |
|
223 | - * be included in the files list. |
|
224 | - * |
|
225 | - * @return FileHelper_FileFinder |
|
226 | - */ |
|
221 | + /** |
|
222 | + * In this mode, the full, absolute paths to the files will |
|
223 | + * be included in the files list. |
|
224 | + * |
|
225 | + * @return FileHelper_FileFinder |
|
226 | + */ |
|
227 | 227 | public function setPathmodeAbsolute() : FileHelper_FileFinder |
228 | 228 | { |
229 | 229 | return $this->setPathmode(self::PATH_MODE_ABSOLUTE); |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * This sets a character or string to replace the slashes |
|
234 | - * in the paths with. |
|
235 | - * |
|
236 | - * This is used for example in the `getPHPClassNames()` |
|
237 | - * method, to return files from subfolders as class names |
|
238 | - * using the "_" character: |
|
239 | - * |
|
240 | - * Subfolder/To/File.php => Subfolder_To_File.php |
|
241 | - * |
|
242 | - * @param string $character |
|
243 | - * @return FileHelper_FileFinder |
|
244 | - */ |
|
232 | + /** |
|
233 | + * This sets a character or string to replace the slashes |
|
234 | + * in the paths with. |
|
235 | + * |
|
236 | + * This is used for example in the `getPHPClassNames()` |
|
237 | + * method, to return files from subfolders as class names |
|
238 | + * using the "_" character: |
|
239 | + * |
|
240 | + * Subfolder/To/File.php => Subfolder_To_File.php |
|
241 | + * |
|
242 | + * @param string $character |
|
243 | + * @return FileHelper_FileFinder |
|
244 | + */ |
|
245 | 245 | public function setSlashReplacement(string $character) : FileHelper_FileFinder |
246 | 246 | { |
247 | 247 | return $this->setOption('slash-replacement', $character); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | return $this->setOption(self::OPTION_PATHMODE, $mode); |
265 | 265 | } |
266 | 266 | |
267 | - /** |
|
268 | - * Retrieves a list of all matching file names/paths, |
|
269 | - * depending on the selected options. |
|
270 | - * |
|
271 | - * @return string[] |
|
272 | - */ |
|
267 | + /** |
|
268 | + * Retrieves a list of all matching file names/paths, |
|
269 | + * depending on the selected options. |
|
270 | + * |
|
271 | + * @return string[] |
|
272 | + */ |
|
273 | 273 | public function getAll() : array |
274 | 274 | { |
275 | 275 | $this->find($this->path, true); |
@@ -277,24 +277,24 @@ discard block |
||
277 | 277 | return $this->found; |
278 | 278 | } |
279 | 279 | |
280 | - /** |
|
281 | - * Retrieves only PHP files. Can be combined with other |
|
282 | - * options like enabling recursion into subfolders. |
|
283 | - * |
|
284 | - * @return string[] |
|
285 | - */ |
|
280 | + /** |
|
281 | + * Retrieves only PHP files. Can be combined with other |
|
282 | + * options like enabling recursion into subfolders. |
|
283 | + * |
|
284 | + * @return string[] |
|
285 | + */ |
|
286 | 286 | public function getPHPFiles() : array |
287 | 287 | { |
288 | 288 | $this->includeExtensions(array('php')); |
289 | 289 | return $this->getAll(); |
290 | 290 | } |
291 | 291 | |
292 | - /** |
|
293 | - * Generates PHP class names from file paths: it replaces |
|
294 | - * slashes with underscores, and removes file extensions. |
|
295 | - * |
|
296 | - * @return string[] An array of PHP file names without extension. |
|
297 | - */ |
|
292 | + /** |
|
293 | + * Generates PHP class names from file paths: it replaces |
|
294 | + * slashes with underscores, and removes file extensions. |
|
295 | + * |
|
296 | + * @return string[] An array of PHP file names without extension. |
|
297 | + */ |
|
298 | 298 | public function getPHPClassNames() : array |
299 | 299 | { |
300 | 300 | $this->includeExtensions(array('php')); |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | return $path; |
366 | 366 | } |
367 | 367 | |
368 | - /** |
|
369 | - * Checks whether the specified extension is allowed |
|
370 | - * with the current settings. |
|
371 | - * |
|
372 | - * @param string $extension |
|
373 | - * @return bool |
|
374 | - */ |
|
368 | + /** |
|
369 | + * Checks whether the specified extension is allowed |
|
370 | + * with the current settings. |
|
371 | + * |
|
372 | + * @param string $extension |
|
373 | + * @return bool |
|
374 | + */ |
|
375 | 375 | protected function filterExclusion(string $extension) : bool |
376 | 376 | { |
377 | 377 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
@@ -393,12 +393,12 @@ discard block |
||
393 | 393 | return true; |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Adjusts the path according to the selected path mode. |
|
398 | - * |
|
399 | - * @param string $path |
|
400 | - * @return string |
|
401 | - */ |
|
396 | + /** |
|
397 | + * Adjusts the path according to the selected path mode. |
|
398 | + * |
|
399 | + * @param string $path |
|
400 | + * @return string |
|
401 | + */ |
|
402 | 402 | protected function filterPath(string $path) : string |
403 | 403 | { |
404 | 404 | switch($this->getStringOption(self::OPTION_PATHMODE)) |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see FileHelper_FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils; |
13 | 13 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $real = realpath($path); |
60 | 60 | |
61 | - if($real === false) |
|
61 | + if ($real === false) |
|
62 | 62 | { |
63 | 63 | throw new FileHelper_Exception( |
64 | 64 | 'Target path does not exist', |
@@ -305,22 +305,22 @@ discard block |
||
305 | 305 | return $this->getAll(); |
306 | 306 | } |
307 | 307 | |
308 | - protected function find(string $path, bool $isRoot=false) : void |
|
308 | + protected function find(string $path, bool $isRoot = false) : void |
|
309 | 309 | { |
310 | - if($isRoot) { |
|
310 | + if ($isRoot) { |
|
311 | 311 | $this->found = array(); |
312 | 312 | } |
313 | 313 | |
314 | 314 | $recursive = $this->getBoolOption('recursive'); |
315 | 315 | |
316 | 316 | $d = new \DirectoryIterator($path); |
317 | - foreach($d as $item) |
|
317 | + foreach ($d as $item) |
|
318 | 318 | { |
319 | 319 | $pathname = $item->getPathname(); |
320 | 320 | |
321 | - if($item->isDir()) |
|
321 | + if ($item->isDir()) |
|
322 | 322 | { |
323 | - if($recursive && !$item->isDot()) { |
|
323 | + if ($recursive && !$item->isDot()) { |
|
324 | 324 | $this->find($pathname); |
325 | 325 | } |
326 | 326 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $file = $this->filterFile($pathname); |
331 | 331 | |
332 | - if($file !== null) |
|
332 | + if ($file !== null) |
|
333 | 333 | { |
334 | 334 | $this->found[] = $file; |
335 | 335 | } |
@@ -342,23 +342,23 @@ discard block |
||
342 | 342 | |
343 | 343 | $extension = FileHelper::getExtension($path); |
344 | 344 | |
345 | - if(!$this->filterExclusion($extension)) { |
|
345 | + if (!$this->filterExclusion($extension)) { |
|
346 | 346 | return null; |
347 | 347 | } |
348 | 348 | |
349 | 349 | $path = $this->filterPath($path); |
350 | 350 | |
351 | - if($this->getOption('strip-extensions') === true) |
|
351 | + if ($this->getOption('strip-extensions') === true) |
|
352 | 352 | { |
353 | 353 | $path = str_replace('.'.$extension, '', $path); |
354 | 354 | } |
355 | 355 | |
356 | - if($path === '') { |
|
356 | + if ($path === '') { |
|
357 | 357 | return null; |
358 | 358 | } |
359 | 359 | |
360 | 360 | $replace = $this->getOption('slash-replacement'); |
361 | - if(!empty($replace)) { |
|
361 | + if (!empty($replace)) { |
|
362 | 362 | $path = str_replace('/', $replace, $path); |
363 | 363 | } |
364 | 364 | |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
378 | 378 | $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS); |
379 | 379 | |
380 | - if(!empty($include)) |
|
380 | + if (!empty($include)) |
|
381 | 381 | { |
382 | - if(!in_array($extension, $include)) { |
|
382 | + if (!in_array($extension, $include)) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | } |
386 | - else if(!empty($exclude)) |
|
386 | + else if (!empty($exclude)) |
|
387 | 387 | { |
388 | - if(in_array($extension, $exclude)) { |
|
388 | + if (in_array($extension, $exclude)) { |
|
389 | 389 | return false; |
390 | 390 | } |
391 | 391 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function filterPath(string $path) : string |
403 | 403 | { |
404 | - switch($this->getStringOption(self::OPTION_PATHMODE)) |
|
404 | + switch ($this->getStringOption(self::OPTION_PATHMODE)) |
|
405 | 405 | { |
406 | 406 | case self::PATH_MODE_STRIP: |
407 | 407 | return basename($path); |
@@ -23,44 +23,44 @@ |
||
23 | 23 | */ |
24 | 24 | class Request_URLComparer |
25 | 25 | { |
26 | - /** |
|
27 | - * @var Request |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var Request |
|
28 | + */ |
|
29 | 29 | protected $request; |
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | 34 | protected $sourceURL; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | 39 | protected $targetURL; |
40 | 40 | |
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | 44 | protected $limitParams = array(); |
45 | 45 | |
46 | - /** |
|
47 | - * @var bool |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var bool |
|
48 | + */ |
|
49 | 49 | protected $isMatch = false; |
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | 54 | protected $ignoreFragment = true; |
55 | 55 | |
56 | - /** |
|
57 | - * @var URLInfo |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var URLInfo |
|
58 | + */ |
|
59 | 59 | protected $sourceInfo; |
60 | 60 | |
61 | - /** |
|
62 | - * @var URLInfo |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var URLInfo |
|
63 | + */ |
|
64 | 64 | protected $targetInfo; |
65 | 65 | |
66 | 66 | public function __construct(Request $request, string $sourceURL, string $targetURL) |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | public function addLimitParam(string $name) : Request_URLComparer |
81 | 81 | { |
82 | - if(!in_array($name, $this->limitParams)) { |
|
82 | + if (!in_array($name, $this->limitParams)) { |
|
83 | 83 | $this->limitParams[] = $name; |
84 | 84 | } |
85 | 85 | |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | |
89 | 89 | public function addLimitParams(array $names) : Request_URLComparer |
90 | 90 | { |
91 | - foreach($names as $name) { |
|
91 | + foreach ($names as $name) { |
|
92 | 92 | $this->addLimitParam($name); |
93 | 93 | } |
94 | 94 | |
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
98 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
99 | 99 | { |
100 | 100 | $this->ignoreFragment = $ignore; |
101 | 101 | return $this; |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | 'query' |
122 | 122 | ); |
123 | 123 | |
124 | - if(!$this->ignoreFragment) { |
|
124 | + if (!$this->ignoreFragment) { |
|
125 | 125 | $keys[] = 'fragment'; |
126 | 126 | } |
127 | 127 | |
128 | - foreach($keys as $key) |
|
128 | + foreach ($keys as $key) |
|
129 | 129 | { |
130 | - if(!$this->compareKey($key)) { |
|
130 | + if (!$this->compareKey($key)) { |
|
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $filter = 'filter_'.$key; |
144 | 144 | |
145 | - if(method_exists($this, $filter)) |
|
145 | + if (method_exists($this, $filter)) |
|
146 | 146 | { |
147 | 147 | $sVal = $this->$filter($sVal); |
148 | 148 | $tVal = $this->$filter($tVal); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | protected function filter_path(string $path) : string |
155 | 155 | { |
156 | 156 | // fix double slashes in URLs |
157 | - while(stristr($path, '//')) { |
|
157 | + while (stristr($path, '//')) { |
|
158 | 158 | $path = str_replace('//', '/', $path); |
159 | 159 | } |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | protected function filter_query(string $query) : string |
165 | 165 | { |
166 | - if(empty($query)) { |
|
166 | + if (empty($query)) { |
|
167 | 167 | return ''; |
168 | 168 | } |
169 | 169 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | |
179 | 179 | protected function limitParams(array $params) : array |
180 | 180 | { |
181 | - if(empty($this->limitParams)) { |
|
181 | + if (empty($this->limitParams)) { |
|
182 | 182 | return $params; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $keep = array(); |
186 | 186 | |
187 | - foreach($this->limitParams as $name) |
|
187 | + foreach ($this->limitParams as $name) |
|
188 | 188 | { |
189 | - if(isset($params[$name])) { |
|
189 | + if (isset($params[$name])) { |
|
190 | 190 | $keep[$name] = $params[$name]; |
191 | 191 | } |
192 | 192 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | |
143 | 143 | protected function getInfoKey(string $name) : string |
144 | 144 | { |
145 | - if(isset($this->info[$name])) { |
|
145 | + if (isset($this->info[$name])) { |
|
146 | 146 | return (string)$this->info[$name]; |
147 | 147 | } |
148 | 148 |
@@ -19,51 +19,51 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class RequestHelper_Response |
21 | 21 | { |
22 | - /** |
|
23 | - * @var RequestHelper |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var RequestHelper |
|
24 | + */ |
|
25 | 25 | protected $request; |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | protected $body = ''; |
31 | 31 | |
32 | - /** |
|
33 | - * @var array |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var array |
|
34 | + */ |
|
35 | 35 | protected $info; |
36 | 36 | |
37 | - /** |
|
38 | - * @var bool |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | 40 | protected $isError = false; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $errorMessage = ''; |
46 | 46 | |
47 | - /** |
|
48 | - * @var integer |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var integer |
|
49 | + */ |
|
50 | 50 | protected $errorCode = 0; |
51 | 51 | |
52 | - /** |
|
53 | - * @param RequestHelper $helper |
|
54 | - * @param array $info The CURL info array from curl_getinfo(). |
|
55 | - */ |
|
52 | + /** |
|
53 | + * @param RequestHelper $helper |
|
54 | + * @param array $info The CURL info array from curl_getinfo(). |
|
55 | + */ |
|
56 | 56 | public function __construct(RequestHelper $helper, array $info) |
57 | 57 | { |
58 | 58 | $this->request = $helper; |
59 | 59 | $this->info = $info; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Retrieves the request instance that initiated the request. |
|
64 | - * |
|
65 | - * @return RequestHelper |
|
66 | - */ |
|
62 | + /** |
|
63 | + * Retrieves the request instance that initiated the request. |
|
64 | + * |
|
65 | + * @return RequestHelper |
|
66 | + */ |
|
67 | 67 | public function getRequest() : RequestHelper |
68 | 68 | { |
69 | 69 | return $this->request; |
@@ -84,79 +84,79 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Whether an error occurred in the request. |
|
89 | - * @return bool |
|
90 | - */ |
|
87 | + /** |
|
88 | + * Whether an error occurred in the request. |
|
89 | + * @return bool |
|
90 | + */ |
|
91 | 91 | public function isError() : bool |
92 | 92 | { |
93 | 93 | return $this->isError; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether the request timed out. |
|
98 | - * @return bool |
|
99 | - */ |
|
96 | + /** |
|
97 | + * Whether the request timed out. |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function isTimeout() : bool |
101 | 101 | { |
102 | 102 | return $this->errorCode === RequestHelper_CURL::OPERATION_TIMEDOUT; |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Retrieves the native error message, if an error occurred. |
|
107 | - * @return string |
|
108 | - */ |
|
105 | + /** |
|
106 | + * Retrieves the native error message, if an error occurred. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public function getErrorMessage() : string |
110 | 110 | { |
111 | 111 | return $this->errorMessage; |
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Retrieves the native CURL error code, if an error occurred. |
|
116 | - * @return int |
|
117 | - * @see RequestHelper_CURL For a list of error codes. |
|
118 | - */ |
|
114 | + /** |
|
115 | + * Retrieves the native CURL error code, if an error occurred. |
|
116 | + * @return int |
|
117 | + * @see RequestHelper_CURL For a list of error codes. |
|
118 | + */ |
|
119 | 119 | public function getErrorCode() : int |
120 | 120 | { |
121 | 121 | return $this->errorCode; |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Retrieves the full body of the request. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Retrieves the full body of the request. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | public function getRequestBody() : string |
130 | 130 | { |
131 | 131 | return $this->request->getBody(); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Retrieves the body of the response, if any. |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
134 | + /** |
|
135 | + * Retrieves the body of the response, if any. |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | 139 | public function getResponseBody() : string |
140 | 140 | { |
141 | 141 | return $this->body; |
142 | 142 | } |
143 | 143 | |
144 | - /** |
|
145 | - * The response HTTP code. |
|
146 | - * |
|
147 | - * @return int The code, or 0 if none was sent (on error). |
|
148 | - */ |
|
144 | + /** |
|
145 | + * The response HTTP code. |
|
146 | + * |
|
147 | + * @return int The code, or 0 if none was sent (on error). |
|
148 | + */ |
|
149 | 149 | public function getCode() : int |
150 | 150 | { |
151 | 151 | return intval($this->getInfoKey('http_code')); |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Retrieves the actual headers that were sent in the request: |
|
156 | - * one header by entry in the indexed array. |
|
157 | - * |
|
158 | - * @return array |
|
159 | - */ |
|
154 | + /** |
|
155 | + * Retrieves the actual headers that were sent in the request: |
|
156 | + * one header by entry in the indexed array. |
|
157 | + * |
|
158 | + * @return array |
|
159 | + */ |
|
160 | 160 | public function getHeaders() : array |
161 | 161 | { |
162 | 162 | return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header')); |
@@ -32,23 +32,23 @@ |
||
32 | 32 | $this->info = $info; |
33 | 33 | } |
34 | 34 | |
35 | - /** |
|
36 | - * Enables the authentication information in the URL, |
|
37 | - * if a username and password are present. |
|
38 | - * |
|
39 | - * @param bool $enable Whether to turn it on or off. |
|
40 | - * @return URLInfo_Normalizer |
|
41 | - */ |
|
35 | + /** |
|
36 | + * Enables the authentication information in the URL, |
|
37 | + * if a username and password are present. |
|
38 | + * |
|
39 | + * @param bool $enable Whether to turn it on or off. |
|
40 | + * @return URLInfo_Normalizer |
|
41 | + */ |
|
42 | 42 | public function enableAuth(bool $enable=true) : URLInfo_Normalizer |
43 | 43 | { |
44 | 44 | $this->auth = $enable; |
45 | 45 | return $this; |
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * Retrieves the normalized URL. |
|
50 | - * @return string |
|
51 | - */ |
|
48 | + /** |
|
49 | + * Retrieves the normalized URL. |
|
50 | + * @return string |
|
51 | + */ |
|
52 | 52 | public function normalize() : string |
53 | 53 | { |
54 | 54 | $method = 'normalize_'.$this->info->getType(); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param bool $enable Whether to turn it on or off. |
40 | 40 | * @return URLInfo_Normalizer |
41 | 41 | */ |
42 | - public function enableAuth(bool $enable=true) : URLInfo_Normalizer |
|
42 | + public function enableAuth(bool $enable = true) : URLInfo_Normalizer |
|
43 | 43 | { |
44 | 44 | $this->auth = $enable; |
45 | 45 | return $this; |
@@ -86,48 +86,48 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function renderAuth(string $normalized) : string |
88 | 88 | { |
89 | - if(!$this->info->hasUsername() || !$this->auth) { |
|
89 | + if (!$this->info->hasUsername() || !$this->auth) { |
|
90 | 90 | return $normalized; |
91 | 91 | } |
92 | 92 | |
93 | - return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
93 | + return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | protected function renderPort(string $normalized) : string |
97 | 97 | { |
98 | - if(!$this->info->hasPort()) { |
|
98 | + if (!$this->info->hasPort()) { |
|
99 | 99 | return $normalized; |
100 | 100 | } |
101 | 101 | |
102 | - return $normalized . ':'.$this->info->getPort(); |
|
102 | + return $normalized.':'.$this->info->getPort(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | protected function renderPath(string $normalized) : string |
106 | 106 | { |
107 | - if(!$this->info->hasPath()) { |
|
107 | + if (!$this->info->hasPath()) { |
|
108 | 108 | return $normalized; |
109 | 109 | } |
110 | 110 | |
111 | - return $normalized . $this->info->getPath(); |
|
111 | + return $normalized.$this->info->getPath(); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | protected function renderParams(string $normalized) : string |
115 | 115 | { |
116 | 116 | $params = $this->info->getParams(); |
117 | 117 | |
118 | - if(empty($params)) { |
|
118 | + if (empty($params)) { |
|
119 | 119 | return $normalized; |
120 | 120 | } |
121 | 121 | |
122 | - return $normalized . '?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
122 | + return $normalized.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function renderFragment(string $normalized) : string |
126 | 126 | { |
127 | - if(!$this->info->hasFragment()) { |
|
127 | + if (!$this->info->hasFragment()) { |
|
128 | 128 | return $normalized; |
129 | 129 | } |
130 | 130 | |
131 | - return $normalized . '#'.$this->info->getFragment(); |
|
131 | + return $normalized.'#'.$this->info->getFragment(); |
|
132 | 132 | } |
133 | 133 | } |