StrictComparisonsSniff
in package
implements
Sniff
FinalYes
Enforce the use of strict comparisons.
Warning: the auto-fixer for this sniff may cause bugs in applications and should be used with care! This is considered a risky fix.
Tags
Table of Contents
Interfaces
Constants
- METRIC_NAME = 'Type of comparison used'
- Name of the metric.
Properties
- $metricType : array<int|string, string>
- The tokens this sniff records metrics for.
- $targetTokenInfo : array<int|string, array<string, string>>
- The tokens this sniff targets with error code and replacements.
Methods
- process() : void
- Processes this test, when one of its tokens is encountered.
- register() : array<string|int, int|string>
- Returns an array of tokens this test wants to listen for.
Constants
METRIC_NAME
Name of the metric.
public
string
METRIC_NAME
= 'Type of comparison used'
Tags
Properties
$metricType
The tokens this sniff records metrics for.
private
array<int|string, string>
$metricType
= [\T_IS_EQUAL => 'loose', \T_IS_NOT_EQUAL => 'loose', \T_IS_IDENTICAL => 'strict', \T_IS_NOT_IDENTICAL => 'strict']
Tags
$targetTokenInfo
The tokens this sniff targets with error code and replacements.
private
array<int|string, array<string, string>>
$targetTokenInfo
= [\T_IS_EQUAL => ['error_code' => 'LooseEqual', 'replacement' => '==='], \T_IS_NOT_EQUAL => ['error_code' => 'LooseNotEqual', 'replacement' => '!==']]
Tags
Methods
process()
Processes this test, when one of its tokens is encountered.
public
process(File $phpcsFile, int $stackPtr) : void
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the current token in the stack passed in $tokens.
Tags
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, int|string>