Documentation

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
since
1.0.0

Table of Contents

Interfaces

Sniff

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
since
1.0.0

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
since
1.0.0

$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
since
1.0.0

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
since
1.0.0

register()

Returns an array of tokens this test wants to listen for.

public register() : array<string|int, int|string>
Tags
since
1.0.0
Return values
array<string|int, int|string>

        
On this page

Search results