Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed Aug 25, 2023
1 parent 9bf1e9c commit 2ec02f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Inpsyde/Sniffs/CodeQuality/ArgumentTypeDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ public function process(File $phpcsFile, $stackPtr): void
// phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
// phpcs:enable Generic.Metrics.CyclomaticComplexity

if ($this->shouldIgnore($phpcsFile, $stackPtr)) {
/** @var array<int, array<string, mixed>> $tokens */
$tokens = $phpcsFile->getTokens();

if ($this->shouldIgnore($phpcsFile, $stackPtr, $tokens)) {
return;
}

/** @var array<int, array<string, mixed>> $tokens */
$tokens = $phpcsFile->getTokens();
$paramsStart = (int)($tokens[$stackPtr]['parenthesis_opener'] ?? 0);
$paramsEnd = (int)($tokens[$stackPtr]['parenthesis_closer'] ?? 0);

Expand Down Expand Up @@ -91,15 +92,17 @@ public function process(File $phpcsFile, $stackPtr): void
/**
* @param File $phpcsFile
* @param int $stackPtr
* @param array<int, array<string, mixed>> $tokens
* @return bool
*
* phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration
*/
private function shouldIgnore(File $phpcsFile, $stackPtr): bool
private function shouldIgnore(File $phpcsFile, $stackPtr, array $tokens): bool
{
// phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration

$name = $phpcsFile->getDeclarationName($stackPtr);
$tokenCode = $tokens[$stackPtr]['code'] ?? '';
$name = ($tokenCode !== T_FN) ? ($phpcsFile->getDeclarationName($stackPtr) ?: '') : '';

return PhpcsHelpers::functionIsArrayAccess($phpcsFile, $stackPtr)
|| PhpcsHelpers::isHookClosure($phpcsFile, $stackPtr)
Expand Down

0 comments on commit 2ec02f5

Please sign in to comment.