Skip to content
This repository was archived by the owner on Jun 17, 2020. It is now read-only.

Commit cf55fa8

Browse files
committedFeb 27, 2019
run code inspection check
1 parent e7df10c commit cf55fa8

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed
 

‎src/Directory.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -180,27 +180,27 @@ public static function getDirs($path, $loop = false, $parent = null, array $list
180180
* @return array
181181
* @throws FileNotFoundException
182182
*/
183-
public static function simpleInfo($dir, $ext = null, $recursive = false): array
183+
public static function simpleInfo(string $dir, $ext = null, $recursive = false): array
184184
{
185185
$list = [];
186186
$dir = self::pathFormat($dir);
187-
$ext = \is_array($ext) ? implode('|', $ext) : trim($ext);
187+
$ext = \is_array($ext) ? \implode('|', $ext) : \trim($ext);
188188

189-
if (!is_dir($dir)) {
189+
if (!\is_dir($dir)) {
190190
throw new FileNotFoundException("directory not exists! DIR: $dir");
191191
}
192192

193193
// glob()寻找与模式匹配的文件路径 $file is pull path
194-
foreach (glob($dir . '*') as $file) {
194+
foreach (\glob($dir . '*') as $file) {
195195

196196
// 匹配文件 如果没有传入$ext 则全部遍历,传入了则按传入的类型来查找
197-
if (is_file($file) && (!$ext || preg_match("/\.($ext)$/i", $file))) {
197+
if (\is_file($file) && (!$ext || \preg_match("/\.($ext)$/i", $file))) {
198198
//basename — 返回路径中的 文件名部分
199-
$list[] = basename($file);
199+
$list[] = \basename($file);
200200

201201
// is directory
202202
} else {
203-
$list[] = '/' . basename($file);
203+
$list[] = '/' . \basename($file);
204204

205205
if ($recursive) {
206206
$list = array_merge($list, self::simpleInfo($file, $ext, $recursive));
@@ -221,7 +221,7 @@ public static function simpleInfo($dir, $ext = null, $recursive = false): array
221221
* @return array
222222
* @throws FileNotFoundException
223223
*/
224-
public static function getFiles($path, $ext = null, $recursive = false, $parent = null, array $list = []): array
224+
public static function getFiles(string $path, $ext = null, $recursive = false, $parent = null, array $list = []): array
225225
{
226226
$path = self::pathFormat($path);
227227

@@ -230,13 +230,13 @@ public static function getFiles($path, $ext = null, $recursive = false, $parent
230230
}
231231

232232
$len = \strlen($path);
233-
$ext = \is_array($ext) ? implode('|', $ext) : trim($ext);
233+
$ext = \is_array($ext) ? \implode('|', $ext) : \trim($ext);
234234

235235
foreach (glob($path . '*') as $v) {
236236
$relatePath = substr($v, $len);
237237

238238
// 匹配文件 如果没有传入$ext 则全部遍历,传入了则按传入的类型来查找
239-
if (is_file($v) && (!$ext || preg_match("/\.($ext)$/i", $v))) {
239+
if (\is_file($v) && (!$ext || \preg_match("/\.($ext)$/i", $v))) {
240240
$list[] = $parent . $relatePath;
241241

242242
} elseif ($recursive) {

‎src/File.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static function save(string $filename, string $data): bool
124124
* @param $path
125125
* @throws IOException
126126
*/
127-
public static function write($content, $path)
127+
public static function write($content, $path): void
128128
{
129129
$handler = static::openHandler($path);
130130

@@ -154,7 +154,7 @@ public static function openHandler(string $path)
154154
* @param string $path The path to the file (for exception printing only).
155155
* @throws IOException
156156
*/
157-
public static function writeToFile($handler, string $content, string $path = '')
157+
public static function writeToFile($handler, string $content, string $path = ''): void
158158
{
159159
if (($result = @fwrite($handler, $content)) === false || ($result < \strlen($content))) {
160160
throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
@@ -172,7 +172,7 @@ public static function writeToFile($handler, string $content, string $path = '')
172172
* 'case.html' => 'content' ,
173173
* );
174174
**/
175-
public static function createAndWrite(array $fileData = [], $append = false, $mode = 0664)
175+
public static function createAndWrite(array $fileData = [], $append = false, $mode = 0664): void
176176
{
177177
foreach ($fileData as $file => $content) {
178178
//检查目录是否存在,不存在就先创建(多级)目录
@@ -262,7 +262,7 @@ public static function getContents(
262262
* @throws FileSystemException
263263
* @throws IOException
264264
*/
265-
public static function move(string $file, string $target)
265+
public static function move(string $file, string $target): void
266266
{
267267
Directory::mkdir(\dirname($target));
268268

@@ -388,7 +388,7 @@ public static function stripPhpCode(string $source): string
388388
* @param string $file
389389
* @param string $as
390390
*/
391-
public static function downBigFile($file, $as)
391+
public static function downBigFile($file, $as): void
392392
{
393393
header('Expires: Mon, 1 Apr 1974 05:00:00 GMT');
394394
header('Pragma: no-cache');

‎src/FileFinder.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public function getChildren()
485485
}
486486
}
487487

488-
public function rewind()
488+
public function rewind(): void
489489
{
490490
if (false === $this->isRewindable()) {
491491
return;
@@ -501,8 +501,8 @@ public function isRewindable()
501501
}
502502

503503
if (false !== $stream = @opendir($this->getPath())) {
504-
$infoS = stream_get_meta_data($stream);
505-
closedir($stream);
504+
$infoS = \stream_get_meta_data($stream);
505+
\closedir($stream);
506506

507507
if ($infoS['seekable']) {
508508
return $this->rewindable = true;
@@ -522,7 +522,7 @@ public function isRewindable()
522522

523523
public function __construct(\RecursiveIterator $iterator, array $excludes)
524524
{
525-
$this->excludes = array_flip($excludes);
525+
$this->excludes = \array_flip($excludes);
526526
$this->iterator = $iterator;
527527

528528
parent::__construct($iterator);
@@ -598,14 +598,14 @@ public function accept(): bool
598598
$pathname = $this->current()->getFilename();
599599

600600
foreach ($this->notNames as $not) {
601-
if (fnmatch($not, $pathname)) {
601+
if (\fnmatch($not, $pathname)) {
602602
return false;
603603
}
604604
}
605605

606606
if ($this->names) {
607607
foreach ($this->names as $need) {
608-
if (fnmatch($need, $pathname)) {
608+
if (\fnmatch($need, $pathname)) {
609609
return true;
610610
}
611611
}
@@ -665,14 +665,14 @@ public function accept(): bool
665665
}
666666

667667
foreach ($this->notPaths as $not) {
668-
if (fnmatch($not, $pathname)) {
668+
if (\fnmatch($not, $pathname)) {
669669
return false;
670670
}
671671
}
672672

673673
if ($this->paths) {
674674
foreach ($this->paths as $need) {
675-
if (fnmatch($need, $pathname)) {
675+
if (\fnmatch($need, $pathname)) {
676676
return true;
677677
}
678678
}

‎src/FileSystem.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function exists(string $file, $type = null)
116116
* @throws FileNotFoundException
117117
* @throws \InvalidArgumentException
118118
*/
119-
public static function check(string $file, $ext = null)
119+
public static function check(string $file, $ext = null): void
120120
{
121121
if (!$file || !file_exists($file)) {
122122
throw new FileNotFoundException("File {$file} not exists!");
@@ -142,7 +142,7 @@ public static function check(string $file, $ext = null)
142142
* @throws IOException When target file or directory already exists
143143
* @throws IOException When origin cannot be renamed
144144
*/
145-
public static function rename(string $origin, string $target, bool $overwrite = false)
145+
public static function rename(string $origin, string $target, bool $overwrite = false): void
146146
{
147147
// we check that target does not exist
148148
if (!$overwrite && static::isReadable($target)) {
@@ -176,7 +176,7 @@ public static function isReadable(string $filename): bool
176176
* @param int $mode The directory mode
177177
* @throws IOException On any directory creation failure
178178
*/
179-
public static function mkdir($dirs, $mode = 0777)
179+
public static function mkdir($dirs, $mode = 0777): void
180180
{
181181
foreach (Arr::toIterator($dirs) as $dir) {
182182
if (is_dir($dir)) {
@@ -207,7 +207,7 @@ public static function mkdir($dirs, $mode = 0777)
207207
* @param bool $recursive Whether change the mod recursively or not
208208
* @throws IOException When the change fail
209209
*/
210-
public static function chmod($files, $mode, $umask = 0000, $recursive = false)
210+
public static function chmod($files, $mode, $umask = 0000, $recursive = false): void
211211
{
212212
foreach (Arr::toIterator($files) as $file) {
213213
if (true !== @chmod($file, $mode & ~$umask)) {
@@ -228,7 +228,7 @@ public static function chmod($files, $mode, $umask = 0000, $recursive = false)
228228
* @param bool $recursive Whether change the owner recursively or not
229229
* @throws IOException When the change fail
230230
*/
231-
public static function chown($files, string $user, $recursive = false)
231+
public static function chown($files, string $user, $recursive = false): void
232232
{
233233
foreach (Arr::toIterator($files) as $file) {
234234
if ($recursive && is_dir($file) && !is_link($file)) {

‎src/ModifyWatcher.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function calcMd5Hash(): string
225225
/**
226226
* @param string $watchDir
227227
*/
228-
private function collectDirMd5(string $watchDir)
228+
private function collectDirMd5(string $watchDir): void
229229
{
230230
$files = scandir($watchDir, 0);
231231

@@ -275,23 +275,23 @@ private function collectDirMd5(string $watchDir)
275275
/**
276276
* @return string|null
277277
*/
278-
public function getIdFile()
278+
public function getIdFile(): ?string
279279
{
280280
return $this->idFile;
281281
}
282282

283283
/**
284284
* @return string|null
285285
*/
286-
public function getWatchDir()
286+
public function getWatchDir(): ?string
287287
{
288288
return $this->watchDirs;
289289
}
290290

291291
/**
292292
* @return string|null
293293
*/
294-
public function getDirMd5()
294+
public function getDirMd5(): ?string
295295
{
296296
return $this->dirMd5;
297297
}

0 commit comments

Comments
 (0)
This repository has been archived.