Skip to content

Commit f0c1acd

Browse files
committed
WSL support: replace remaining calls to is_readable()
... with calls to `Common::isReadable()` as introduced in d56e167 . Includes adding additional error silencing to the `Common::isReadable()` function as each of these PHP native functions will throw a warning upon failure. Co-authored-by: Graham Wharton <graham@gwharton.me.uk> Fixes 3388 May also fix 3412, but needs testing.
1 parent b10c327 commit f0c1acd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Config.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use PHP_CodeSniffer\Exceptions\DeepExitException;
1616
use PHP_CodeSniffer\Exceptions\RuntimeException;
17+
use PHP_CodeSniffer\Util\Common;
1718

1819
/**
1920
* Stores the configuration used to run PHPCS and PHPCBF.
@@ -363,7 +364,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
363364

364365
$lastDir = $currentDir;
365366
$currentDir = dirname($currentDir);
366-
} while ($currentDir !== '.' && $currentDir !== $lastDir && @is_readable($currentDir) === true);
367+
} while ($currentDir !== '.' && $currentDir !== $lastDir && Common::isReadable($currentDir) === true);
367368
}//end if
368369

369370
if (defined('STDIN') === false
@@ -1656,7 +1657,7 @@ public static function getAllConfigData()
16561657
return [];
16571658
}
16581659

1659-
if (is_readable($configFile) === false) {
1660+
if (Common::isReadable($configFile) === false) {
16601661
$error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
16611662
throw new DeepExitException($error, 3);
16621663
}

src/Util/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public static function isPharFile($path)
6060
*/
6161
public static function isReadable($path)
6262
{
63-
if (is_readable($path) === true) {
63+
if (@is_readable($path) === true) {
6464
return true;
6565
}
6666

67-
if (file_exists($path) === true && is_file($path) === true) {
67+
if (@file_exists($path) === true && @is_file($path) === true) {
6868
$f = @fopen($path, 'rb');
6969
if (fclose($f) === true) {
7070
return true;

0 commit comments

Comments
 (0)