@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | public const SVN_ERROR_TYPE_WARNING = 'warning'; |
22 | 22 | |
23 | 23 | /** |
24 | - * @var SVNHelper |
|
25 | - */ |
|
24 | + * @var SVNHelper |
|
25 | + */ |
|
26 | 26 | protected $helper; |
27 | 27 | |
28 | - /** |
|
29 | - * @var SVNHelper_Target |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var SVNHelper_Target |
|
30 | + */ |
|
31 | 31 | protected $target; |
32 | 32 | |
33 | - /** |
|
34 | - * @var SVNHelper_CommandResult|NULL |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var SVNHelper_CommandResult|NULL |
|
35 | + */ |
|
36 | 36 | protected ?SVNHelper_CommandResult $result; |
37 | 37 | |
38 | 38 | public function __construct(SVNHelper $helper, SVNHelper_Target $target) |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $this->target = $target; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * @return SVNHelper |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @return SVNHelper |
|
46 | + */ |
|
47 | 47 | public function getSVN() |
48 | 48 | { |
49 | 49 | return $this->helper; |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | return $cmd; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Executes the specified command, and returns a result |
|
105 | - * instance to read the results. |
|
106 | - * |
|
107 | - * @param string $mode The command mode, e.g. commit / update... |
|
108 | - * @param string $path The path to apply the command to |
|
109 | - * @param array $params |
|
110 | - * @return SVNHelper_CommandResult |
|
111 | - */ |
|
103 | + /** |
|
104 | + * Executes the specified command, and returns a result |
|
105 | + * instance to read the results. |
|
106 | + * |
|
107 | + * @param string $mode The command mode, e.g. commit / update... |
|
108 | + * @param string $path The path to apply the command to |
|
109 | + * @param array $params |
|
110 | + * @return SVNHelper_CommandResult |
|
111 | + */ |
|
112 | 112 | protected function execCommand($mode, $path=null, $params=array()) |
113 | 113 | { |
114 | 114 | $relative = $this->helper->relativizePath($path); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | return $this->result; |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Retrieves the type of command, e.g. "Commit" |
|
200 | - * @return string |
|
201 | - */ |
|
198 | + /** |
|
199 | + * Retrieves the type of command, e.g. "Commit" |
|
200 | + * @return string |
|
201 | + */ |
|
202 | 202 | public function getType() |
203 | 203 | { |
204 | 204 | return str_replace('SVNHelper_Command_', '', get_class($this)); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function execute() |
58 | 58 | { |
59 | - if(isset($this->result)) |
|
59 | + if (isset($this->result)) |
|
60 | 60 | { |
61 | 61 | return $this->result; |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | putenv('LC_ALL='.$locale); |
68 | 68 | |
69 | 69 | $this->result = $this->_execute(); |
70 | - if(!$this->result instanceof SVNHelper_CommandResult) { |
|
70 | + if (!$this->result instanceof SVNHelper_CommandResult) { |
|
71 | 71 | throw new SVNHelper_Exception( |
72 | 72 | 'Not a valid SVN command result', |
73 | 73 | sprintf( |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | abstract protected function _execute(); |
85 | 85 | |
86 | - protected function buildCommand($mode, $path=null, $params=array()) |
|
86 | + protected function buildCommand($mode, $path = null, $params = array()) |
|
87 | 87 | { |
88 | 88 | $params[] = 'non-interactive'; |
89 | 89 | $params[] = 'username '.$this->helper->getAuthUser(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $cmd = 'svn '.$mode.' '.$path.' '; |
93 | 93 | |
94 | - foreach($params as $param) { |
|
94 | + foreach ($params as $param) { |
|
95 | 95 | $cmd .= '--'.$param.' '; |
96 | 96 | } |
97 | 97 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $params |
110 | 110 | * @return SVNHelper_CommandResult |
111 | 111 | */ |
112 | - protected function execCommand($mode, $path=null, $params=array()) |
|
112 | + protected function execCommand($mode, $path = null, $params = array()) |
|
113 | 113 | { |
114 | 114 | $relative = $this->helper->relativizePath($path); |
115 | 115 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | exec($cmd, $output); |
125 | 125 | |
126 | 126 | $lines = array(); |
127 | - foreach($output as $line) { |
|
127 | + foreach ($output as $line) { |
|
128 | 128 | $lines[] = mb_strtolower(trim(utf8_encode($line))); |
129 | 129 | } |
130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | // |
137 | 137 | // Can happen for example when the path is not under version |
138 | 138 | // control. |
139 | - if(isset($lines[0]) && substr($lines[0], 0, 7) == 'skipped') |
|
139 | + if (isset($lines[0]) && substr($lines[0], 0, 7) == 'skipped') |
|
140 | 140 | { |
141 | 141 | $tokens = explode('--', $lines[0]); |
142 | 142 | $message = trim(array_pop($tokens)); |
@@ -157,20 +157,20 @@ discard block |
||
157 | 157 | // svn: w123456: warning message |
158 | 158 | else |
159 | 159 | { |
160 | - foreach($lines as $line) |
|
160 | + foreach ($lines as $line) |
|
161 | 161 | { |
162 | - if(strstr($line, 'svn:')) |
|
162 | + if (strstr($line, 'svn:')) |
|
163 | 163 | { |
164 | 164 | $result = array(); |
165 | 165 | preg_match_all('/svn:[ ]*(e|warning:[ ]*w)([0-9]+):(.*)/', $line, $result, PREG_PATTERN_ORDER); |
166 | 166 | |
167 | - if(isset($result[1]) && isset($result[1][0])) |
|
167 | + if (isset($result[1]) && isset($result[1][0])) |
|
168 | 168 | { |
169 | 169 | $message = trim($result[3][0]); |
170 | 170 | $code = trim($result[2][0]); |
171 | 171 | $type = self::SVN_ERROR_TYPE_ERROR; |
172 | 172 | |
173 | - if($result[1][0] != 'e') { |
|
173 | + if ($result[1][0] != 'e') { |
|
174 | 174 | $type = self::SVN_ERROR_TYPE_WARNING; |
175 | 175 | } |
176 | 176 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $result = new SVNHelper_CommandResult($this, $cmd, $lines, $errorMessages); |
185 | 185 | |
186 | - if($result->isError()) { |
|
186 | + if ($result->isError()) { |
|
187 | 187 | $this->log(sprintf('[%s] | Command returned errors.', $relative)); |
188 | 188 | } |
189 | 189 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | protected function throwExceptionUnexpected(SVNHelper_CommandResult $result) |
208 | 208 | { |
209 | - if($result->isConnectionFailed()) { |
|
209 | + if ($result->isConnectionFailed()) { |
|
210 | 210 | $this->throwException( |
211 | 211 | t('Could not connect to the remote SVN repository'), |
212 | 212 | '', |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ); |
216 | 216 | } |
217 | 217 | |
218 | - if($result->hasConflicts()) { |
|
218 | + if ($result->hasConflicts()) { |
|
219 | 219 | $this->throwException( |
220 | 220 | t('SVN command reported conflicts'), |
221 | 221 | '', |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ); |
225 | 225 | } |
226 | 226 | |
227 | - if($result->hasLocks()) { |
|
227 | + if ($result->hasLocks()) { |
|
228 | 228 | $this->throwException( |
229 | 229 | t('The target SVN folder or file is locked.'), |
230 | 230 | '', |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | ); |
242 | 242 | } |
243 | 243 | |
244 | - protected function throwException($message, $details, $code, SVNHelper_CommandResult $result, $previous=null) |
|
244 | + protected function throwException($message, $details, $code, SVNHelper_CommandResult $result, $previous = null) |
|
245 | 245 | { |
246 | 246 | $body = |
247 | 247 | '<p>'. |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | '</p>'. |
257 | 257 | '<ul>'; |
258 | 258 | $errors = $result->getErrorMessages(); |
259 | - foreach($errors as $error) { |
|
259 | + foreach ($errors as $error) { |
|
260 | 260 | $body .= |
261 | 261 | '<li>'. |
262 | 262 | $error. |
@@ -119,7 +119,7 @@ |
||
119 | 119 | public function hasAnyErrorCode(array $codes) : bool |
120 | 120 | { |
121 | 121 | $items = array(); |
122 | - foreach($codes as $code) { |
|
122 | + foreach ($codes as $code) { |
|
123 | 123 | $items[] = $this->filterCode($code); |
124 | 124 | } |
125 | 125 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct($path) |
30 | 30 | { |
31 | - if($path instanceof FolderInfo) |
|
31 | + if ($path instanceof FolderInfo) |
|
32 | 32 | { |
33 | 33 | $this->folder = $path; |
34 | 34 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - public function makeRecursive(bool $recursive=true) : self |
|
49 | + public function makeRecursive(bool $recursive = true) : self |
|
50 | 50 | { |
51 | 51 | return $this->setOption(self::OPTION_RECURSIVE, $recursive); |
52 | 52 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | $result = array(); |
78 | 78 | |
79 | - foreach($this->folders as $folder) |
|
79 | + foreach ($this->folders as $folder) |
|
80 | 80 | { |
81 | 81 | $result[] = $this->resolvePath($folder); |
82 | 82 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | private function resolvePath(FolderInfo $folder) : string |
98 | 98 | { |
99 | - if(!$this->isPathModeAbsolute()) |
|
99 | + if (!$this->isPathModeAbsolute()) |
|
100 | 100 | { |
101 | 101 | return $folder->getRelativeTo($this->folder); |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $d = new DirectoryIterator($folder->getPath()); |
119 | 119 | |
120 | - foreach($d as $item) |
|
120 | + foreach ($d as $item) |
|
121 | 121 | { |
122 | - if($item->isDir() && !$item->isDot()) |
|
122 | + if ($item->isDir() && !$item->isDot()) |
|
123 | 123 | { |
124 | 124 | $this->processFolder(FileHelper::getFolderInfo($item->getPathname())); |
125 | 125 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $this->folders[] = $folder; |
142 | 142 | |
143 | - if($this->isRecursive()) |
|
143 | + if ($this->isRecursive()) |
|
144 | 144 | { |
145 | 145 | $this->scanFolder($folder); |
146 | 146 | } |
@@ -31,8 +31,7 @@ |
||
31 | 31 | if($path instanceof FolderInfo) |
32 | 32 | { |
33 | 33 | $this->folder = $path; |
34 | - } |
|
35 | - else |
|
34 | + } else |
|
36 | 35 | { |
37 | 36 | $this->folder = FileHelper::getFolderInfo(FileHelper::getPathInfo($path)->getPath()); |
38 | 37 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $os = $this->getOS(); |
61 | 61 | |
62 | - if(isset(self::$osCommands[$os])) |
|
62 | + if (isset(self::$osCommands[$os])) |
|
63 | 63 | { |
64 | 64 | return self::$osCommands[$os]; |
65 | 65 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function exists(string $command) : bool |
85 | 85 | { |
86 | - if(isset(self::$checked[$command])) |
|
86 | + if (isset(self::$checked[$command])) |
|
87 | 87 | { |
88 | 88 | return self::$checked[$command]; |
89 | 89 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $pipes |
115 | 115 | ); |
116 | 116 | |
117 | - if($process === false) |
|
117 | + if ($process === false) |
|
118 | 118 | { |
119 | 119 | return ''; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | proc_close($process); |
128 | 128 | |
129 | - if($stdout === false) |
|
129 | + if ($stdout === false) |
|
130 | 130 | { |
131 | 131 | return ''; |
132 | 132 | } |
@@ -255,8 +255,7 @@ |
||
255 | 255 | if($this->exists()) |
256 | 256 | { |
257 | 257 | $this->requireWritable(); |
258 | - } |
|
259 | - else |
|
258 | + } else |
|
260 | 259 | { |
261 | 260 | FolderInfo::factory(dirname($this->path)) |
262 | 261 | ->create() |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function factory($path) : FileInfo |
52 | 52 | { |
53 | - if($path instanceof self) { |
|
53 | + if ($path instanceof self) { |
|
54 | 54 | return $path; |
55 | 55 | } |
56 | 56 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $pathString = AbstractPathInfo::type2string($path); |
68 | 68 | $key = $pathString.';'.static::class; |
69 | 69 | |
70 | - if(!isset(self::$infoCache[$key])) |
|
70 | + if (!isset(self::$infoCache[$key])) |
|
71 | 71 | { |
72 | 72 | $class = static::class; |
73 | 73 | $instance = new $class($pathString); |
74 | 74 | |
75 | - if(!$instance instanceof self) { |
|
75 | + if (!$instance instanceof self) { |
|
76 | 76 | throw new FileHelper_Exception( |
77 | 77 | 'Invalid class' |
78 | 78 | ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | parent::__construct($path); |
108 | 108 | |
109 | - if(!self::is_file($this->path)) |
|
109 | + if (!self::is_file($this->path)) |
|
110 | 110 | { |
111 | 111 | throw new FileHelper_Exception( |
112 | 112 | 'Not a file path', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $path = trim($path); |
122 | 122 | |
123 | - if(empty($path)) |
|
123 | + if (empty($path)) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== ''; |
129 | 129 | } |
130 | 130 | |
131 | - public function removeExtension(bool $keepPath=false) : string |
|
131 | + public function removeExtension(bool $keepPath = false) : string |
|
132 | 132 | { |
133 | - if(!$keepPath) |
|
133 | + if (!$keepPath) |
|
134 | 134 | { |
135 | 135 | return (string)pathinfo($this->getName(), PATHINFO_FILENAME); |
136 | 136 | } |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | return $this->removeExtension(); |
156 | 156 | } |
157 | 157 | |
158 | - public function getExtension(bool $lowercase=true) : string |
|
158 | + public function getExtension(bool $lowercase = true) : string |
|
159 | 159 | { |
160 | 160 | $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION); |
161 | 161 | |
162 | - if($lowercase) |
|
162 | + if ($lowercase) |
|
163 | 163 | { |
164 | 164 | $ext = mb_strtolower($ext); |
165 | 165 | } |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function delete() : FileInfo |
182 | 182 | { |
183 | - if(!$this->exists()) |
|
183 | + if (!$this->exists()) |
|
184 | 184 | { |
185 | 185 | return $this; |
186 | 186 | } |
187 | 187 | |
188 | - if(unlink($this->path)) |
|
188 | + if (unlink($this->path)) |
|
189 | 189 | { |
190 | 190 | return $this; |
191 | 191 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | { |
213 | 213 | $target = $this->checkCopyPrerequisites($targetPath); |
214 | 214 | |
215 | - if(copy($this->path, (string)$target)) |
|
215 | + if (copy($this->path, (string)$target)) |
|
216 | 216 | { |
217 | 217 | return $target; |
218 | 218 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function getLineReader() : LineReader |
266 | 266 | { |
267 | - if($this->lineReader === null) |
|
267 | + if ($this->lineReader === null) |
|
268 | 268 | { |
269 | 269 | $this->lineReader = new LineReader($this); |
270 | 270 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $result = file_get_contents($this->getPath()); |
285 | 285 | |
286 | - if($result !== false) { |
|
286 | + if ($result !== false) { |
|
287 | 287 | return $result; |
288 | 288 | } |
289 | 289 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function putContents(string $content) : FileInfo |
307 | 307 | { |
308 | - if($this->exists()) |
|
308 | + if ($this->exists()) |
|
309 | 309 | { |
310 | 310 | $this->requireWritable(); |
311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ->requireWritable(); |
317 | 317 | } |
318 | 318 | |
319 | - if(file_put_contents($this->path, $content) !== false) |
|
319 | + if (file_put_contents($this->path, $content) !== false) |
|
320 | 320 | { |
321 | 321 | return $this; |
322 | 322 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | private function createFolder() : FileInfo |
348 | 348 | { |
349 | - if(!$this->exists()) |
|
349 | + if (!$this->exists()) |
|
350 | 350 | { |
351 | 351 | FolderInfo::factory($this->getFolderPath()) |
352 | 352 | ->create() |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var array<string,string>|NULL |
29 | 29 | */ |
30 | - protected static ?array $utfBoms = null; |
|
30 | + protected static ? array $utfBoms = null; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @var string[]|NULL |
34 | 34 | */ |
35 | - protected static ?array $encodings = null; |
|
35 | + protected static ? array $encodings = null; |
|
36 | 36 | |
37 | 37 | public function __construct() |
38 | 38 | { |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | fclose($fp); |
72 | 72 | |
73 | - foreach(self::$utfBoms as $bom => $value) |
|
73 | + foreach (self::$utfBoms as $bom => $value) |
|
74 | 74 | { |
75 | - if(mb_strpos($text, $value) === 0) |
|
75 | + if (mb_strpos($text, $value) === 0) |
|
76 | 76 | { |
77 | 77 | return $bom; |
78 | 78 | } |
@@ -83,23 +83,23 @@ discard block |
||
83 | 83 | |
84 | 84 | private function initBOMs() : void |
85 | 85 | { |
86 | - if(isset(self::$utfBoms)) |
|
86 | + if (isset(self::$utfBoms)) |
|
87 | 87 | { |
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | self::$utfBoms = array( |
92 | - 'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF), |
|
93 | - 'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00), |
|
94 | - 'UTF16-BE' => chr(0xFE) . chr(0xFF), |
|
95 | - 'UTF16-LE' => chr(0xFF) . chr(0xFE), |
|
96 | - 'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF) |
|
92 | + 'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF), |
|
93 | + 'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00), |
|
94 | + 'UTF16-BE' => chr(0xFE).chr(0xFF), |
|
95 | + 'UTF16-LE' => chr(0xFF).chr(0xFE), |
|
96 | + 'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF) |
|
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
100 | 100 | private function initEncodings() : void |
101 | 101 | { |
102 | - if(isset(self::$encodings)) |
|
102 | + if (isset(self::$encodings)) |
|
103 | 103 | { |
104 | 104 | return; |
105 | 105 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | self::$encodings = array(); |
110 | 110 | |
111 | - foreach($encodings as $string) |
|
111 | + foreach ($encodings as $string) |
|
112 | 112 | { |
113 | 113 | $withHyphen = str_replace('UTF', 'UTF-', $string); |
114 | 114 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->file = $info; |
36 | 36 | } |
37 | 37 | |
38 | - public function send(?string $fileName = null, bool $asAttachment=true) : void |
|
38 | + public function send(?string $fileName = null, bool $asAttachment = true) : void |
|
39 | 39 | { |
40 | 40 | $this->file |
41 | 41 | ->requireExists() |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | header("Cache-Control: public", true); |
55 | 55 | header("Content-Description: File Transfer", true); |
56 | - header("Content-Type: " . $this->detectMime(), true); |
|
56 | + header("Content-Type: ".$this->detectMime(), true); |
|
57 | 57 | |
58 | 58 | header(sprintf( |
59 | 59 | "Content-Disposition: %s; filename=%s", |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | private function resolveDisposition(bool $asAttachment) : string |
71 | 71 | { |
72 | - if($asAttachment) |
|
72 | + if ($asAttachment) |
|
73 | 73 | { |
74 | 74 | return 'attachment'; |
75 | 75 | } |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | |
48 | 48 | $file = new SplFileObject($this->file->getPath()); |
49 | 49 | |
50 | - if($file->eof()) { |
|
50 | + if ($file->eof()) { |
|
51 | 51 | return ''; |
52 | 52 | } |
53 | 53 | |
54 | - $targetLine = $lineNumber-1; |
|
54 | + $targetLine = $lineNumber - 1; |
|
55 | 55 | |
56 | 56 | $file->seek($targetLine); |
57 | 57 | |
58 | - if($file->key() !== $targetLine) |
|
58 | + if ($file->key() !== $targetLine) |
|
59 | 59 | { |
60 | 60 | return null; |
61 | 61 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $number = $spl->key(); |
77 | 77 | |
78 | 78 | // if seeking to the end the cursor is still at 0, there are no lines. |
79 | - if($number === 0) |
|
79 | + if ($number === 0) |
|
80 | 80 | { |
81 | 81 | // since it's a very small file, to get reliable results, |
82 | 82 | // we read its contents and use that to determine what |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | // that this is not practical to solve with the SplFileObject. |
85 | 85 | $content = file_get_contents($path); |
86 | 86 | |
87 | - if(empty($content)) { |
|
87 | + if (empty($content)) { |
|
88 | 88 | return 0; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | // return the line number we were able to reach + 1 (key is zero-based) |
93 | - return $number+1; |
|
93 | + return $number + 1; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | * @return string[] |
99 | 99 | * @throws FileHelper_Exception |
100 | 100 | */ |
101 | - public function getLines(int $amount=0) : array |
|
101 | + public function getLines(int $amount = 0) : array |
|
102 | 102 | { |
103 | 103 | $this->file->requireExists(); |
104 | 104 | |
105 | 105 | $fn = fopen($this->file->getPath(), 'rb'); |
106 | 106 | |
107 | - if($fn === false) |
|
107 | + if ($fn === false) |
|
108 | 108 | { |
109 | 109 | throw new FileHelper_Exception( |
110 | 110 | 'Could not open file for reading.', |
@@ -120,19 +120,19 @@ discard block |
||
120 | 120 | $counter = 0; |
121 | 121 | $first = true; |
122 | 122 | |
123 | - while(!feof($fn)) |
|
123 | + while (!feof($fn)) |
|
124 | 124 | { |
125 | 125 | $counter++; |
126 | 126 | |
127 | 127 | $line = fgets($fn); |
128 | 128 | |
129 | 129 | // can happen with zero length files |
130 | - if($line === false) { |
|
130 | + if ($line === false) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // the first line may contain a unicode BOM marker. |
135 | - if($first) |
|
135 | + if ($first) |
|
136 | 136 | { |
137 | 137 | $line = ConvertHelper::stripUTFBom($line); |
138 | 138 | $first = false; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | $result[] = $line; |
142 | 142 | |
143 | - if($amount > 0 && $counter === $amount) { |
|
143 | + if ($amount > 0 && $counter === $amount) { |
|
144 | 144 | break; |
145 | 145 | } |
146 | 146 | } |
@@ -49,13 +49,13 @@ |
||
49 | 49 | |
50 | 50 | $name = str_replace(array_keys($replaces), array_values($replaces), $name); |
51 | 51 | |
52 | - while(strpos($name, ' ') !== false) { |
|
52 | + while (strpos($name, ' ') !== false) { |
|
53 | 53 | $name = str_replace(' ', ' ', $name); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $name = str_replace(array_keys($replaces), array_values($replaces), $name); |
57 | 57 | |
58 | - while(strpos($name, '..') !== false) { |
|
58 | + while (strpos($name, '..') !== false) { |
|
59 | 59 | $name = str_replace('..', '.', $name); |
60 | 60 | } |
61 | 61 |