\Horde\Refactor\RuleFileLevelDocBlock

Refactors a file to contain a (correct) file-level DocBlock.

If there is no file-level DocBlock, the first DocBlock is used as a template to create one.

If a file-level DocBlock exists, this one and the following the following first element-level DocBlock are checked for correct content.

If no DocBlock exists at all, a default is created. If you want your own defaults, extend this class and overwrite __construct().

Summary

Methods
Properties
Constants
__construct()
run()
dump()
__get()
addWarning()
pauseWarnings()
resumeWarnings()
autoload()
$warnings
No constants found
_addEmptyBlocks()
_checkDocBlocks()
_checkDocBlock()
_createFileLevelBlock()
_stripIncorrectText()
_getFileLevelDocBlock()
_getDocBlock()
_processDocBlockText()
_processDocBlock()
_fillTemplate()
$_config
$_tokens
$_warnings
$_first
$_second
$_firstBlock
$_secondBlock
$_extracted
N/A
No private methods found
No private properties found
N/A

Properties

$warnings

$warnings : array<mixed,string>

Warning messages.

Type

array<mixed,string>

$_config

$_config : \Horde\Refactor\Horde\Refactor\Config\Base

Rule configuration.

Type

\Horde\Refactor\Horde\Refactor\Config\Base

$_tokens

$_tokens : \Horde\Refactor\Horde\Refactor\Tokens

Current list of tokens.

Type

\Horde\Refactor\Horde\Refactor\Tokens

$_warnings

$_warnings : array<mixed,string>

A list of warning messages.

Type

array<mixed,string>

$_first

$_first : integer

Position of the first DocBlock.

Type

integer

$_second

$_second : integer

Position of the second DocBlock.

Type

integer

$_firstBlock

$_firstBlock : \phpDocumentor\Reflection\DocBlock

The first DocBlock.

Type

\phpDocumentor\Reflection\DocBlock

$_secondBlock

$_secondBlock : \phpDocumentor\Reflection\DocBlock

The second DocBlock.

Type

\phpDocumentor\Reflection\DocBlock

$_extracted

$_extracted : array

Extracted information from existing DocBlocks.

Type

array

Methods

__construct()

__construct(string  $file, \Horde\Refactor\Rule\Horde\Refactor\Config\Base  $config) 

Constructor.

Parameters

string $file

Name of the file to parse and refactor.

\Horde\Refactor\Rule\Horde\Refactor\Config\Base $config

The rule configuration.

run()

run() 

Applies the actual refactoring to the tokenized code.

dump()

dump() : string

Returns the file code in its current state.

Returns

string —

The file code.

__get()

__get(  $name) 

Getter.

Parameters

$name

addWarning()

addWarning(string  $warning) 

Adds a warning.

Parameters

string $warning

A warning.

pauseWarnings()

pauseWarnings() 

Pauses the logging of warnings and errors.

resumeWarnings()

resumeWarnings() 

Resumes the logging of warnings and errors.

autoload()

autoload() 

Autoload necessary libraries.

_addEmptyBlocks()

_addEmptyBlocks() 

Adds two default DocBlocks at the top of the file.

_checkDocBlocks()

_checkDocBlocks() 

Verifies the existing DocBlocks.

_checkDocBlock()

_checkDocBlock(string  $which) 

Verifies one of the existing DocBlocks.

Parameters

string $which

Which DocBlock to verify, either 'file' or 'class'.

_createFileLevelBlock()

_createFileLevelBlock() 

Creates a file-level DocBlock based on the first existing DocBlock.

_stripIncorrectText()

_stripIncorrectText(string  $text, string  $which) : string

Strips text from summary and description that belongs to the "other" block.

Parameters

string $text

The original text.

string $which

Which DocBlock to verify, either 'file' or 'class'.

Returns

string —

The cleaned text.

_getFileLevelDocBlock()

_getFileLevelDocBlock(array<mixed,\phpDocumentor\Reflection\DocBlock\Tag>  $tags) : \phpDocumentor\Reflection\DocBlock

Builds a default file-level DocBlock.

Parameters

array<mixed,\phpDocumentor\Reflection\DocBlock\Tag> $tags

Tags to add.

Returns

\phpDocumentor\Reflection\DocBlock —

A file-level DocBlock.

_getDocBlock()

_getDocBlock(\phpDocumentor\Reflection\DocBlock|string  $descriptions, array<mixed,\phpDocumentor\Reflection\DocBlock\Tag>  $tags) : \phpDocumentor\Reflection\DocBlock

Builds a DocBlock.

Parameters

\phpDocumentor\Reflection\DocBlock|string $descriptions

The DocBlock summary and description or the DocBlock to pull those from.

array<mixed,\phpDocumentor\Reflection\DocBlock\Tag> $tags

Tags to add.

Returns

\phpDocumentor\Reflection\DocBlock —

A DocBlock.

_processDocBlockText()

_processDocBlockText(\phpDocumentor\Reflection\DocBlock  $block, string  $which) 

Processes the summary and description of an existing DocBlock.

Parses any information out of the "other" block that might be required later.

Parameters

\phpDocumentor\Reflection\DocBlock $block

A DocBlock.

string $which

Which DocBlock to verify, either 'file' or 'class'.

_processDocBlock()

_processDocBlock(\phpDocumentor\Reflection\DocBlock  $block) 

Processes an existing DocBlock.

Parses any information out of the block that might be required later, and checks for different tag contents if processing the second block.

Parameters

\phpDocumentor\Reflection\DocBlock $block

A DocBlock.

_fillTemplate()

_fillTemplate(string|array  $template) : string

Fills out the placeholders in DocBlock templates.

Parameters

string|array $template

The template(s) to fill out.

Returns

string —

The filled template.