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

Commit

Permalink
run code inspection check. fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 4, 2019
1 parent 2ce75b8 commit 34194fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ abstract class File extends FileSystem
{
use ReadTrait;

const FORMAT_JSON = 'json';
const FORMAT_PHP = 'php';
const FORMAT_INI = 'ini';
const FORMAT_YML = 'yml';
const FORMAT_YAML = 'yml';
public const FORMAT_JSON = 'json';
public const FORMAT_PHP = 'php';
public const FORMAT_INI = 'ini';
public const FORMAT_YML = 'yml';
public const FORMAT_YAML = 'yml';

/**
* 获得文件名称
Expand Down
8 changes: 4 additions & 4 deletions src/FileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
*/
final class FileFinder implements \IteratorAggregate, \Countable
{
const ONLY_FILE = 1;
const ONLY_DIR = 2;
const IGNORE_VCS_FILES = 1;
const IGNORE_DOT_FILES = 2;
public const ONLY_FILE = 1;
public const ONLY_DIR = 2;
public const IGNORE_VCS_FILES = 1;
public const IGNORE_DOT_FILES = 2;

/** @var array */
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
Expand Down
16 changes: 7 additions & 9 deletions src/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static function isAbsPath(string $path): bool
}

if (
$path{0} === '/' || // linux/mac
1 === preg_match('#^[a-z]:[\/|\\\]{1}.+#i', $path) // windows
\strpos($path, '/') === 0 || // linux/mac
1 === \preg_match('#^[a-z]:[\/|\\\]{1}.+#i', $path) // windows
) {
return true;
}
Expand Down Expand Up @@ -63,9 +63,9 @@ public static function isAbsolutePath(string $file): bool
*/
public static function pathFormat(string $dirName): string
{
$dirName = str_ireplace('\\', '/', trim($dirName));
$dirName = (string)\str_ireplace('\\', '/', trim($dirName));

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

/**
Expand Down Expand Up @@ -239,10 +239,8 @@ public static function chown($files, string $user, $recursive = false)
if (true !== lchown($file, $user)) {
throw new IOException(sprintf('Failed to chown file "%s".', $file));
}
} else {
if (true !== chown($file, $user)) {
throw new IOException(sprintf('Failed to chown file "%s".', $file));
}
} elseif (true !== chown($file, $user)) {
throw new IOException(sprintf('Failed to chown file "%s".', $file));
}
}
}
Expand All @@ -255,7 +253,7 @@ public static function chown($files, string $user, $recursive = false)
*/
public static function getIterator(string $srcDir, callable $filter): \RecursiveIteratorIterator
{
if (!$srcDir || !file_exists($srcDir)) {
if (!$srcDir || !\file_exists($srcDir)) {
throw new \InvalidArgumentException('Please provide a exists source directory.');
}

Expand Down

0 comments on commit 34194fd

Please sign in to comment.