Documentation

EchoTagSyntaxFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Michele Locati michele@locati.it

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

phpstan-type

_AutogeneratedInputConfiguration array{ format?: 'long'|'short', long_function?: 'echo'|'print', shorten_simple_statements_only?: bool }

phpstan-type

_AutogeneratedComputedConfiguration array{ format: 'long'|'short', long_function: 'echo'|'print', shorten_simple_statements_only: bool }

Table of Contents

Interfaces

ConfigurableFixerInterface

Constants

SUPPORTED_FORMAT_OPTIONS  = [self::FORMAT_LONG, self::FORMAT_SHORT]
SUPPORTED_LONGFUNCTION_OPTIONS  = [self::LONG_FUNCTION_ECHO, self::LONG_FUNCTION_PRINT]

Methods

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
buildLongToShortTokens()  : array<int, Token>
Builds the list of tokens that replace a long echo sequence.
isComplexCode()  : bool
Check if $tokens, starting at $index, contains "complex code", that is, the content of the echo tag contains more than a simple "echo something".
longToShort()  : void
shortToLong()  : void

Constants

SUPPORTED_FORMAT_OPTIONS

private mixed SUPPORTED_FORMAT_OPTIONS = [self::FORMAT_LONG, self::FORMAT_SHORT]

SUPPORTED_LONGFUNCTION_OPTIONS

private mixed SUPPORTED_LONGFUNCTION_OPTIONS = [self::LONG_FUNCTION_ECHO, self::LONG_FUNCTION_PRINT]

Methods

getPriority()

Returns the priority of the fixer.

public getPriority() : int

Must run before NoMixedEchoPrintFixer.

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

buildLongToShortTokens()

Builds the list of tokens that replace a long echo sequence.

private buildLongToShortTokens(Tokens $tokens, int $openTagIndex, int $echoTagIndex) : array<int, Token>
Parameters
$tokens : Tokens
$openTagIndex : int
$echoTagIndex : int
Return values
array<int, Token>

isComplexCode()

Check if $tokens, starting at $index, contains "complex code", that is, the content of the echo tag contains more than a simple "echo something".

private isComplexCode(Tokens $tokens, int $index) : bool

This is done by a very quick test: if the tag contains non-whitespace tokens after a semicolon, we consider it as "complex".

Parameters
$tokens : Tokens
$index : int
Tags
example

<?php echo 1 ?> is false (not complex)

example

<?php echo 'hello' . 'world'; ?> is false (not "complex")

example

<?php echo 2; $set = 3 ?> is true ("complex")

Return values
bool

        
On this page

Search results