UserFrosting API

WhoopsRenderer extends ErrorRenderer

[abstract description].

Table of Contents

$searchPaths Search paths to be scanned for resources, in the reverse order they're declared. array
$resourceCache Fast lookup cache for known resource locations. array
$customCss The name of the custom css file. string
$extraTables array[]
$handleUnconditionally bool
$pageTitle string
$applicationPaths array[]
$blacklist array[]
$editor A string identifier for a known IDE/text editor, or a closure that resolves a string that can be used to open a given file in an editor. If the string contains the special substrings %file or %line, they will be replaced with the correct data. mixed
$editors A list of known editor strings. array
$inspector Inspector
$templateHelper TemplateHelper
$request ServerRequestInterface
$response ResponseInterface
$exception Throwable
$displayErrorDetails Tells the renderer whether or not to output detailed error information to the client. bool
__construct() Create a new ErrorRenderer object. mixed
render() string
addDataTable() Adds an entry to the list of tables displayed in the template. mixed
addDataTableCallback() Lazily adds an entry to the list of tables displayed in the table. mixed
blacklist() blacklist a sensitive value within one of the superglobal arrays. mixed
getDataTables() Returns all the extra data tables registered with this handler. array[]|callable
handleUnconditionally() Allows to disable all attempts to dynamically decide whether to handle or return prematurely. bool|null
addEditor() Adds an editor resolver, identified by a string name, and that may be a string path, or a callable resolver. If the callable returns a string, it will be set as the file reference's href attribute. mixed
setEditor() Set the editor to use to open referenced files, by a string identifier, or a callable that will be executed for every file reference, with a $file and $line argument, and should return a string. mixed
getEditorHref() Given a string file path, and an integer file line, executes the editor resolver and returns, if available, a string that may be used as the href property for that file reference. string|bool
getEditorAjax() Given a boolean if the editor link should act as an Ajax request. The editor must be a valid callable function/closure. bool
setPageTitle() mixed
getPageTitle() string
addResourcePath() Adds a path to the list of paths to be searched for resources. mixed
addCustomCss() Adds a custom css file to be loaded. mixed
getResourcePaths() array
getResourcesPath() string
setResourcesPath() mixed
getApplicationPaths() Return the application paths. array
setApplicationPaths() Set the application paths. mixed
setApplicationRootPath() Set the application root path. mixed
getEditor() Given a boolean if the editor link should act as an Ajax request. The editor must be a valid callable function/closure. array
getException() Throwable
getInspector() Inspector
getResource() Finds a resource, by its relative path, in all available search paths. string
masked() Checks all values within the given superGlobal array. array
__construct() Create a new ErrorRenderer object. mixed
render() string
renderWithBody() Body

Properties

$searchPaths

Search paths to be scanned for resources, in the reverse order they're declared.

private array $searchPaths = []

$resourceCache

Fast lookup cache for known resource locations.

private array $resourceCache = []

$customCss

The name of the custom css file.

private string $customCss = null

$handleUnconditionally

private bool $handleUnconditionally = false

$pageTitle

private string $pageTitle = 'Whoops! There was an error.'

$blacklist

private array[] $blacklist = ['_GET' => [], '_POST' => [], '_FILES' => [], '_COOKIE' => [], '_SESSION' => [], '_SERVER' => ['DB_PASSWORD', 'SMTP_PASSWORD'], '_ENV' => ['DB_PASSWORD', 'SMTP_PASSWORD']]

$editor

A string identifier for a known IDE/text editor, or a closure that resolves a string that can be used to open a given file in an editor. If the string contains the special substrings %file or %line, they will be replaced with the correct data.

protected mixed $editor
Tags
example

"txmt://open?url=%file&line=%line"

$editors

A list of known editor strings.

protected array $editors = ['sublime' => 'subl://open?url=file://%file&line=%line', 'textmate' => 'txmt://open?url=file://%file&line=%line', 'emacs' => 'emacs://open?url=file://%file&line=%line', 'macvim' => 'mvim://open/?url=file://%file&line=%line', 'phpstorm' => 'phpstorm://open?file=%file&line=%line', 'idea' => 'idea://open?file=%file&line=%line']

$displayErrorDetails

Tells the renderer whether or not to output detailed error information to the client.

protected bool $displayErrorDetails
Each renderer may choose if and how to implement this.

Methods

__construct()

Create a new ErrorRenderer object.

public __construct( $request : ServerRequestInterface , $response : ResponseInterface , $exception : mixed [, $displayErrorDetails : mixed = false ] ) : mixed
Parameters
$request : ServerRequestInterface

The most recent Request object

$response : ResponseInterface

The most recent Response object

$exception : mixed

The caught Exception object

$displayErrorDetails : mixed = false
Return values
mixed

addDataTable()

Adds an entry to the list of tables displayed in the template.

public addDataTable( $label : string , $data : array ) : mixed

The expected data is a simple associative array. Any nested arrays will be flattened with print_r.

Parameters
$label : string
$data : array
Return values
mixed

addDataTableCallback()

Lazily adds an entry to the list of tables displayed in the table.

public addDataTableCallback( $label : string , $callback : callable ) : mixed

The supplied callback argument will be called when the error is rendered, it should produce a simple associative array. Any nested arrays will be flattened with print_r.

Parameters
$label : string
$callback : callable

Callable returning an associative array

Tags
throws
InvalidArgumentException

If $callback is not callable

Return values
mixed

blacklist()

