[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/RendererGenerators/PHP/ -> BranchOutputOptimizer.php (summary)

(no description)

File Size: 467 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BranchOutputOptimizer:: (17 methods):
  optimize()
  captureOutput()
  captureOutputExpression()
  captureStructure()
  isBranchToken()
  mergeIfBranches()
  mergeOutput()
  optimizeBranchesHead()
  optimizeBranchesOutput()
  optimizeBranchesTail()
  parseBranch()
  parseIfBlock()
  serializeBranch()
  serializeIfBlock()
  serializeOutput()
  serializeToken()
  skipOutputAssignment()


Class: BranchOutputOptimizer  - X-Ref


optimize(array $tokens)   X-Ref
Optimize the code used to output content

This method will go through the array of tokens, identify if/elseif/else blocks that contain
identical code at the beginning or the end and move the common code outside of the block

param: array $tokens Array of tokens from token_get_all()
return: string        Optimized code

captureOutput()   X-Ref
Capture the expressions used in any number of consecutive output statements

Starts looking at current index. Ends at the first token that's not part of an output
statement

return: string[]

captureOutputExpression()   X-Ref
Capture an expression used in output at current index

Ends on "." or ";"

return: string

captureStructure()   X-Ref
Capture the source of a control structure from its keyword to its opening brace

Ends after the brace, but the brace itself is not returned

return: string

isBranchToken()   X-Ref
Test whether the token at current index is an if/elseif/else token

return: bool

mergeIfBranches(array $branches)   X-Ref
Merge the branches of an if/elseif/else block

Returns an array that contains the following:

- before: array of PHP expressions to be output before the block
- source: PHP code for the if block
- after:  array of PHP expressions to be output after the block

param: array $branches
return: array

mergeOutput(array $left, array $right)   X-Ref
Merge two consecutive series of consecutive output expressions together

param: array $left  First series
param: array $right Second series
return: array        Merged series

optimizeBranchesHead(array &$branches)   X-Ref
Optimize the "head" part of a series of branches in-place

param: array    &$branches Array of branches, modified in-place
return: string[]            PHP expressions removed from the "head" part of the branches

optimizeBranchesOutput(array &$branches, $which)   X-Ref
Optimize the output of given branches

param: array    &$branches Array of branches
param: string    $which    Which end to optimize ("head" or "tail")
return: string[]            PHP expressions removed from the given part of the branches

optimizeBranchesTail(array &$branches)   X-Ref
Optimize the "tail" part of a series of branches in-place

param: array    &$branches Array of branches, modified in-place
return: string[]            PHP expressions removed from the "tail" part of the branches

parseBranch()   X-Ref
Parse the if, elseif or else branch starting at current index

Ends at the last }

return: array Branch's data ("structure", "head", "body", "tail")

parseIfBlock()   X-Ref
Parse the if block (including elseif/else branches) starting at current index

return: array

serializeBranch(array $branch)   X-Ref
Serialize a recorded branch back to PHP

param: array  $branch
return: string

serializeIfBlock(array $block)   X-Ref
Serialize a series of recorded branch back to PHP

param: array  $block
return: string

serializeOutput(array $expressions)   X-Ref
Serialize a series of output expressions

param: string[] $expressions Array of PHP expressions
return: string                PHP code used to append given expressions to the output

serializeToken($token)   X-Ref
Serialize a token back to PHP

param: array|string $token Token from token_get_all()
return: string              PHP code

skipOutputAssignment()   X-Ref
Attempt to move past output assignment at current index

return: bool Whether if an output assignment was skipped



Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1