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

Commit 36bff34

Browse files
committed
format all codes
1 parent 8327b82 commit 36bff34

File tree

5 files changed

+76
-72
lines changed

5 files changed

+76
-72
lines changed

src/Directory.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Directory extends FileSystem
4040
* // $info->getFilename(); ...
4141
* }
4242
* ```
43-
* @param string $srcDir
43+
* @param string $srcDir
4444
* @param callable $filter
4545
* @return \RecursiveIteratorIterator
4646
* @throws \LogicException
@@ -103,9 +103,9 @@ public static function ls($path): array
103103

104104
/**
105105
* 只获得目录结构
106-
* @param $path
107-
* @param int $pid
108-
* @param int $son
106+
* @param $path
107+
* @param int $pid
108+
* @param int $son
109109
* @param array $list
110110
* @return array
111111
* @throws FileNotFoundException
@@ -140,9 +140,9 @@ public static function getList($path, $pid = 0, $son = 0, array $list = []): arr
140140
}
141141

142142
/**
143-
* @param $path
144-
* @param bool $loop
145-
* @param null $parent
143+
* @param $path
144+
* @param bool $loop
145+
* @param null $parent
146146
* @param array $list
147147
* @return array
148148
* @throws FileNotFoundException
@@ -174,9 +174,9 @@ public static function getDirs($path, $loop = false, $parent = null, array $list
174174

175175
/**
176176
* 获得目录下的文件,可选择类型、是否遍历子文件夹
177-
* @param string $dir string 目标目录
177+
* @param string $dir string 目标目录
178178
* @param string|array $ext array('css','html','php') css|html|php
179-
* @param bool $recursive int|bool 是否包含子目录
179+
* @param bool $recursive int|bool 是否包含子目录
180180
* @return array
181181
* @throws FileNotFoundException
182182
*/
@@ -213,11 +213,11 @@ public static function simpleInfo($dir, $ext = null, $recursive = false): array
213213

214214
/**
215215
* 获得目录下的文件,可选择类型、是否遍历子文件夹
216-
* @param string $path string 目标目录
216+
* @param string $path string 目标目录
217217
* @param array|string $ext array('css','html','php') css|html|php
218-
* @param bool $recursive 是否包含子目录
219-
* @param null|string $parent
220-
* @param array $list
218+
* @param bool $recursive 是否包含子目录
219+
* @param null|string $parent
220+
* @param array $list
221221
* @return array
222222
* @throws FileNotFoundException
223223
*/
@@ -249,10 +249,10 @@ public static function getFiles($path, $ext = null, $recursive = false, $parent
249249

250250
/**
251251
* 获得目录下的文件以及详细信息,可选择类型、是否遍历子文件夹
252-
* @param $path string 目标目录
252+
* @param $path string 目标目录
253253
* @param array|string $ext array('css','html','php') css|html|php
254-
* @param $recursive int|bool 是否包含子目录
255-
* @param array $list
254+
* @param $recursive int|bool 是否包含子目录
255+
* @param array $list
256256
* @return array
257257
* @throws \InvalidArgumentException
258258
* @throws FileNotFoundException
@@ -288,9 +288,9 @@ public static function getFilesInfo($path, $ext = null, $recursive = 0, &$list):
288288

289289
/**
290290
* 支持层级目录的创建
291-
* @param $path
291+
* @param $path
292292
* @param int|string $mode
293-
* @param bool $recursive
293+
* @param bool $recursive
294294
* @return bool
295295
*/
296296
public static function create($path, $mode = 0775, $recursive = true): bool
@@ -337,7 +337,7 @@ public static function copy($oldDir, $newDir): bool
337337

338338
/**
339339
* 删除目录及里面的文件
340-
* @param $path
340+
* @param $path
341341
* @param boolean $delSelf 默认最后删掉自己
342342
* @return bool
343343
*/

src/File.php

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ abstract class File extends FileSystem
2424
use ReadTrait;
2525

2626
const FORMAT_JSON = 'json';
27-
const FORMAT_PHP = 'php';
28-
const FORMAT_INI = 'ini';
29-
const FORMAT_YML = 'yml';
27+
const FORMAT_PHP = 'php';
28+
const FORMAT_INI = 'ini';
29+
const FORMAT_YML = 'yml';
3030
const FORMAT_YAML = 'yml';
3131

3232
/**
3333
* 获得文件名称
3434
* @param string $file
35-
* @param bool $clearExt 是否去掉文件名中的后缀,仅保留名字
35+
* @param bool $clearExt 是否去掉文件名中的后缀,仅保留名字
3636
* @return string
3737
*/
3838
public static function getName($file, $clearExt = false): string
@@ -44,7 +44,7 @@ public static function getName($file, $clearExt = false): string
4444

4545
/**
4646
* 获得文件扩展名、后缀名
47-
* @param $filename
47+
* @param $filename
4848
* @param bool $clearPoint 是否带点
4949
* @return string
5050
*/
@@ -57,7 +57,7 @@ public static function getSuffix($filename, $clearPoint = false): string
5757

5858
/**
5959
* 获得文件扩展名、后缀名
60-
* @param $path
60+
* @param $path
6161
* @param bool $clearPoint 是否带点
6262
* @return string
6363
*/
@@ -79,7 +79,7 @@ public static function mimeType($file): string
7979

8080
/**
8181
* @param string $filename
82-
* @param bool $check
82+
* @param bool $check
8383
* @return array
8484
* @throws FileNotFoundException
8585
* @throws \InvalidArgumentException
@@ -89,12 +89,12 @@ public static function info(string $filename, $check = true): array
8989
$check && self::check($filename);
9090

9191
return [
92-
'name' => basename($filename), //文件名
93-
'type' => filetype($filename), //类型
94-
'size' => (filesize($filename) / 1000) . ' Kb', //大小
95-
'is_write' => is_writable($filename) ? 'true' : 'false', //可写
96-
'is_read' => is_readable($filename) ? 'true' : 'false',//可读
97-
'update_time' => filectime($filename), //修改时间
92+
'name' => basename($filename), //文件名
93+
'type' => filetype($filename), //类型
94+
'size' => (filesize($filename) / 1000) . ' Kb', //大小
95+
'is_write' => is_writable($filename) ? 'true' : 'false', //可写
96+
'is_read' => is_readable($filename) ? 'true' : 'false',//可读
97+
'update_time' => filectime($filename), //修改时间
9898
'last_visit_time' => fileatime($filename), //文件的上次访问时间
9999
];
100100
}
@@ -110,7 +110,7 @@ public static function getStat($filename): array
110110

111111
/**
112112
* save description
113-
* @param mixed $data string array(仅一维数组) 或者是 stream 资源
113+
* @param mixed $data string array(仅一维数组) 或者是 stream 资源
114114
* @param string $filename [description], LOCK_EX
115115
* @return bool
116116
*/
@@ -150,8 +150,8 @@ public static function openHandler(string $path)
150150
/**
151151
* Attempts to write $content to the file specified by $handler. $path is used for printing exceptions.
152152
* @param resource $handler The resource to write to.
153-
* @param string $content The content to write.
154-
* @param string $path The path to the file (for exception printing only).
153+
* @param string $content The content to write.
154+
* @param string $path The path to the file (for exception printing only).
155155
* @throws IOException
156156
*/
157157
public static function writeToFile($handler, string $content, string $path = '')
@@ -192,16 +192,20 @@ public static function createAndWrite(array $fileData = [], $append = false, $mo
192192
}
193193

194194
/**
195-
* @param string $file a file path or url path
196-
* @param bool|false $useIncludePath
195+
* @param string $file a file path or url path
196+
* @param bool|false $useIncludePath
197197
* @param null|resource $streamContext
198-
* @param int $curlTimeout
198+
* @param int $curlTimeout
199199
* @return bool|mixed|string
200200
* @throws FileNotFoundException
201201
* @throws FileReadException
202202
*/
203-
public static function getContents(string $file, $useIncludePath = false, $streamContext = null, int $curlTimeout = 5)
204-
{
203+
public static function getContents(
204+
string $file,
205+
$useIncludePath = false,
206+
$streamContext = null,
207+
int $curlTimeout = 5
208+
) {
205209
$isUrl = preg_match('/^https?:\/\//', $file);
206210

207211
if (null === $streamContext && $isUrl) {
@@ -227,7 +231,7 @@ public static function getContents(string $file, $useIncludePath = false, $strea
227231
curl_setopt($curl, CURLOPT_URL, $file);
228232
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
229233
curl_setopt($curl, CURLOPT_TIMEOUT, $curlTimeout);
230-
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
234+
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
231235

232236
if (null !== $streamContext) {
233237
$opts = stream_context_get_options($streamContext);
@@ -279,8 +283,8 @@ public static function delete($filename): bool
279283
}
280284

281285
/**
282-
* @param $source
283-
* @param $destination
286+
* @param $source
287+
* @param $destination
284288
* @param null $streamContext
285289
* @return bool|int
286290
* @throws FileSystemException
@@ -336,9 +340,9 @@ public static function combine($inFile, $outFile)
336340
$data = preg_replace($preg_arr, '', $data);
337341
// $outFile = $outDir . Data::getRandStr(8) . '.' . $fileType;
338342

339-
$fileData = array(
343+
$fileData = [
340344
$outFile => $data
341-
);
345+
];
342346

343347
self::createAndWrite($fileData);
344348

src/FileFinder.php

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

@@ -88,11 +88,11 @@ public static function fromArray(array $config): self
8888
{
8989
$finder = new self();
9090
$allowed = [
91-
'names' => 'addNames',
91+
'names' => 'addNames',
9292
'notNames' => 'addNotNames',
93-
'paths' => 'addNotPaths',
93+
'paths' => 'addNotPaths',
9494
'notPaths' => 'addNotPaths',
95-
'exclude' => 'exclude',
95+
'exclude' => 'exclude',
9696
'excludes' => 'exclude',
9797
];
9898

src/FileSystem.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function clearPharPath(string $path): string
8787

8888
/**
8989
* 检查文件/夹/链接是否存在
90-
* @param string $file 要检查的目标
90+
* @param string $file 要检查的目标
9191
* @param null|string $type
9292
* @return array|string
9393
*/
@@ -111,7 +111,7 @@ public static function exists(string $file, $type = null)
111111
}
112112

113113
/**
114-
* @param string $file
114+
* @param string $file
115115
* @param null|string|array $ext eg: 'jpg|gif'
116116
* @throws FileNotFoundException
117117
* @throws \InvalidArgumentException
@@ -138,7 +138,7 @@ public static function check(string $file, $ext = null)
138138
* @from Symfony-filesystem
139139
* @param string $origin The origin filename or directory
140140
* @param string $target The new filename or directory
141-
* @param bool $overwrite Whether to overwrite the target if it already exists
141+
* @param bool $overwrite Whether to overwrite the target if it already exists
142142
* @throws IOException When target file or directory already exists
143143
* @throws IOException When origin cannot be renamed
144144
*/
@@ -173,7 +173,7 @@ public static function isReadable(string $filename): bool
173173
/**
174174
* Creates a directory recursively.
175175
* @param string|array|\Traversable $dirs The directory path
176-
* @param int $mode The directory mode
176+
* @param int $mode The directory mode
177177
* @throws IOException On any directory creation failure
178178
*/
179179
public static function mkdir($dirs, $mode = 0777)
@@ -202,9 +202,9 @@ public static function mkdir($dirs, $mode = 0777)
202202
* Change mode for an array of files or directories.
203203
* @from Symfony-filesystem
204204
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change mode
205-
* @param int $mode The new mode (octal)
206-
* @param int $umask The mode mask (octal)
207-
* @param bool $recursive Whether change the mod recursively or not
205+
* @param int $mode The new mode (octal)
206+
* @param int $umask The mode mask (octal)
207+
* @param bool $recursive Whether change the mod recursively or not
208208
* @throws IOException When the change fail
209209
*/
210210
public static function chmod($files, $mode, $umask = 0000, $recursive = false)
@@ -224,8 +224,8 @@ public static function chmod($files, $mode, $umask = 0000, $recursive = false)
224224
* Change the owner of an array of files or directories.
225225
* @from Symfony-filesystem
226226
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change owner
227-
* @param string $user The new owner user name
228-
* @param bool $recursive Whether change the owner recursively or not
227+
* @param string $user The new owner user name
228+
* @param bool $recursive Whether change the owner recursively or not
229229
* @throws IOException When the change fail
230230
*/
231231
public static function chown($files, string $user, $recursive = false)
@@ -248,7 +248,7 @@ public static function chown($files, string $user, $recursive = false)
248248
}
249249

250250
/**
251-
* @param string $srcDir
251+
* @param string $srcDir
252252
* @param callable $filter
253253
* @return \RecursiveIteratorIterator
254254
* @throws \InvalidArgumentException
@@ -266,7 +266,7 @@ public static function getIterator(string $srcDir, callable $filter): \Recursive
266266
}
267267

268268
/**
269-
* @param $path
269+
* @param $path
270270
* @param int $mode
271271
* @return bool
272272
*/

0 commit comments

Comments
 (0)