@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | self::TYPE_TRAIT |
49 | 49 | ); |
50 | 50 | |
51 | - /** |
|
52 | - * @param PHPFile $path The path to the PHP file to parse. |
|
53 | - * @throws FileHelper_Exception |
|
54 | - * @see FileHelper::findPHPClasses() |
|
55 | - */ |
|
51 | + /** |
|
52 | + * @param PHPFile $path The path to the PHP file to parse. |
|
53 | + * @throws FileHelper_Exception |
|
54 | + * @see FileHelper::findPHPClasses() |
|
55 | + */ |
|
56 | 56 | public function __construct(PHPFile $path) |
57 | 57 | { |
58 | 58 | $this->file = $path |
@@ -62,58 +62,58 @@ discard block |
||
62 | 62 | $this->parseFile(); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * The name of the namespace of the classes in the file, if any. |
|
67 | - * @return string |
|
68 | - */ |
|
65 | + /** |
|
66 | + * The name of the namespace of the classes in the file, if any. |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public function getNamespace() : string |
70 | 70 | { |
71 | 71 | return $this->namespace; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Whether the file contains a namespace. |
|
76 | - * @return bool |
|
77 | - */ |
|
74 | + /** |
|
75 | + * Whether the file contains a namespace. |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | 78 | public function hasNamespace() : bool |
79 | 79 | { |
80 | 80 | return !empty($this->namespace); |
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * The absolute path to the file. |
|
85 | - * @return string |
|
86 | - */ |
|
83 | + /** |
|
84 | + * The absolute path to the file. |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function getPath() : string |
88 | 88 | { |
89 | 89 | return $this->file->getPath(); |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Whether any classes were found in the file. |
|
94 | - * @return bool |
|
95 | - */ |
|
92 | + /** |
|
93 | + * Whether any classes were found in the file. |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | 96 | public function hasClasses() : bool |
97 | 97 | { |
98 | 98 | return !empty($this->classes); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * The names of the classes that were found in the file (with namespace if any). |
|
103 | - * @return string[] |
|
104 | - */ |
|
101 | + /** |
|
102 | + * The names of the classes that were found in the file (with namespace if any). |
|
103 | + * @return string[] |
|
104 | + */ |
|
105 | 105 | public function getClassNames() : array |
106 | 106 | { |
107 | 107 | return array_keys($this->classes); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Retrieves all classes that were detected in the file, |
|
112 | - * which can be used to retrieve more information about |
|
113 | - * them. |
|
114 | - * |
|
115 | - * @return FileHelper_PHPClassInfo_Class[] |
|
116 | - */ |
|
110 | + /** |
|
111 | + * Retrieves all classes that were detected in the file, |
|
112 | + * which can be used to retrieve more information about |
|
113 | + * them. |
|
114 | + * |
|
115 | + * @return FileHelper_PHPClassInfo_Class[] |
|
116 | + */ |
|
117 | 117 | public function getClasses() : array |
118 | 118 | { |
119 | 119 | return array_values($this->classes); |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $this->classes[$class->getNameNS()] = $class; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Strips all whitespace from the string, replacing it with |
|
190 | - * regular spaces (newlines, tabs, etc.). |
|
191 | - * |
|
192 | - * @param string $string |
|
193 | - * @return string |
|
194 | - */ |
|
188 | + /** |
|
189 | + * Strips all whitespace from the string, replacing it with |
|
190 | + * regular spaces (newlines, tabs, etc.). |
|
191 | + * |
|
192 | + * @param string $string |
|
193 | + * @return string |
|
194 | + */ |
|
195 | 195 | protected function stripWhitespace(string $string) : string |
196 | 196 | { |
197 | 197 | return preg_replace('/\s/', ' ', $string); |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | $this->detectNamespace($code); |
127 | 127 | $result = $this->detectMatches($code); |
128 | 128 | |
129 | - if($result === null) { |
|
129 | + if ($result === null) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $indexes = array_keys($result[0]); |
134 | 134 | |
135 | - foreach($indexes as $idx) |
|
135 | + foreach ($indexes as $idx) |
|
136 | 136 | { |
137 | 137 | $this->parseResult( |
138 | 138 | $result[1][$idx], |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | preg_match_all('/(abstract|final)\s+('.$types.')\s+([\sa-z\d\\\\_,]+){|('.$types.')\s+([\sa-z\d\\\\_,]+){/ix', $code, $result, PREG_PATTERN_ORDER); |
153 | 153 | |
154 | - if(isset($result[0][0])) { |
|
154 | + if (isset($result[0][0])) { |
|
155 | 155 | return $result; |
156 | 156 | } |
157 | 157 | |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | $result = array(); |
164 | 164 | preg_match_all('/namespace\s+([^;]+);/ix', $code, $result, PREG_PATTERN_ORDER); |
165 | 165 | |
166 | - if(isset($result[0][0])) { |
|
166 | + if (isset($result[0][0])) { |
|
167 | 167 | $this->namespace = trim($result[1][0]); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | 171 | private function parseResult(string $keyword, string $declaration, string $type, string $simpleType, string $simpleDeclaration) : void |
172 | 172 | { |
173 | - if(empty($keyword)) { |
|
173 | + if (empty($keyword)) { |
|
174 | 174 | $type = $simpleType; |
175 | 175 | $declaration = $simpleDeclaration; |
176 | 176 | } |
@@ -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() |