@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | public function toString() : string |
20 | 20 | { |
21 | 21 | return |
22 | - $this->renderMessage() . |
|
23 | - $this->renderCalls() . |
|
22 | + $this->renderMessage(). |
|
23 | + $this->renderCalls(). |
|
24 | 24 | $this->renderPrevious(); |
25 | 25 | } |
26 | 26 | |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | |
34 | 34 | if ($this->info->hasCode()) |
35 | 35 | { |
36 | - $string .= ' #' . $this->info->getCode(); |
|
36 | + $string .= ' #'.$this->info->getCode(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $string .= |
40 | - ': ' . |
|
41 | - $this->info->getMessage() . |
|
40 | + ': '. |
|
41 | + $this->info->getMessage(). |
|
42 | 42 | PHP_EOL; |
43 | 43 | |
44 | 44 | return $string; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | foreach ($calls as $call) |
57 | 57 | { |
58 | - $string .= $call->toString() . PHP_EOL; |
|
58 | + $string .= $call->toString().PHP_EOL; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $string; |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | return |
76 | - PHP_EOL . |
|
77 | - PHP_EOL . |
|
78 | - 'Previous error:' . |
|
79 | - PHP_EOL . |
|
80 | - PHP_EOL . |
|
76 | + PHP_EOL. |
|
77 | + PHP_EOL. |
|
78 | + 'Previous error:'. |
|
79 | + PHP_EOL. |
|
80 | + PHP_EOL. |
|
81 | 81 | $this->info->getPrevious()->toString(); |
82 | 82 | } |
83 | 83 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
34 | 34 | |
35 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
35 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
36 | 36 | |
37 | 37 | protected $options = array( |
38 | 38 | 'WriteThreshold' => 100 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
84 | 84 | */ |
85 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
85 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
86 | 86 | { |
87 | 87 | $this->open(); |
88 | 88 | |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function open() : void |
137 | 137 | { |
138 | - if($this->open) { |
|
138 | + if ($this->open) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | - if(!isset($this->zip)) { |
|
142 | + if (!isset($this->zip)) { |
|
143 | 143 | $this->zip = new ZipArchive(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | $flag = null; |
147 | - if(!file_exists($this->file)) { |
|
147 | + if (!file_exists($this->file)) { |
|
148 | 148 | $flag = ZipArchive::CREATE; |
149 | 149 | } |
150 | 150 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | $this->fileTracker++; |
189 | 189 | |
190 | - if($this->options['WriteThreshold'] < 1) { |
|
190 | + if ($this->options['WriteThreshold'] < 1) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | protected function close() : void |
202 | 202 | { |
203 | - if(!$this->open) { |
|
203 | + if (!$this->open) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | throw new ZIPHelper_Exception( |
210 | 210 | 'Could not save ZIP file to disk', |
211 | 211 | sprintf( |
212 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
213 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
212 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
213 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
214 | 214 | 'or trying to save to a directory that does not exist.', |
215 | 215 | $this->file |
216 | 216 | ), |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | $this->open(); |
227 | 227 | |
228 | - if($this->countFiles() < 1) |
|
228 | + if ($this->countFiles() < 1) |
|
229 | 229 | { |
230 | 230 | throw new ZIPHelper_Exception( |
231 | 231 | 'No files in the zip file', |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | * @throws ZIPHelper_Exception |
252 | 252 | * @return string The file name that was sent (useful in case none was specified). |
253 | 253 | */ |
254 | - public function download(?string $fileName=null) : string |
|
254 | + public function download(?string $fileName = null) : string |
|
255 | 255 | { |
256 | 256 | $this->save(); |
257 | 257 | |
258 | - if(empty($fileName)) |
|
258 | + if (empty($fileName)) |
|
259 | 259 | { |
260 | 260 | $fileName = basename($this->file); |
261 | 261 | } |
262 | 262 | |
263 | 263 | header('Content-type: application/zip'); |
264 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
265 | - header('Content-length: ' . filesize($this->file)); |
|
264 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
265 | + header('Content-length: '.filesize($this->file)); |
|
266 | 266 | header('Pragma: no-cache'); |
267 | 267 | header('Expires: 0'); |
268 | 268 | readfile($this->file); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @throws ZIPHelper_Exception |
281 | 281 | * @see ZIPHelper::download() |
282 | 282 | */ |
283 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
283 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
284 | 284 | { |
285 | 285 | $this->download($fileName); |
286 | 286 | |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
298 | 298 | * @return boolean |
299 | 299 | */ |
300 | - public function extractAll(?string $outputFolder=null) : bool |
|
300 | + public function extractAll(?string $outputFolder = null) : bool |
|
301 | 301 | { |
302 | - if(empty($outputFolder)) { |
|
302 | + if (empty($outputFolder)) { |
|
303 | 303 | $outputFolder = dirname($this->file); |
304 | 304 | } |
305 | 305 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param bool $lowercase |
62 | 62 | * @return Transliteration |
63 | 63 | */ |
64 | - public function setLowercase(bool $lowercase=true) : Transliteration |
|
64 | + public function setLowercase(bool $lowercase = true) : Transliteration |
|
65 | 65 | { |
66 | 66 | $this->setOption(self::OPTION_LOWER_CASE, $lowercase); |
67 | 67 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | $result = implode('', $keep); |
101 | 101 | |
102 | - while (strpos($result, $space . $space) !== false) { |
|
103 | - $result = str_replace($space . $space, $space, $result); |
|
102 | + while (strpos($result, $space.$space) !== false) { |
|
103 | + $result = str_replace($space.$space, $space, $result); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $result = trim($result, $space); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|number|StringBuilder_Interface|NULL $content |
30 | 30 | * @return HTMLTag |
31 | 31 | */ |
32 | - public static function anchor(string $url, $content=null) : HTMLTag |
|
32 | + public static function anchor(string $url, $content = null) : HTMLTag |
|
33 | 33 | { |
34 | 34 | return HTMLTag::create('a') |
35 | 35 | ->href($url) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string|number|StringBuilder_Interface|NULL $content |
47 | 47 | * @return HTMLTag |
48 | 48 | */ |
49 | - public static function div($content=null) : HTMLTag |
|
49 | + public static function div($content = null) : HTMLTag |
|
50 | 50 | { |
51 | 51 | return HTMLTag::create('div')->setContent($content); |
52 | 52 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string|number|StringBuilder_Interface|NULL $content |
56 | 56 | * @return HTMLTag |
57 | 57 | */ |
58 | - public static function p($content=null) : HTMLTag |
|
58 | + public static function p($content = null) : HTMLTag |
|
59 | 59 | { |
60 | 60 | return HTMLTag::create('p')->setContent($content); |
61 | 61 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct() |
38 | 38 | { |
39 | - if(class_exists('\AppLocalize\Localization')) { |
|
39 | + if (class_exists('\AppLocalize\Localization')) { |
|
40 | 40 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
41 | 41 | } |
42 | 42 | } |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | $keep = $this->resolveTokens($interval); |
70 | 70 | |
71 | 71 | $parts = array(); |
72 | - foreach($keep as $token) |
|
72 | + foreach ($keep as $token) |
|
73 | 73 | { |
74 | 74 | $value = $interval->getToken($token); |
75 | - if($value <= 0) { |
|
75 | + if ($value <= 0) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $parts[] = $this->translateToken($token, $interval); |
80 | 80 | } |
81 | 81 | |
82 | - if(count($parts) == 1) { |
|
82 | + if (count($parts) == 1) { |
|
83 | 83 | return $parts[0]; |
84 | 84 | } |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $value = $interval->getToken($token); |
102 | 102 | |
103 | 103 | $suffix = 'p'; |
104 | - if($value == 1) { $suffix = 's'; } |
|
104 | + if ($value == 1) { $suffix = 's'; } |
|
105 | 105 | $token .= $suffix; |
106 | 106 | |
107 | - if(!isset(self::$texts[$token])) |
|
107 | + if (!isset(self::$texts[$token])) |
|
108 | 108 | { |
109 | 109 | throw new ConvertHelper_Exception( |
110 | 110 | 'Missing interval translation', |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $offset = 0; |
136 | 136 | |
137 | - foreach($this->tokens as $token) |
|
137 | + foreach ($this->tokens as $token) |
|
138 | 138 | { |
139 | - if($interval->getToken($token) > 0) |
|
139 | + if ($interval->getToken($token) > 0) |
|
140 | 140 | { |
141 | 141 | return array_slice($this->tokens, $offset); |
142 | 142 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function initTexts() : void |
154 | 154 | { |
155 | - if(isset(self::$texts)) { |
|
155 | + if (isset(self::$texts)) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $this->path = realpath($path); |
55 | 55 | |
56 | - if($this->path === false) |
|
56 | + if ($this->path === false) |
|
57 | 57 | { |
58 | 58 | throw new FileHelper_Exception( |
59 | 59 | 'Cannot extract file information: file not found.', |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | |
132 | 132 | $result = array(); |
133 | 133 | preg_match_all('/namespace[\s]+([^;]+);/six', $code, $result, PREG_PATTERN_ORDER); |
134 | - if(isset($result[0]) && isset($result[0][0])) { |
|
134 | + if (isset($result[0]) && isset($result[0][0])) { |
|
135 | 135 | $this->namespace = trim($result[1][0]); |
136 | 136 | } |
137 | 137 | |
138 | 138 | $result = array(); |
139 | 139 | preg_match_all('/(abstract|final)[\s]+(class|trait)[\s]+([\sa-z0-9\\\\_,]+){|(class|trait)[\s]+([\sa-z0-9\\\\_,]+){/six', $code, $result, PREG_PATTERN_ORDER); |
140 | 140 | |
141 | - if(!isset($result[0]) || !isset($result[0][0])) { |
|
141 | + if (!isset($result[0]) || !isset($result[0][0])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $indexes = array_keys($result[0]); |
146 | 146 | |
147 | - foreach($indexes as $idx) |
|
147 | + foreach ($indexes as $idx) |
|
148 | 148 | { |
149 | 149 | $keyword = $result[1][$idx]; |
150 | 150 | $declaration = $result[3][$idx]; |
151 | 151 | $type = $result[2][$idx]; |
152 | - if(empty($keyword)) { |
|
152 | + if (empty($keyword)) { |
|
153 | 153 | $type = $result[4][$idx]; |
154 | 154 | $declaration = $result[5][$idx]; |
155 | 155 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $name = $this->getName(); |
113 | 113 | |
114 | - if($this->info->hasNamespace()) { |
|
114 | + if ($this->info->hasNamespace()) { |
|
115 | 115 | $name = $this->info->getNamespace().'\\'.$this->name; |
116 | 116 | } |
117 | 117 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $parts[] = $this->type; |
167 | 167 | $parts[] = $this->getName(); |
168 | 168 | |
169 | - if(!empty($this->extends)) { |
|
169 | + if (!empty($this->extends)) { |
|
170 | 170 | $parts[] = 'extends'; |
171 | 171 | $parts[] = $this->extends; |
172 | 172 | } |
173 | 173 | |
174 | - if(!empty($this->implements)) { |
|
174 | + if (!empty($this->implements)) { |
|
175 | 175 | $parts[] = 'implements'; |
176 | 176 | $parts[] = implode(', ', $this->implements); |
177 | 177 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | |
196 | 196 | protected function analyzeCode() : void |
197 | 197 | { |
198 | - if($this->keyword === 'abstract') { |
|
198 | + if ($this->keyword === 'abstract') { |
|
199 | 199 | $this->abstract = true; |
200 | - } else if($this->keyword === 'final') { |
|
200 | + } else if ($this->keyword === 'final') { |
|
201 | 201 | $this->final = true; |
202 | 202 | } |
203 | 203 | |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | |
215 | 215 | $tokenName = 'none'; |
216 | 216 | |
217 | - foreach($parts as $part) |
|
217 | + foreach ($parts as $part) |
|
218 | 218 | { |
219 | 219 | $part = str_replace(',', '', $part); |
220 | 220 | $part = trim($part); |
221 | - if(empty($part)) { |
|
221 | + if (empty($part)) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $name = strtolower($part); |
226 | - if($name === 'extends' || $name === 'implements') { |
|
226 | + if ($name === 'extends' || $name === 'implements') { |
|
227 | 227 | $tokenName = $name; |
228 | 228 | continue; |
229 | 229 | } |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | |
234 | 234 | $this->implements = $tokens['implements']; |
235 | 235 | |
236 | - if(!empty($this->implements)) { |
|
236 | + if (!empty($this->implements)) { |
|
237 | 237 | usort($this->implements, function(string $a, string $b) { |
238 | 238 | return strnatcasecmp($a, $b); |
239 | 239 | }); |
240 | 240 | } |
241 | 241 | |
242 | - if(!empty($tokens['extends'])) { |
|
242 | + if (!empty($tokens['extends'])) { |
|
243 | 243 | $this->extends = $tokens['extends'][0]; |
244 | 244 | } |
245 | 245 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
35 | 35 | */ |
36 | - public function __construct(array $styles=array()) |
|
36 | + public function __construct(array $styles = array()) |
|
37 | 37 | { |
38 | 38 | $this->options = new StyleOptions(); |
39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
45 | 45 | * @return StyleCollection |
46 | 46 | */ |
47 | - public static function create(array $styles=array()) : StyleCollection |
|
47 | + public static function create(array $styles = array()) : StyleCollection |
|
48 | 48 | { |
49 | 49 | return new StyleCollection($styles); |
50 | 50 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $lines = explode(';', $string); |
70 | 70 | |
71 | - foreach($lines as $line) |
|
71 | + foreach ($lines as $line) |
|
72 | 72 | { |
73 | 73 | $parts = explode(':', $line); |
74 | 74 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setStyles(array $styles) : StyleCollection |
91 | 91 | { |
92 | - foreach($styles as $name => $value) |
|
92 | + foreach ($styles as $name => $value) |
|
93 | 93 | { |
94 | 94 | $this->styleAuto($name, $value); |
95 | 95 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * @param bool $important |
106 | 106 | * @return $this |
107 | 107 | */ |
108 | - public function style(string $name, string $value, bool $important=false) : StyleCollection |
|
108 | + public function style(string $name, string $value, bool $important = false) : StyleCollection |
|
109 | 109 | { |
110 | - if($value === '') |
|
110 | + if ($value === '') |
|
111 | 111 | { |
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - if($important && stripos($value, '!important') === false) |
|
115 | + if ($important && stripos($value, '!important') === false) |
|
116 | 116 | { |
117 | 117 | $value .= ' !important'; |
118 | 118 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param bool $important |
131 | 131 | * @return $this |
132 | 132 | */ |
133 | - public function styleAuto(string $name, $value, bool $important=false) : StyleCollection |
|
133 | + public function styleAuto(string $name, $value, bool $important = false) : StyleCollection |
|
134 | 134 | { |
135 | - if($value instanceof NumberInfo) |
|
135 | + if ($value instanceof NumberInfo) |
|
136 | 136 | { |
137 | 137 | return $this->style($name, $value->toCSS(), $important); |
138 | 138 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | return $this->style($name, (string)$value, $important); |
141 | 141 | } |
142 | 142 | |
143 | - public function stylePX(string $name, int $px, bool $important=false) : StyleCollection |
|
143 | + public function stylePX(string $name, int $px, bool $important = false) : StyleCollection |
|
144 | 144 | { |
145 | 145 | return $this->style($name, $px.'px', $important); |
146 | 146 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param bool $important |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function styleParseNumber(string $name, $value, bool $important=false) : StyleCollection |
|
172 | + public function styleParseNumber(string $name, $value, bool $important = false) : StyleCollection |
|
173 | 173 | { |
174 | 174 | return $this->styleNumber($name, parseNumber($value), $important); |
175 | 175 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param bool $important |
183 | 183 | * @return $this |
184 | 184 | */ |
185 | - public function styleNumber(string $name, NumberInfo $info, bool $important=false) : StyleCollection |
|
185 | + public function styleNumber(string $name, NumberInfo $info, bool $important = false) : StyleCollection |
|
186 | 186 | { |
187 | 187 | $this->style($name, $info->toCSS(), $important); |
188 | 188 | return $this; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | public function remove(string $name) : StyleCollection |
192 | 192 | { |
193 | - if(isset($this->styles[$name])) |
|
193 | + if (isset($this->styles[$name])) |
|
194 | 194 | { |
195 | 195 | unset($this->styles[$name]); |
196 | 196 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $all = self::create(); |
228 | 228 | |
229 | - foreach($collections as $collection) |
|
229 | + foreach ($collections as $collection) |
|
230 | 230 | { |
231 | 231 | $all->mergeWith($collection); |
232 | 232 | } |
@@ -339,7 +339,7 @@ |
||
339 | 339 | */ |
340 | 340 | private function requireValidComponent(string $name) : void |
341 | 341 | { |
342 | - if(in_array($name, self::COLOR_COMPONENTS)) |
|
342 | + if (in_array($name, self::COLOR_COMPONENTS)) |
|
343 | 343 | { |
344 | 344 | return; |
345 | 345 | } |