Skip to content

Commit 35962e6

Browse files
committed
chore: update some method params
1 parent e681a8f commit 35962e6

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/Directory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public static function getFilesInfo(string $path, $ext = null, bool $recursive =
233233
*
234234
* @return bool
235235
*/
236-
public static function create(string $path, int $mode = 0665, bool $recursive = true): bool
236+
public static function create(string $path, int $mode = 0666, bool $recursive = true): bool
237237
{
238238
return (is_dir($path) || !(!@mkdir($path, $mode, $recursive) && !is_dir($path))) && is_writable($path);
239239
}
@@ -247,7 +247,7 @@ public static function create(string $path, int $mode = 0665, bool $recursive =
247247
*
248248
* @return bool
249249
*/
250-
public static function mkSubDirs(string $parentDir, array $subDirs, int $mode = 0665): bool
250+
public static function mkSubDirs(string $parentDir, array $subDirs, int $mode = 0666): bool
251251
{
252252
if (!self::create($parentDir)) {
253253
return false;

src/File.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function function_exists;
2828
use function in_array;
2929
use function is_array;
30+
use function is_file;
3031
use function is_string;
3132
use function stream_get_contents;
3233
use function stream_get_meta_data;
@@ -117,9 +118,7 @@ public static function loadPhp(string $file, bool $throwError = true): array
117118
$ary = [];
118119

119120
if (is_file($file)) {
120-
/** @noinspection PhpIncludeInspection */
121121
$ary = require $file;
122-
123122
if (!is_array($ary)) {
124123
$ary = [];
125124
}
@@ -223,6 +222,10 @@ public static function getContents(
223222
int $offset = 0,
224223
int $maxlen = null
225224
): string {
225+
if (!is_file($filename)) {
226+
throw new InvalidArgumentException("No such file: $filename");
227+
}
228+
226229
$content = file_get_contents($filename, $useIncludePath, $context, $offset, $maxlen);
227230
if ($content === false) {
228231
throw new FileWriteException('read contents error from file: ' . $filename);

src/Traits/FileSystemFuncTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function assertReadableStream($stream): void
7575
}
7676

7777
$meta = stream_get_meta_data($stream);
78-
if (strpos($meta['mode'], 'r') === false && strpos($meta['mode'], '+') === false) {
78+
if (!str_contains($meta['mode'], 'r') && !str_contains($meta['mode'], '+')) {
7979
throw new InvalidArgumentException('Expected a readable stream');
8080
}
8181
}

0 commit comments

Comments
 (0)