Skip to content

Commit

Permalink
Fix phpcs and phpunit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Aug 11, 2019
1 parent 8bda6ce commit 5dad6ea
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Standards/Generic/Sniffs/Files/FilePermissionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

class FileExtensionSniff implements Sniff
{


/**
* Returns an array of tokens this test wants to listen for.
*
Expand All @@ -37,14 +39,19 @@ public function register()
*/
public function process(File $phpcsFile, $stackPtr)
{
$perms = fileperms($phpcsFile->getFilename());
$filename = $phpcsFile->getFilename();

if ($filename !== 'STDIN') {
$perms = fileperms($phpcsFile->getFilename());

if (($perms & 0x0040) !== 0 || ($perms & 0x0008) !== 0 || ($perms & 0x0001) !== 0) {
$error = "A PHP file must not be executable";
$phpcsFile->addError($error, $stackPtr, 'Executable');
}

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

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

}//end process()
Expand Down

0 comments on commit 5dad6ea

Please sign in to comment.