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

Universal/Constants/ModifierKeywordOrder: defer to PHPCSUtils for modifier keywords #193

Merged
merged 1 commit into from
Dec 29, 2022
Merged
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
21 changes: 2 additions & 19 deletions Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Util\Tokens;
use PHPCSUtils\Tokens\Collections;
use PHPCSUtils\Utils\Scopes;

/**
Expand Down Expand Up @@ -65,17 +66,6 @@ final class ModifierKeywordOrderSniff implements Sniff
*/
public $order = self::FINAL_VISIBILITY;

/**
* Tokens which can be constant modifier keywords.
*
* @since 1.0.0
*
* @var array
*/
private $constantModifierKeywords = [
\T_FINAL => \T_FINAL,
];

/**
* Returns an array of tokens this test wants to listen for.
*
Expand All @@ -85,9 +75,6 @@ final class ModifierKeywordOrderSniff implements Sniff
*/
public function register()
{
// Add the visibility keywords to the constant modifier keywords.
$this->constantModifierKeywords += Tokens::$scopeModifiers;

return [\T_CONST];
}

Expand All @@ -108,12 +95,8 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

/*
* Note to self: This can be switched to use the `Collections::constantModifierKeywords()`
* method as of the next version of PHPCSUtils.
*/
$tokens = $phpcsFile->getTokens();
$valid = $this->constantModifierKeywords + Tokens::$emptyTokens;
$valid = Collections::constantModifierKeywords() + Tokens::$emptyTokens;

$finalPtr = false;
$visibilityPtr = false;
Expand Down