PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
slevomat
/
coding-standard
/
SlevomatCodingStandard
/
Sniffs
/
Classes
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Sniffs\Classes; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use SlevomatCodingStandard\Helpers\FixerHelper; use SlevomatCodingStandard\Helpers\TokenHelper; use function strtolower; use const T_DOUBLE_COLON; use const T_OPEN_PARENTHESIS; use const T_STATIC; use const T_STRING; class DisallowLateStaticBindingForConstantsSniff implements Sniff { public const CODE_DISALLOWED_LATE_STATIC_BINDING_FOR_CONSTANT = 'DisallowedLateStaticBindingForConstant'; /** * @return array<int, (int|string)> */ public function register(): array { return [ T_STATIC, ]; } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @param int $staticPointer */ public function process(File $phpcsFile, $staticPointer): void { $tokens = $phpcsFile->getTokens(); $doubleColonPointer = TokenHelper::findNextEffective($phpcsFile, $staticPointer + 1); if ($tokens[$doubleColonPointer]['code'] !== T_DOUBLE_COLON) { return; } $stringPointer = TokenHelper::findNextEffective($phpcsFile, $doubleColonPointer + 1); if ($tokens[$stringPointer]['code'] !== T_STRING) { return; } if (strtolower($tokens[$stringPointer]['content']) === 'class') { return; } $pointerAfterString = TokenHelper::findNextEffective($phpcsFile, $stringPointer + 1); if ($tokens[$pointerAfterString]['code'] === T_OPEN_PARENTHESIS) { return; } $fix = $phpcsFile->addFixableError( 'Late static binding for constants is disallowed.', $staticPointer, self::CODE_DISALLOWED_LATE_STATIC_BINDING_FOR_CONSTANT, ); if (!$fix) { return; } $phpcsFile->fixer->beginChangeset(); FixerHelper::replace($phpcsFile, $staticPointer, 'self'); $phpcsFile->fixer->endChangeset(); } }
[-] MethodSpacingSniff.php
[edit]
[-] PropertySpacingSniff.php
[edit]
[-] EmptyLinesAroundClassBracesSniff.php
[edit]
[-] ClassLengthSniff.php
[edit]
[-] DisallowConstructorPropertyPromotionSniff.php
[edit]
[+]
..
[-] AbstractPropertyConstantAndEnumCaseSpacing.php
[edit]
[-] ParentCallSpacingSniff.php
[edit]
[-] RequireAbstractOrFinalSniff.php
[edit]
[-] RequireSelfReferenceSniff.php
[edit]
[-] RequireConstructorPropertyPromotionSniff.php
[edit]
[-] TraitUseDeclarationSniff.php
[edit]
[-] ConstantSpacingSniff.php
[edit]
[-] ForbiddenPublicPropertySniff.php
[edit]
[-] ClassStructureSniff.php
[edit]
[-] BackedEnumTypeSpacingSniff.php
[edit]
[-] UnsupportedClassGroupException.php
[edit]
[-] SuperfluousAbstractClassNamingSniff.php
[edit]
[-] ClassConstantVisibilitySniff.php
[edit]
[-] SuperfluousTraitNamingSniff.php
[edit]
[-] SuperfluousExceptionNamingSniff.php
[edit]
[-] UselessLateStaticBindingSniff.php
[edit]
[-] AbstractMethodSignature.php
[edit]
[-] TraitUseSpacingSniff.php
[edit]
[-] DisallowMultiPropertyDefinitionSniff.php
[edit]
[-] SuperfluousErrorNamingSniff.php
[edit]
[-] DisallowStringExpressionPropertyFetchSniff.php
[edit]
[-] SuperfluousInterfaceNamingSniff.php
[edit]
[-] RequireSingleLineMethodSignatureSniff.php
[edit]
[-] DisallowLateStaticBindingForConstantsSniff.php
[edit]
[-] RequireMultiLineMethodSignatureSniff.php
[edit]
[-] PropertyDeclarationSniff.php
[edit]
[-] ClassMemberSpacingSniff.php
[edit]
[-] MissingClassGroupsException.php
[edit]
[-] DisallowMultiConstantDefinitionSniff.php
[edit]
[-] EnumCaseSpacingSniff.php
[edit]
[-] ModernClassNameReferenceSniff.php
[edit]