HumHub Documentation (unofficial)

PhpUnitDedicateAssertFixer extends AbstractPhpUnitFixer
in package
implements ConfigurableFixerInterface

FinalYes
Tags
author

Dariusz Rumiński dariusz.ruminski@gmail.com

Table of Contents

Interfaces

ConfigurableFixerInterface

Properties

$fixMap  : array<string, array{positive: string, negative: false|string, argument_count?: int, swap_arguments?: true}|true>
$functions  : array<int, string>

Methods

configure()  : void
Set configuration.
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
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, ]]

Methods

configure()

Set configuration.

public configure(array<string|int, mixed> $configuration) : void

New configuration must override current one, not patch it. Using empty array makes fixer to use default configuration (or reset configuration from previously configured back to default one).

Some fixers may have no configuration, then - simply don't implement this interface. Other ones may have configuration that will change behavior of fixer, eg php_unit_strict fixer allows to configure which methods should be fixed. Finally, some fixers need configuration to work, eg header_comment.

Parameters
$configuration : array<string|int, mixed>

configuration depends on Fixer

getPriority()

Returns the priority of the fixer.

public getPriority() : int

Must run before NoUnusedImportsFixer, PhpUnitDedicateAssertInternalTypeFixer. Must run after ModernizeStrposFixer, NoAliasFunctionsFixer, PhpUnitConstructFixer.

Return values
int

isRisky()

Check if fixer is risky or not.

public isRisky() : bool

Risky fixer could change code behavior!

Return values
bool

applyPhpUnitClassFix()

protected applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex) : void
Parameters
$tokens : Tokens
$startIndex : int
$endIndex : int

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
bool

getPreviousAssertCall()

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

        
On this page

Search results