function ExecutableFileSniff::process
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token in the: stack passed in $tokens.
Return value
int
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Generic/ Sniffs/ Files/ ExecutableFileSniff.php, line 43
Class
Namespace
PHP_CodeSniffer\Standards\Generic\Sniffs\FilesCode
public function process(File $phpcsFile, $stackPtr) {
$filename = $phpcsFile->getFilename();
if ($filename !== 'STDIN') {
$perms = fileperms($phpcsFile->getFilename());
if (($perms & 0x40) !== 0 || ($perms & 0x8) !== 0 || ($perms & 0x1) !== 0) {
$error = 'A PHP file should not be executable; found file permissions set to %s';
$data = [
substr(sprintf('%o', $perms), -4),
];
$phpcsFile->addError($error, 0, 'Executable', $data);
}
}
// Ignore the rest of the file.
return $phpcsFile->numTokens;
}