PrettyPageHandler
extends Handler
in package
Abstract implementation of a Handler.
Table of Contents
Constants
- DONE = 0x10
- EDITOR_ATOM = "atom"
- EDITOR_EMACS = "emacs"
- EDITOR_ESPRESSO = "espresso"
- EDITOR_IDEA = "idea"
- EDITOR_MACVIM = "macvim"
- EDITOR_NETBEANS = "netbeans"
- EDITOR_PHPSTORM = "phpstorm"
- EDITOR_SUBLIME = "sublime"
- EDITOR_TEXTMATE = "textmate"
- EDITOR_VSCODE = "vscode"
- EDITOR_XDEBUG = "xdebug"
- LAST_HANDLER = 0x20
- The Handler has handled the Throwable in some way, and wishes to skip any other Handler.
- QUIT = 0x30
- The Handler has handled the Throwable in some way, and wishes to quit/stop execution
Properties
- $editor : callable|string
- An identifier for a known IDE/text editor.
- $editors : array<string|int, mixed>
- A list of known editor strings.
- $templateHelper : TemplateHelper
- $applicationPaths : array<string|int, array<string|int, mixed>>
- $blacklist : array<string|int, array<string|int, mixed>>
- $customCss : string|null
- The name of the custom css file.
- $customJs : string|null
- The name of the custom js file.
- $exception : Throwable
- $extraTables : array<string|int, array<string|int, mixed>>
- $handleUnconditionally : bool
- $inspector : Inspector
- $pageTitle : string
- $resourceCache : array<string|int, mixed>
- Fast lookup cache for known resource locations.
- $run : RunInterface
- $searchPaths : array<string|int, mixed>
- Search paths to be scanned for resources.
Methods
- __construct() : void
- Constructor.
- addCustomCss() : static
- Adds a custom css file to be loaded.
- addCustomJs() : static
- Adds a custom js file to be loaded.
- addDataTable() : static
- Adds an entry to the list of tables displayed in the template.
- addDataTableCallback() : static
- Lazily adds an entry to the list of tables displayed in the table.
- addEditor() : static
- Adds an editor resolver.
- addResourcePath() : static
- Adds a path to the list of paths to be searched for resources.
- blacklist() : static
- blacklist a sensitive value within one of the superglobal arrays.
- contentType() : string
- getApplicationPaths() : array<string|int, mixed>
- Return the application paths.
- getDataTables() : array<string|int, array<string|int, mixed>>|callable
- Returns all the extra data tables registered with this handler.
- getEditorAjax() : bool
- Determine if the editor link should act as an Ajax request.
- getEditorHref() : string|bool
- Get the editor href for a given file and line, if available.
- getPageTitle() : string
- Get the page title.
- getResourcePaths() : array<string|int, mixed>
- getResourcesPath() : string
- handle() : int|null
- handleUnconditionally() : bool|static
- Set whether to handle unconditionally.
- hideSuperglobalKey() : static
- Hide a sensitive value within one of the superglobal arrays.
- isLocal() : bool
- is Local Environment Check if the application is running in a local environment.
- setApplicationPaths() : void
- Set the application paths.
- setApplicationRootPath() : void
- Set the application root path.
- setEditor() : static
- Set the editor to use to open referenced files.
- setException() : void
- setInspector() : void
- setPageTitle() : static
- Set the page title.
- setResourcesPath() : static
- setRun() : void
- getEditor() : array<string|int, mixed>
- Determines both the editor and if ajax should be used.
- getException() : Throwable
- getExceptionCode() : string
- Get the code of the exception currently being handled.
- getExceptionFrames() : FrameCollection
- Get the stack trace frames of the exception currently being handled.
- getInspector() : Inspector
- getResource() : string
- Finds a resource, by its relative path, in all available search paths.
- getRun() : RunInterface
- masked() : array<string|int, mixed>
- Checks all values within the given superGlobal array.
Constants
DONE
public
mixed
DONE
= 0x10
EDITOR_ATOM
public
mixed
EDITOR_ATOM
= "atom"
EDITOR_EMACS
public
mixed
EDITOR_EMACS
= "emacs"
EDITOR_ESPRESSO
public
mixed
EDITOR_ESPRESSO
= "espresso"
EDITOR_IDEA
public
mixed
EDITOR_IDEA
= "idea"
EDITOR_MACVIM
public
mixed
EDITOR_MACVIM
= "macvim"
EDITOR_NETBEANS
public
mixed
EDITOR_NETBEANS
= "netbeans"
EDITOR_PHPSTORM
public
mixed
EDITOR_PHPSTORM
= "phpstorm"
EDITOR_SUBLIME
public
mixed
EDITOR_SUBLIME
= "sublime"
EDITOR_TEXTMATE
public
mixed
EDITOR_TEXTMATE
= "textmate"
EDITOR_VSCODE
public
mixed
EDITOR_VSCODE
= "vscode"
EDITOR_XDEBUG
public
mixed
EDITOR_XDEBUG
= "xdebug"
LAST_HANDLER
The Handler has handled the Throwable in some way, and wishes to skip any other Handler.
public
mixed
LAST_HANDLER
= 0x20
Execution will continue.
QUIT
The Handler has handled the Throwable in some way, and wishes to quit/stop execution
public
mixed
QUIT
= 0x30
Properties
$editor
An identifier for a known IDE/text editor.
protected
callable|string
$editor
Either a string, or a calalble 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.
Tags
$editors
A list of known editor strings.
protected
array<string|int, mixed>
$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", "vscode" => "vscode://file/%file:%line", "atom" => "atom://core/open/file?filename=%file&line=%line", "espresso" => "x-espresso://open?filepath=%file&lines=%line", "netbeans" => "netbeans://open/?f=%file:%line"]
$templateHelper
protected
TemplateHelper
$templateHelper
$applicationPaths
private
array<string|int, array<string|int, mixed>>
$applicationPaths
$blacklist
private
array<string|int, array<string|int, mixed>>
$blacklist
= ['_GET' => [], '_POST' => [], '_FILES' => [], '_COOKIE' => [], '_SESSION' => [], '' => [], '_ENV' => []]
$customCss
The name of the custom css file.
private
string|null
$customCss
= null
$customJs
The name of the custom js file.
private
string|null
$customJs
= null
$exception
private
Throwable
$exception
$extraTables
private
array<string|int, array<string|int, mixed>>
$extraTables
= []
$handleUnconditionally
private
bool
$handleUnconditionally
= false
$inspector
private
Inspector
$inspector
$pageTitle
private
string
$pageTitle
= "Whoops! There was an error."
$resourceCache
Fast lookup cache for known resource locations.
private
array<string|int, mixed>
$resourceCache
= []
$run
private
RunInterface
$run
$searchPaths
Search paths to be scanned for resources.
private
array<string|int, mixed>
$searchPaths
= []
Stored in the reverse order they're declared.
Methods
__construct()
Constructor.
public
__construct() : void
addCustomCss()
Adds a custom css file to be loaded.
public
addCustomCss(string|null $name) : static
Parameters
- $name : string|null
Return values
staticaddCustomJs()
Adds a custom js file to be loaded.
public
addCustomJs(string|null $name) : static
Parameters
- $name : string|null
Return values
staticaddDataTable()
Adds an entry to the list of tables displayed in the template.
public
addDataTable(string $label, array<string|int, mixed> $data) : static
The expected data is a simple associative array. Any nested arrays
will be flattened with print_r
.
Parameters
- $label : string
- $data : array<string|int, mixed>
Return values
staticaddDataTableCallback()
Lazily adds an entry to the list of tables displayed in the table.
public
addDataTableCallback(string $label, callable $callback) : static
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
Return values
staticaddEditor()
Adds an editor resolver.
public
addEditor(string $identifier, string|callable $resolver) : static
Either a string, 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.
Parameters
- $identifier : string
- $resolver : string|callable
Tags
Return values
staticaddResourcePath()
Adds a path to the list of paths to be searched for resources.
public
addResourcePath(string $path) : static
Parameters
- $path : string
Tags
Return values
staticblacklist()
blacklist a sensitive value within one of the superglobal arrays.
public
blacklist(string $superGlobalName, string $key) : static
Alias for the hideSuperglobalKey method.
Parameters
- $superGlobalName : string
-
The name of the superglobal array, e.g. '_GET'
- $key : string
-
The key within the superglobal
Tags
Return values
staticcontentType()
public
contentType() : string
Return values
stringgetApplicationPaths()
Return the application paths.
public
getApplicationPaths() : array<string|int, mixed>
Return values
array<string|int, mixed>getDataTables()
Returns all the extra data tables registered with this handler.
public
getDataTables([string|null $label = null ]) : array<string|int, array<string|int, mixed>>|callable
Optionally accepts a 'label' parameter, to only return the data table under that label.
Parameters
- $label : string|null = null
Return values
array<string|int, array<string|int, mixed>>|callablegetEditorAjax()
Determine if the editor link should act as an Ajax request.
public
getEditorAjax(string $filePath, int $line) : bool
Parameters
- $filePath : string
- $line : int
Tags
Return values
boolgetEditorHref()
Get the editor href for a given file and line, if available.
public
getEditorHref(string $filePath, int $line) : string|bool
Parameters
- $filePath : string
- $line : int
Tags
Return values
string|boolgetPageTitle()
Get the page title.
public
getPageTitle() : string
Return values
stringgetResourcePaths()
public
getResourcePaths() : array<string|int, mixed>
Return values
array<string|int, mixed>getResourcesPath()
public
getResourcesPath() : string
Return values
stringhandle()
public
handle() : int|null
Tags
Return values
int|nullhandleUnconditionally()
Set whether to handle unconditionally.
public
handleUnconditionally([bool|null $value = null ]) : bool|static
Allows to disable all attempts to dynamically decide whether to handle or return prematurely. Set this to ensure that the handler will perform, no matter what.
Parameters
- $value : bool|null = null
Return values
bool|statichideSuperglobalKey()
Hide a sensitive value within one of the superglobal arrays.
public
hideSuperglobalKey(string $superGlobalName, string $key) : static
Parameters
- $superGlobalName : string
-
The name of the superglobal array, e.g. '_GET'
- $key : string
-
The key within the superglobal
Return values
staticisLocal()
is Local Environment Check if the application is running in a local environment.
public
isLocal() : bool
Return values
bool —True if running locally, otherwise false.
setApplicationPaths()
Set the application paths.
public
setApplicationPaths(array<string|int, mixed> $applicationPaths) : void
Parameters
- $applicationPaths : array<string|int, mixed>
setApplicationRootPath()
Set the application root path.
public
setApplicationRootPath(string $applicationRootPath) : void
Parameters
- $applicationRootPath : string
setEditor()
Set the editor to use to open referenced files.
public
setEditor(string|callable $editor) : static
Pass either the name of a configured editor, or a closure that directly resolves an editor string.
Parameters
- $editor : string|callable
Tags
Return values
staticsetException()
public
setException(Throwable $exception) : void
Parameters
- $exception : Throwable
setInspector()
public
setInspector(Inspector $inspector) : void
Parameters
- $inspector : Inspector
setPageTitle()
Set the page title.
public
setPageTitle(string $title) : static
Parameters
- $title : string
Return values
staticsetResourcesPath()
public
setResourcesPath(string $resourcesPath) : static
Parameters
- $resourcesPath : string
Return values
staticsetRun()
public
setRun(RunInterface $run) : void
Parameters
- $run : RunInterface
getEditor()
Determines both the editor and if ajax should be used.
protected
getEditor(string $filePath, int $line) : array<string|int, mixed>
Parameters
- $filePath : string
- $line : int
Return values
array<string|int, mixed>getException()
protected
getException() : Throwable
Return values
ThrowablegetExceptionCode()
Get the code of the exception currently being handled.
protected
getExceptionCode() : string
Return values
stringgetExceptionFrames()
Get the stack trace frames of the exception currently being handled.
protected
getExceptionFrames() : FrameCollection
Return values
FrameCollectiongetInspector()
protected
getInspector() : Inspector
Return values
InspectorgetResource()
Finds a resource, by its relative path, in all available search paths.
protected
getResource(string $resource) : 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
Return values
stringgetRun()
protected
getRun() : RunInterface
Return values
RunInterfacemasked()
Checks all values within the given superGlobal array.
private
masked(array<string|int, mixed> $superGlobal, string $superGlobalName) : array<string|int, mixed>
Blacklisted values will be replaced by a equal length string containing only '*' characters for string values. Non-string values will be replaced with a fixed asterisk count. We intentionally dont rely on $GLOBALS as it depends on the 'auto_globals_jit' php.ini setting.
Parameters
- $superGlobal : array<string|int, mixed>
-
One of the superglobal arrays
- $superGlobalName : string
-
The name of the superglobal array, e.g. '_GET'
Return values
array<string|int, mixed> —$values without sensitive data