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

Commit 34194fd

Browse files
committed
run code inspection check. fix some errors
1 parent 2ce75b8 commit 34194fd

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/File.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ abstract class File extends FileSystem
2323
{
2424
use ReadTrait;
2525

26-
const FORMAT_JSON = 'json';
27-
const FORMAT_PHP = 'php';
28-
const FORMAT_INI = 'ini';
29-
const FORMAT_YML = 'yml';
30-
const FORMAT_YAML = 'yml';
26+
public const FORMAT_JSON = 'json';
27+
public const FORMAT_PHP = 'php';
28+
public const FORMAT_INI = 'ini';
29+
public const FORMAT_YML = 'yml';
30+
public const FORMAT_YAML = 'yml';
3131

3232
/**
3333
* 获得文件名称

src/FileFinder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
*/
2929
final class FileFinder implements \IteratorAggregate, \Countable
3030
{
31-
const ONLY_FILE = 1;
32-
const ONLY_DIR = 2;
33-
const IGNORE_VCS_FILES = 1;
34-
const IGNORE_DOT_FILES = 2;
31+
public const ONLY_FILE = 1;
32+
public const ONLY_DIR = 2;
33+
public const IGNORE_VCS_FILES = 1;
34+
public const IGNORE_DOT_FILES = 2;
3535

3636
/** @var array */
3737
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];

src/FileSystem.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public static function isAbsPath(string $path): bool
3131
}
3232

3333
if (
34-
$path{0} === '/' || // linux/mac
35-
1 === preg_match('#^[a-z]:[\/|\\\]{1}.+#i', $path) // windows
34+
\strpos($path, '/') === 0 || // linux/mac
35+
1 === \preg_match('#^[a-z]:[\/|\\\]{1}.+#i', $path) // windows
3636
) {
3737
return true;
3838
}
@@ -63,9 +63,9 @@ public static function isAbsolutePath(string $file): bool
6363
*/
6464
public static function pathFormat(string $dirName): string
6565
{
66-
$dirName = str_ireplace('\\', '/', trim($dirName));
66+
$dirName = (string)\str_ireplace('\\', '/', trim($dirName));
6767

68-
return substr((string)$dirName, -1) === '/' ? $dirName : $dirName . '/';
68+
return \substr($dirName, -1) === '/' ? $dirName : $dirName . '/';
6969
}
7070

7171
/**
@@ -239,10 +239,8 @@ public static function chown($files, string $user, $recursive = false)
239239
if (true !== lchown($file, $user)) {
240240
throw new IOException(sprintf('Failed to chown file "%s".', $file));
241241
}
242-
} else {
243-
if (true !== chown($file, $user)) {
244-
throw new IOException(sprintf('Failed to chown file "%s".', $file));
245-
}
242+
} elseif (true !== chown($file, $user)) {
243+
throw new IOException(sprintf('Failed to chown file "%s".', $file));
246244
}
247245
}
248246
}
@@ -255,7 +253,7 @@ public static function chown($files, string $user, $recursive = false)
255253
*/
256254
public static function getIterator(string $srcDir, callable $filter): \RecursiveIteratorIterator
257255
{
258-
if (!$srcDir || !file_exists($srcDir)) {
256+
if (!$srcDir || !\file_exists($srcDir)) {
259257
throw new \InvalidArgumentException('Please provide a exists source directory.');
260258
}
261259

0 commit comments

Comments
 (0)