Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace InfinityloopCodingStandard\Sniffs\Classes;

use \SlevomatCodingStandard\Helpers\FunctionHelper;
use \SlevomatCodingStandard\Helpers\SniffSettingsHelper;
use \SlevomatCodingStandard\Helpers\TokenHelper;

class ConstructorPropertyPromotionSpacingSniff implements \PHP_CodeSniffer\Sniffs\Sniff
{
public const CONSTRUCTOR_PARAMETER_SAME_LINE = 'ConstructorParametersOnSameLine';
Expand All @@ -15,19 +19,19 @@ public function register() : array

public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer) : void
{
if (!\SlevomatCodingStandard\Helpers\SniffSettingsHelper::isEnabledByPhpVersion(null, 80000)) {
if (!SniffSettingsHelper::isEnabledByPhpVersion(null, 80000)) {
return;
}

$tokens = $phpcsFile->getTokens();

$namePointer = \SlevomatCodingStandard\Helpers\TokenHelper::findNextEffective($phpcsFile, $functionPointer + 1);
$namePointer = TokenHelper::findNextEffective($phpcsFile, $functionPointer + 1);

if (\strtolower($tokens[$namePointer]['content']) !== '__construct') {
return;
}

if (\SlevomatCodingStandard\Helpers\FunctionHelper::isAbstract($phpcsFile, $functionPointer)) {
if (FunctionHelper::isAbstract($phpcsFile, $functionPointer)) {
return;
}

Expand All @@ -40,13 +44,13 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
$containsPropertyPromotion = false;

foreach ($parameterPointers as $parameterPointer) {
$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
$pointerBefore = TokenHelper::findPrevious(
$phpcsFile,
[\T_COMMA, \T_OPEN_PARENTHESIS],
$parameterPointer - 1,
);

$visibilityPointer = \SlevomatCodingStandard\Helpers\TokenHelper::findNextEffective($phpcsFile, $pointerBefore + 1);
$visibilityPointer = TokenHelper::findNextEffective($phpcsFile, $pointerBefore + 1);

if (\in_array($tokens[$visibilityPointer]['code'], \PHP_CodeSniffer\Util\Tokens::$scopeModifiers, true)) {
$containsPropertyPromotion = true;
Expand All @@ -58,7 +62,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
}

if (\count($parameterPointers) === 1) {
$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
$pointerBefore = TokenHelper::findPrevious(
$phpcsFile,
[\T_COMMA, \T_OPEN_PARENTHESIS],
$parameterPointers[0],
Expand Down Expand Up @@ -110,7 +114,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer

$phpcsFile->fixer->beginChangeset();

$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
$pointerBefore = TokenHelper::findPrevious(
$phpcsFile,
[\T_COMMA, \T_OPEN_PARENTHESIS],
$parameterPointer - 1,
Expand All @@ -126,7 +130,7 @@ private function getParameterPointers(\PHP_CodeSniffer\Files\File $phpcsFile, in
{
$tokens = $phpcsFile->getTokens();

return \SlevomatCodingStandard\Helpers\TokenHelper::findNextAll(
return TokenHelper::findNextAll(
$phpcsFile,
\T_VARIABLE,
$tokens[$functionPointer]['parenthesis_opener'] + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace InfinityloopCodingStandard\Sniffs\ControlStructures;

use \PHP_CodeSniffer\Files\File;
use \SlevomatCodingStandard\Helpers\TokenHelper;

class RequireMultiLineNullCoalesceSniff implements \PHP_CodeSniffer\Sniffs\Sniff
Expand All @@ -24,7 +25,7 @@ public function register() : array
}

//@phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $coalescePointer) : void
public function process(File $phpcsFile, $coalescePointer) : void
{
$tokens = $phpcsFile->getTokens();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace InfinityloopCodingStandard\Sniffs\ControlStructures;

use \PHP_CodeSniffer\Files\File;
use \SlevomatCodingStandard\Helpers\TokenHelper;

class SwitchCommentSpacingSniff implements \PHP_CodeSniffer\Sniffs\Sniff
Expand All @@ -21,7 +22,7 @@ public function register() : array
}

//@phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) : void
public function process(File $phpcsFile, $stackPtr) : void
{
$tokens = $phpcsFile->getTokens();

Expand Down Expand Up @@ -127,7 +128,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) : voi
}
}

private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, int|bool|null $stackPtr, ?int $end = null) : bool|int
private function findNextCase(File $phpcsFile, int|bool|null $stackPtr, ?int $end = null) : bool|int
{
$tokens = $phpcsFile->getTokens();

Expand All @@ -145,7 +146,7 @@ private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, int|bool|n
return $stackPtr;
}

private function getEndOfLineBefore(\PHP_CodeSniffer\Files\File $phpcsFile, int $pointer) : int
private function getEndOfLineBefore(File $phpcsFile, int $pointer) : int
{
$tokens = $phpcsFile->getTokens();

Expand Down Expand Up @@ -193,7 +194,7 @@ private function getEndOfLineBefore(\PHP_CodeSniffer\Files\File $phpcsFile, int
return $endOfLineBefore;
}

private function getIndentation(\PHP_CodeSniffer\Files\File $phpcsFile, int $endOfLinePointer) : string
private function getIndentation(File $phpcsFile, int $endOfLinePointer) : string
{
$pointerAfterWhitespace = TokenHelper::findNextExcluding($phpcsFile, \T_WHITESPACE, $endOfLinePointer + 1);
$actualIndentation = TokenHelper::getContent($phpcsFile, $endOfLinePointer + 1, $pointerAfterWhitespace - 1);
Expand Down
Loading