PhpUnitDedicateAssertFixer
extends AbstractPhpUnitFixer
in package
implements
ConfigurableFixerInterface
uses
ConfigurableFixerTrait
FinalYes
Tags
Table of Contents
Interfaces
Properties
- $fixMap : array<string, array{positive: string, negative: false|string, argument_count?: int, swap_arguments?: true}|true>
- $functions : array<int, string>
Methods
- getDefinition() : FixerDefinitionInterface
- Returns the definition of the fixer.
- getPriority() : int
- Returns the priority of the fixer.
- isRisky() : bool
- Check if fixer is risky or not.
- applyPhpUnitClassFix() : void
- configurePostNormalisation() : void
- createConfigurationDefinition() : FixerConfigurationResolverInterface
- cloneAndClearTokens() : array<int, Token>
- fixAssertSameEquals() : void
- fixAssertTrueFalse() : void
- fixAssertTrueFalseInstanceof() : bool
- getPreviousAssertCall() : iterable<string|int, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}>
- removeFunctionCall() : void
- swapArguments() : void
Properties
$fixMap
private
static array<string, array{positive: string, negative: false|string, argument_count?: int, swap_arguments?: true}|true>
$fixMap
= ['array_key_exists' => ['positive' => 'assertArrayHasKey', 'negative' => 'assertArrayNotHasKey', 'argument_count' => 2], 'empty' => ['positive' => 'assertEmpty', 'negative' => 'assertNotEmpty'], 'file_exists' => ['positive' => 'assertFileExists', 'negative' => 'assertFileNotExists'], 'is_array' => true, 'is_bool' => true, 'is_callable' => true, 'is_dir' => ['positive' => 'assertDirectoryExists', 'negative' => 'assertDirectoryNotExists'], 'is_double' => true, 'is_float' => true, 'is_infinite' => ['positive' => 'assertInfinite', 'negative' => 'assertFinite'], 'is_int' => true, 'is_integer' => true, 'is_long' => true, 'is_nan' => ['positive' => 'assertNan', 'negative' => false], 'is_null' => ['positive' => 'assertNull', 'negative' => 'assertNotNull'], 'is_numeric' => true, 'is_object' => true, 'is_readable' => ['positive' => 'assertIsReadable', 'negative' => 'assertNotIsReadable'], 'is_real' => true, 'is_resource' => true, 'is_scalar' => true, 'is_string' => true, 'is_writable' => ['positive' => 'assertIsWritable', 'negative' => 'assertNotIsWritable'], 'str_contains' => [
// since 7.5
'positive' => 'assertStringContainsString',
'negative' => 'assertStringNotContainsString',
'argument_count' => 2,
'swap_arguments' => true,
], 'str_ends_with' => [
// since 3.4
'positive' => 'assertStringEndsWith',
'negative' => 'assertStringEndsNotWith',
'argument_count' => 2,
'swap_arguments' => true,
], 'str_starts_with' => [
// since 3.4
'positive' => 'assertStringStartsWith',
'negative' => 'assertStringStartsNotWith',
'argument_count' => 2,
'swap_arguments' => true,
]]
$functions
private
array<int, string>
$functions
= []
Methods
getDefinition()
Returns the definition of the fixer.
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
Returns the priority of the fixer.
public
getPriority() : int
Must run before NoUnusedImportsFixer, PhpUnitDedicateAssertInternalTypeFixer. Must run after ModernizeStrposFixer, NoAliasFunctionsFixer, PhpUnitConstructFixer.
Return values
intisRisky()
Check if fixer is risky or not.
public
isRisky() : bool
Risky fixer could change code behavior!
Return values
boolapplyPhpUnitClassFix()
protected
applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex) : void
Parameters
- $tokens : Tokens
- $startIndex : int
- $endIndex : int
configurePostNormalisation()
protected
configurePostNormalisation() : void
createConfigurationDefinition()
protected
createConfigurationDefinition() : FixerConfigurationResolverInterface
Return values
FixerConfigurationResolverInterfacecloneAndClearTokens()
private
cloneAndClearTokens(Tokens $tokens, int $start, int $end) : array<int, Token>
Parameters
- $tokens : Tokens
- $start : int
- $end : int
Return values
array<int, Token>fixAssertSameEquals()
private
fixAssertSameEquals(Tokens $tokens, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int} $assertCall) : void
Parameters
- $tokens : Tokens
- $assertCall : array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}
fixAssertTrueFalse()
private
fixAssertTrueFalse(Tokens $tokens, ArgumentsAnalyzer $argumentsAnalyzer, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int} $assertCall) : void
Parameters
- $tokens : Tokens
- $argumentsAnalyzer : ArgumentsAnalyzer
- $assertCall : array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}
fixAssertTrueFalseInstanceof()
private
fixAssertTrueFalseInstanceof(Tokens $tokens, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int} $assertCall, int $testIndex) : bool
Parameters
- $tokens : Tokens
- $assertCall : array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}
- $testIndex : int
Return values
boolgetPreviousAssertCall()
private
getPreviousAssertCall(Tokens $tokens, int $startIndex, int $endIndex) : iterable<string|int, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}>
Parameters
- $tokens : Tokens
- $startIndex : int
- $endIndex : int
Return values
iterable<string|int, array{index: int, loweredName: string, openBraceIndex: int, closeBraceIndex: int}>removeFunctionCall()
private
removeFunctionCall(Tokens $tokens, int|null $callNSIndex, int $callIndex, int $openIndex, int $closeIndex) : void
Parameters
- $tokens : Tokens
- $callNSIndex : int|null
- $callIndex : int
- $openIndex : int
- $closeIndex : int
swapArguments()
private
swapArguments(Tokens $tokens, array<int, int> $argumentsIndices) : void
Parameters
- $tokens : Tokens
- $argumentsIndices : array<int, int>