Documentation

NoUnneededControlParenthesesFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Sullivan Senechal soullivaneuh@gmail.com

author

Dariusz Rumiński dariusz.ruminski@gmail.com

author

Gregor Harlan gharlan@web.de

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

phpstan-type

_AutogeneratedInputConfiguration array{ statements?: list<'break'|'clone'|'continue'|'echo_print'|'negative_instanceof'|'others'|'return'|'switch_case'|'yield'|'yield_from'> }

phpstan-type

_AutogeneratedComputedConfiguration array{ statements: list<'break'|'clone'|'continue'|'echo_print'|'negative_instanceof'|'others'|'return'|'switch_case'|'yield'|'yield_from'> }

Table of Contents

Interfaces

ConfigurableFixerInterface

Constants

BEFORE_TYPES  = [ ';', '{', [T_OPEN_TAG], [T_OPEN_TAG_WITH_ECHO], [T_ECHO], [T_PRINT], [T_RETURN], [T_THROW], [T_YIELD], [T_YIELD_FROM], [T_BREAK], [T_CONTINUE], // won't be fixed, but true in concept, helpful for fast check [T_REQUIRE], [T_REQUIRE_ONCE], [T_INCLUDE], [T_INCLUDE_ONCE], ]
BLOCK_TYPES  = [\PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_CURLY_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DESTRUCTURING_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DYNAMIC_PROP_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_PARENTHESIS_BRACE]
CONFIG_OPTIONS  = ['break', 'clone', 'continue', 'echo_print', 'negative_instanceof', 'others', 'return', 'switch_case', 'yield', 'yield_from']
TOKEN_TYPE_CONFIG_MAP  = [T_BREAK => 'break', T_CASE => 'switch_case', T_CONTINUE => 'continue', T_ECHO => 'echo_print', T_PRINT => 'echo_print', T_RETURN => 'return', T_YIELD => 'yield', T_YIELD_FROM => 'yield_from']
TOKEN_TYPE_NO_CONFIG  = [T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE]

Properties

$noopTypes  : array<int, array{: int}|string>
$tokensAnalyzer  : TokensAnalyzer

Methods

__construct()  : mixed
getDefinition()  : FixerDefinitionInterface
Returns the definition of the fixer.
getPriority()  : int
Returns the priority of the fixer.
isCandidate()  : bool
Check if the fixer is a candidate for given Tokens collection.
applyFix()  : void
createConfigurationDefinition()  : FixerConfigurationResolverInterface
closeCurlyBelongsToDynamicElement()  : bool
containsOperation()  : bool
getAfterAccess()  : int
getBeforePreUnaryOperation()  : int
getBlock()  : null|Tokens::BLOCK_TYPE_*, isStart: bool}
getConfigType()  : string|null
getIndexOfInstanceOfStatement()  : int|null
isAccess()  : bool
isCloneStatement()  : bool
isExitStatement()  : bool
isKnownNegativePre()  : bool
isPreUnaryOperation()  : bool
isSimpleAssignment()  : bool
isSingleStatement()  : bool
isUselessWrapped()  : bool
isWrappedCloneArgument()  : bool
isWrappedFnBody()  : bool
isWrappedForElement()  : bool
isWrappedInstanceOf()  : bool
isWrappedLanguageConstructArgument()  : bool
isWrappedPartOfOperation()  : bool
isWrappedSequenceElement()  : bool
removeBrace()  : void
removeUselessParenthesisPair()  : void

Constants

BEFORE_TYPES

private mixed BEFORE_TYPES = [ ';', '{', [T_OPEN_TAG], [T_OPEN_TAG_WITH_ECHO], [T_ECHO], [T_PRINT], [T_RETURN], [T_THROW], [T_YIELD], [T_YIELD_FROM], [T_BREAK], [T_CONTINUE], // won't be fixed, but true in concept, helpful for fast check [T_REQUIRE], [T_REQUIRE_ONCE], [T_INCLUDE], [T_INCLUDE_ONCE], ]

BLOCK_TYPES

private array<int, int> BLOCK_TYPES = [\PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_CURLY_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DESTRUCTURING_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DYNAMIC_PROP_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE, \PhpCsFixer\Tokenizer\Tokens::BLOCK_TYPE_PARENTHESIS_BRACE]

CONFIG_OPTIONS

private mixed CONFIG_OPTIONS = ['break', 'clone', 'continue', 'echo_print', 'negative_instanceof', 'others', 'return', 'switch_case', 'yield', 'yield_from']

TOKEN_TYPE_CONFIG_MAP

private mixed TOKEN_TYPE_CONFIG_MAP = [T_BREAK => 'break', T_CASE => 'switch_case', T_CONTINUE => 'continue', T_ECHO => 'echo_print', T_PRINT => 'echo_print', T_RETURN => 'return', T_YIELD => 'yield', T_YIELD_FROM => 'yield_from']

Properties

Methods

getPriority()

Returns the priority of the fixer.

public getPriority() : int

Must run before ConcatSpaceFixer, NoTrailingWhitespaceFixer. Must run after ModernizeTypesCastingFixer, NoAlternativeSyntaxFixer.

Return values
int

isCandidate()

Check if the fixer is a candidate for given Tokens collection.

public isCandidate(Tokens $tokens) : bool

Fixer is a candidate when the collection contains tokens that may be fixed during fixer work. This could be considered as some kind of bloom filter. When this method returns true then to the Tokens collection may or may not need a fixing, but when this method returns false then the Tokens collection need no fixing for sure.

Parameters
$tokens : Tokens
Return values
bool

getBlock()

private getBlock(Tokens $tokens, int $index, bool $isStart) : null|Tokens::BLOCK_TYPE_*, isStart: bool}
Parameters
$tokens : Tokens
$index : int
$isStart : bool
Return values
null|Tokens::BLOCK_TYPE_*, isStart: bool}

getIndexOfInstanceOfStatement()

private getIndexOfInstanceOfStatement(Tokens $tokens, int $openIndex, int $closeIndex) : int|null
Parameters
$tokens : Tokens
$openIndex : int
$closeIndex : int
Return values
int|null

isSimpleAssignment()

private isSimpleAssignment(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isSingleStatement()

private isSingleStatement(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isUselessWrapped()

private isUselessWrapped(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedCloneArgument()

private isWrappedCloneArgument(Tokens $tokens, int $beforeOpenIndex, int $openIndex, int $closeIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$openIndex : int
$closeIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedFnBody()

private isWrappedFnBody(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedForElement()

private isWrappedForElement(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedInstanceOf()

private isWrappedInstanceOf(Tokens $tokens, int $instanceOfIndex, int $beforeOpenIndex, int $openIndex, int $closeIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$instanceOfIndex : int
$beforeOpenIndex : int
$openIndex : int
$closeIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedLanguageConstructArgument()

private isWrappedLanguageConstructArgument(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
Return values
bool

isWrappedPartOfOperation()

private isWrappedPartOfOperation(Tokens $tokens, int $beforeOpenIndex, int $openIndex, int $closeIndex, int $afterCloseIndex) : bool
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$openIndex : int
$closeIndex : int
$afterCloseIndex : int
Return values
bool

removeUselessParenthesisPair()

private removeUselessParenthesisPair(Tokens $tokens, int $beforeOpenIndex, int $afterCloseIndex, int $openIndex, int $closeIndex, string|null $configType) : void
Parameters
$tokens : Tokens
$beforeOpenIndex : int
$afterCloseIndex : int
$openIndex : int
$closeIndex : int
$configType : string|null

        
On this page

Search results