Documentation

Reporter
in package

Manages reporting of errors and warnings.

Table of Contents

Properties

$config  : Config
The config data for the run.
$totalErrors  : int
Total number of errors found during the run.
$totalFiles  : int
Total number of files that contain errors or warnings.
$totalFixable  : int
$totalFixableErrors  : int
Total number of errors that can be fixed.
$totalFixableWarnings  : int
Total number of warnings that can be fixed.
$totalFixed  : int
$totalFixedErrors  : int
Total number of errors that were fixed.
$totalFixedWarnings  : int
Total number of warnings that were fixed.
$totalWarnings  : int
Total number of warnings found during the run.
$reports  : array<string|int, mixed>
A cache of report objects.
$tmpFiles  : array<string, string>
A cache of opened temporary files.

Methods

__construct()  : void
Initialise the reporter.
__get()  : int
Get the value of an inaccessible property.
__isset()  : bool
Check whether a (virtual) property is set.
__set()  : void
Setting a dynamic/virtual property on this class is not allowed.
__unset()  : void
Unsetting a dynamic/virtual property on this class is not allowed.
cacheFileReport()  : void
Caches the result of a single processed file for all reports.
prepareFileReport()  : array<string, string|int|array<string|int, mixed>>
Generate summary information to be used during report generation.
printReport()  : void
Generates and prints a single final report.
printReports()  : bool
Generates and prints final versions of all reports.

Properties

$totalErrors

Total number of errors found during the run.

public int $totalErrors = 0

$totalFiles

Total number of files that contain errors or warnings.

public int $totalFiles = 0

$totalFixable read-only

public int $totalFixable

Total number of errors/warnings that can be fixed.

$totalFixableErrors

Total number of errors that can be fixed.

public int $totalFixableErrors = 0

$totalFixableWarnings

Total number of warnings that can be fixed.

public int $totalFixableWarnings = 0

$totalFixed read-only

public int $totalFixed

Total number of errors/warnings that were fixed.

$totalFixedErrors

Total number of errors that were fixed.

public int $totalFixedErrors = 0

$totalFixedWarnings

Total number of warnings that were fixed.

public int $totalFixedWarnings = 0

$totalWarnings

Total number of warnings found during the run.

public int $totalWarnings = 0

$reports

A cache of report objects.

private array<string|int, mixed> $reports = []

$tmpFiles

A cache of opened temporary files.

private array<string, string> $tmpFiles = []

Methods

__construct()

Initialise the reporter.

public __construct(Config $config) : void

All reports specified in the config will be created and their output file (or a temp file if none is specified) initialised by clearing the current contents.

Parameters
$config : Config

The config data for the run.

Tags
throws
DeepExitException

If a custom report class could not be found.

throws
RuntimeException

If a report class is incorrectly set up.

__get()

Get the value of an inaccessible property.

public __get(string $name) : int

The properties supported via this method are both deprecated since PHP_CodeSniffer 4.0.

  • For $totalFixable, use ($reporter->totalFixableErrors + $reporter->totalFixableWarnings) instead.
  • For $totalFixed, use ($reporter->totalFixedErrors + $reporter->totalFixedWarnings) instead.
Parameters
$name : string

The name of the property.

Tags
throws
RuntimeException

If the setting name is invalid.

Return values
int

__isset()

Check whether a (virtual) property is set.

public __isset(string $name) : bool
Parameters
$name : string

Property name.

Return values
bool

__set()

Setting a dynamic/virtual property on this class is not allowed.

public __set(string $name, mixed $value) : void
Parameters
$name : string

Property name.

$value : mixed

Property value.

Tags
throws
RuntimeException

__unset()

Unsetting a dynamic/virtual property on this class is not allowed.

public __unset(string $name) : void
Parameters
$name : string

Property name.

Tags
throws
RuntimeException

cacheFileReport()

Caches the result of a single processed file for all reports.

public cacheFileReport(File $phpcsFile) : void

The report content that is generated is appended to the output file assigned to each report. This content may be an intermediate report format and not reflect the final report output.

Parameters
$phpcsFile : File

The file that has been processed.

prepareFileReport()

Generate summary information to be used during report generation.

public prepareFileReport(File $phpcsFile) : array<string, string|int|array<string|int, mixed>>
Parameters
$phpcsFile : File

The file that has been processed.

Return values
array<string, string|int|array<string|int, mixed>>

Prepared report data. The format of prepared data is as follows:

array(
  'filename' => string The name of the current file.
  'errors'   => int    The number of errors seen in the current file.
  'warnings' => int    The number of warnings seen in the current file.
  'fixable'  => int    The number of fixable issues seen in the current file.
  'messages' => array(
    int <Line number> => array(
      int <Column number> => array(
        int <Message index> => array(
          'message'  => string The error/warning message.
          'source'   => string The full error code for the message.
          'severity' => int    The severity of the message.
          'fixable'  => bool   Whether this error/warning is auto-fixable.
          'type'     => string The type of message. Either 'ERROR' or 'WARNING'.
        )
      )
    )
  )
)

printReport()

Generates and prints a single final report.

public printReport(string $report) : void
Parameters
$report : string

The report type to print.

printReports()

Generates and prints final versions of all reports.

public printReports() : bool

Returns TRUE if any of the reports output content to the screen or FALSE if all reports were silently printed to a file.

Return values
bool

        
On this page

Search results