Skip to content

Commit 5dad6ea

Browse files
committed
Fix phpcs and phpunit errors
1 parent 8bda6ce commit 5dad6ea

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Standards/Generic/Sniffs/Files/FilePermissionsSniff.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
class FileExtensionSniff implements Sniff
1616
{
17+
18+
1719
/**
1820
* Returns an array of tokens this test wants to listen for.
1921
*
@@ -37,14 +39,19 @@ public function register()
3739
*/
3840
public function process(File $phpcsFile, $stackPtr)
3941
{
40-
$perms = fileperms($phpcsFile->getFilename());
42+
$filename = $phpcsFile->getFilename();
43+
44+
if ($filename !== 'STDIN') {
45+
$perms = fileperms($phpcsFile->getFilename());
46+
47+
if (($perms & 0x0040) !== 0 || ($perms & 0x0008) !== 0 || ($perms & 0x0001) !== 0) {
48+
$error = "A PHP file must not be executable";
49+
$phpcsFile->addError($error, $stackPtr, 'Executable');
50+
}
4151

42-
if ($perms & 0x0040 || $perms & 0x0008 || $perms & 0x0001) {
43-
$error = "A PHP file must not be executable";
44-
$phpcsFile->addError($error, $stackPtr, 'Executable');
52+
// Ignore the rest of the file.
4553
}
4654

47-
// Ignore the rest of the file.
4855
return ($phpcsFile->numTokens + 1);
4956

5057
}//end process()

0 commit comments

Comments
 (0)