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

Commit 6871acd

Browse files
committed
update something. update readme
1 parent bc332d1 commit 6871acd

File tree

3 files changed

+13
-59
lines changed

3 files changed

+13
-59
lines changed

src/Directory.php

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -357,51 +357,4 @@ public static function delete($path, $delSelf = true): bool
357357

358358
return true;
359359
}
360-
361-
/**
362-
* 比较文件路径
363-
* @param $newPath
364-
* @param $oldPath
365-
* @return string
366-
*/
367-
public static function comparePath($newPath, $oldPath): string
368-
{
369-
$oldDirName = basename(rtrim($oldPath, '/'));
370-
$newPath_arr = explode('/', rtrim($newPath, '/'));
371-
$oldPath_arr = explode('/', rtrim($oldPath, '/'));
372-
373-
$reOne = array_diff($newPath_arr, $oldPath_arr);
374-
$numOne = \count((array)$reOne);//
375-
376-
/**
377-
* 跟框架在同一个父目录[phpTest]下
378-
* projectPath 'F:/www/phpTest/xxx/yyy/[zzz]'--应用目录 zzz,
379-
* yzonePath 'F:/www/phpTest/[yzonefk]'---框架目录 [yzonefk]
380-
* 从应用'F:/www/phpTest/xxx/yyy/[zzz]/'目录回滚到共同的父目录[这里是从zzz/web回滚到phpTest]
381-
* 入口文件 在 zzz/web/index.php
382-
*/
383-
$dirStr = '__DIR__';
384-
385-
for ($i = 0; $i <= $numOne; $i++) {
386-
$dirStr = 'dirname( ' . $dirStr . ' )';
387-
}
388-
389-
$dirStr .= '.\'';
390-
391-
/**
392-
* 跟框架在不同父目录下,在回滚到共同的父目录后,再加上到框架的路径
393-
* newPath 'F:/www/otherDir/ddd/eee/xxx/yyy/[zzz]'--应用目录 zzz
394-
* oldPath 'F:/www/phpTest/[yzonefk]'---框架目录[yzonefk]
395-
*/
396-
if (\dirname($newPath) !== \dirname($oldPath)) {
397-
$reTwo = array_diff($oldPath_arr, $newPath_arr);
398-
$reTwo = array_shift($reTwo);
399-
// $numTwo = count($reTwo);// 从框架目录向上回滚,找到相同的父节点,得到相隔几层
400-
$dirStr .= implode('/', (array)$reTwo);
401-
}
402-
403-
$dirStr = $dirStr . '/' . $oldDirName . '/Gee.php\'';
404-
405-
return $dirStr;
406-
}
407360
}

src/File.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function info(string $filename, $check = true): array
105105
*/
106106
public static function getStat($filename): array
107107
{
108-
return stat($filename);
108+
return \stat($filename);
109109
}
110110

111111
/**
@@ -116,15 +116,15 @@ public static function getStat($filename): array
116116
*/
117117
public static function save(string $filename, string $data): bool
118118
{
119-
return file_put_contents($filename, $data) !== false;
119+
return \file_put_contents($filename, $data) !== false;
120120
}
121121

122122
/**
123123
* @param $content
124124
* @param $path
125125
* @throws IOException
126126
*/
127-
public static function write($content, $path): void
127+
public static function write($content, $path)
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 = ''): void
157+
public static function writeToFile($handler, string $content, string $path = '')
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): void
175+
public static function createAndWrite(array $fileData = [], $append = false, $mode = 0664)
176176
{
177177
foreach ($fileData as $file => $content) {
178178
//检查目录是否存在,不存在就先创建(多级)目录

src/FileSystem.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function pathFormat(string $dirName): string
6969
}
7070

7171
/**
72-
* @param string $path e.g phar://E:/workenv/php-dockerized/www/phplang/ugirls-social/social-uem/uem.phar/web
72+
* @param string $path e.g phar://E:/workenv/xxx/yyy/app.phar/web
7373
* @return string
7474
*/
7575
public function clearPharPath(string $path): string
@@ -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): void
119+
public static function check(string $file, $ext = null)
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): void
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): void
145+
public static function rename(string $origin, string $target, bool $overwrite = false)
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): void
179+
public static function mkdir($dirs, $mode = 0777)
180180
{
181181
foreach (Arr::toIterator($dirs) as $dir) {
182182
if (is_dir($dir)) {
@@ -207,7 +207,7 @@ public static function mkdir($dirs, $mode = 0777): void
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): void
210+
public static function chmod($files, $mode, $umask = 0000, $recursive = false)
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): void
231+
public static function chown($files, string $user, $recursive = false)
232232
{
233233
foreach (Arr::toIterator($files) as $file) {
234234
if ($recursive && is_dir($file) && !is_link($file)) {
@@ -251,11 +251,12 @@ public static function chown($files, string $user, $recursive = false): void
251251
* @param string $srcDir
252252
* @param callable $filter
253253
* @return \RecursiveIteratorIterator
254+
* @throws \InvalidArgumentException
254255
*/
255256
public static function getIterator(string $srcDir, callable $filter): \RecursiveIteratorIterator
256257
{
257258
if (!$srcDir || !file_exists($srcDir)) {
258-
throw new \LogicException('Please provide a exists source directory.');
259+
throw new \InvalidArgumentException('Please provide a exists source directory.');
259260
}
260261

261262
$directory = new \RecursiveDirectoryIterator($srcDir);

0 commit comments

Comments
 (0)