Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various sniffs: always return EOF pointer #95

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
*/
public function process(File $phpcsFile, $stackPtr)
{
$csslintPath = Config::getExecutablePath('csslint');
if ($csslintPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand All @@ -59,7 +59,7 @@ public function process(File $phpcsFile, $stackPtr)
exec($cmd, $output, $retval);

if (is_array($output) === false) {
return;
return ($phpcsFile->numTokens + 1);
}

$count = count($output);
Expand Down
6 changes: 3 additions & 3 deletions src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run
*/
public function process(File $phpcsFile, $stackPtr)
{
$lintPath = Config::getExecutablePath('gjslint');
if ($lintPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand All @@ -77,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr)
exec($cmd, $output, $retval);

if (is_array($output) === false) {
return;
return ($phpcsFile->numTokens + 1);
}

foreach ($output as $finding) {
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Generic/Sniffs/Debug/ESLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run
*/
public function process(File $phpcsFile, $stackPtr)
{
$eslintPath = Config::getExecutablePath('eslint');
if ($eslintPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$filename = $phpcsFile->getFilename();
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Generic/Sniffs/Debug/JSHintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run
*/
public function process(File $phpcsFile, $stackPtr)
{
$rhinoPath = Config::getExecutablePath('rhino');
$jshintPath = Config::getExecutablePath('jshint');
if ($jshintPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($tokens[$lastToken]['line'] === 1
&& $tokens[$lastToken]['content'] !== "\n"
) {
return;
return ($phpcsFile->numTokens + 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function process(File $phpcsFile, $stackPtr)
{
$filename = $phpcsFile->getFilename();
if ($filename === 'STDIN') {
return;
return ($phpcsFile->numTokens + 1);
}

$filename = basename($filename);
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function process(File $phpcsFile, $stackPtr)
$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
if ($next === false) {
// Empty file.
return;
return $phpcsFile->numTokens;
}

if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) {
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run
*/
public function process(File $phpcsFile, $stackPtr)
{
$rhinoPath = Config::getExecutablePath('rhino');
$jslintPath = Config::getExecutablePath('jslint');
if ($rhinoPath === null || $jslintPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public function register()
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
* @return int
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If Javascript Lint ran into trouble.
*/
public function process(File $phpcsFile, $stackPtr)
{
$jslPath = Config::getExecutablePath('jsl');
if ($jslPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function process(File $phpcsFile, $stackPtr)
{
$analyzerPath = Config::getExecutablePath('zend_ca');
if ($analyzerPath === null) {
return;
return ($phpcsFile->numTokens + 1);
}

$fileName = $phpcsFile->getFilename();
Expand Down