blacklist a sensitive value within one of the superglobal arrays.

public blacklist( $superGlobalName : string , $key : string ) : mixed
Parameters
$superGlobalName : string

The name of the superglobal array, e.g. '_GET'

$key : string

The key within the superglobal

Return values
mixed

getDataTables()

Returns all the extra data tables registered with this handler.

public getDataTables( [ $label : string|null = null ] ) : array[]|callable

Optionally accepts a 'label' parameter, to only return the data table under that label.

Parameters
$label : string|null = null
Return values
array[]|callable

handleUnconditionally()

Allows to disable all attempts to dynamically decide whether to handle or return prematurely.

public handleUnconditionally( [ $value : bool|null = null ] ) : bool|null

Set this to ensure that the handler will perform no matter what.

Parameters
$value : bool|null = null
Return values
bool|null

addEditor()

Adds an editor resolver, identified by a string name, and that may be a string path, or a callable resolver. If the callable returns a string, it will be set as the file reference's href attribute.

public addEditor( $identifier : string , $resolver : string ) : mixed
Parameters
$identifier : string
$resolver : string
Tags
example

$run->addEditor('macvim', "mvim://open?url=file://%file&line=%line")

example

$run->addEditor('remove-it', function($file, $line) { unlink($file); return "http://stackoverflow.com"; });

Return values
mixed

setEditor()

Set the editor to use to open referenced files, by a string identifier, or a callable that will be executed for every file reference, with a $file and $line argument, and should return a string.

public setEditor( $editor : string|callable ) : mixed
Parameters
$editor : string|callable
Tags
example

$run->setEditor(function($file, $line) { return "file:///{$file}"; });

example

$run->setEditor('sublime');

throws
InvalidArgumentException

If invalid argument identifier provided

Return values
mixed

getEditorHref()

Given a string file path, and an integer file line, executes the editor resolver and returns, if available, a string that may be used as the href property for that file reference.

public getEditorHref( $filePath : string , $line : int ) : string|bool
Parameters
$filePath : string
$line : int
Tags
throws
InvalidArgumentException

If editor resolver does not return a string

Return values
string|bool

getEditorAjax()

Given a boolean if the editor link should act as an Ajax request. The editor must be a valid callable function/closure.

public getEditorAjax( $filePath : string , $line : int ) : bool
Parameters
$filePath : string
$line : int
Tags
throws
UnexpectedValueException

If editor resolver does not return a boolean

Return values
bool

setPageTitle()

public setPageTitle( $title : string ) : mixed
Parameters
$title : string
Return values
mixed

getPageTitle()

public getPageTitle( ) : string
Return values
string

addResourcePath()

Adds a path to the list of paths to be searched for resources.

public addResourcePath( $path : string ) : mixed
Parameters
$path : string
Tags
throws
InvalidArgumentException

If $path is not a valid directory

Return values
mixed

addCustomCss()

Adds a custom css file to be loaded.

public addCustomCss( $name : string ) : mixed
Parameters
$name : string
Return values
mixed

getResourcePaths()

public getResourcePaths( ) : array
Return values
array

getResourcesPath()

public getResourcesPath( ) : string
Tags
deprecated
Return values
string

setResourcesPath()

public setResourcesPath( $resourcesPath : string ) : mixed
Parameters
$resourcesPath : string
Tags
deprecated
Return values
mixed

getApplicationPaths()

Return the application paths.

public getApplicationPaths( ) : array
Return values
array

setApplicationPaths()

Set the application paths.

public setApplicationPaths( $applicationPaths : array ) : mixed
Parameters
$applicationPaths : array
Return values
mixed

setApplicationRootPath()

Set the application root path.

public setApplicationRootPath( $applicationRootPath : string ) : mixed
Parameters
$applicationRootPath : string
Return values
mixed

getEditor()

Given a boolean if the editor link should act as an Ajax request. The editor must be a valid callable function/closure.

protected getEditor( $filePath : string , $line : int ) : array
Parameters
$filePath : string
$line : int
Return values
array

getException()

protected getException( ) : Throwable
Return values
Throwable

getInspector()

protected getInspector( ) : Inspector
Return values
Inspector

getResource()

Finds a resource, by its relative path, in all available search paths.

protected getResource( $resource : string ) : string

The search is performed starting at the last search path, and all the way back to the first, enabling a cascading-type system of overrides for all resources.

Parameters
$resource : string
Tags
throws
RuntimeException

If resource cannot be found in any of the available paths

Return values
string

masked()

Checks all values within the given superGlobal array.

private masked( $superGlobal : array , $superGlobalName : string ) : array

Blacklisted values will be replaced by a equal length string cointaining only '*' characters.

We intentionally dont rely on $GLOBALS as it depends on 'auto_globals_jit' php.ini setting.

Parameters
$superGlobal : array

One of the superglobal arrays

$superGlobalName : string

the name of the superglobal array, e.g. '_GET'

Return values
array

$values without sensitive data

__construct()

Create a new ErrorRenderer object.

public __construct( $request : ServerRequestInterface , $response : ResponseInterface , $exception : Throwable [, $displayErrorDetails : bool = false ] ) : mixed
Parameters
$request : ServerRequestInterface

The most recent Request object

$response : ResponseInterface

The most recent Response object

$exception : Throwable

The caught Exception object

$displayErrorDetails : bool = false
Return values
mixed

render()

public abstract render( ) : string
Return values
string

renderWithBody()

public renderWithBody( ) : Body
Return values
Body

Search results