PHP Class PMA\libraries\ErrorHandler

Show file Open project: phpmyadmin/phpmyadmin

Protected Properties

Property Type Description
$errors Error[] ..
$hide_location Hide location of errors

Public Methods

Method Description
__construct ( ) Constructor - set PHP error handler
__destruct ( ) Destructor
addError ( string $errstr, integer $errno, string $errfile, integer $errline, boolean $escape = true ) : void Add an error; can also be called directly (with or without escaping)
countDisplayErrors ( ) : integer number of errors to be displayed
countErrors ( boolean $check = true ) : integer return count of errors
countUserErrors ( ) : integer return count of user errors
dispErrors ( ) : void displays errors not displayed
dispUserErrors ( ) : void Displays user errors not displayed
getCurrentErrors ( ) : Error[] returns the errors occurred in the current run only.
getDispErrors ( ) : string renders errors not displayed
getDispUserErrors ( ) : string Renders user errors not displayed
getErrors ( boolean $check = true ) : Error[] returns array with all errors
handleError ( integer $errno, string $errstr, string $errfile, integer $errline ) : void Error handler - called when errors are triggered/occurred
hasDisplayErrors ( ) : boolean whether there are errors to display or not
hasErrors ( ) : boolean whether errors occurred or not
hasErrorsForPrompt ( ) : boolean Function to check if there are any errors to be prompted.
hasUserErrors ( ) : boolean whether use errors occurred or not
reportErrors ( ) : void Function to report all the collected php errors.
savePreviousErrors ( ) : void Deletes previously stored errors in SESSION.
setHideLocation ( boolean $hide ) : void Toggles location hiding
sliceErrors ( integer $count ) : Error[] Pops recent errors from the storage
triggerError ( string $errorInfo, integer $errorNumber = null ) : void trigger a custom error

Protected Methods

Method Description
checkSavedErrors ( ) : void look in session for saved errors
dispFatalError ( Error $error ) : void display fatal error and exit
dispPageEnd ( ) : void display HTML footer
dispPageStart ( Error $error = null ) : void display HTML header

Method Details

__construct() public method

Constructor - set PHP error handler
public __construct ( )

__destruct() public method

stores errors in session
public __destruct ( )

addError() public method

The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called. Do not use the context parameter as we want to avoid storing the complete $GLOBALS inside $_SESSION['errors']
public addError ( string $errstr, integer $errno, string $errfile, integer $errline, boolean $escape = true ) : void
$errstr string error string
$errno integer error number
$errfile string error file
$errline integer error line
$escape boolean whether to escape the error string
return void

checkSavedErrors() protected method

look in session for saved errors
protected checkSavedErrors ( ) : void
return void

countDisplayErrors() public method

number of errors to be displayed
public countDisplayErrors ( ) : integer
return integer number of errors to be displayed

countErrors() public method

return count of errors
public countErrors ( boolean $check = true ) : integer
$check boolean Whether to check for session errors
return integer number of errors occurred

countUserErrors() public method

return count of user errors
public countUserErrors ( ) : integer
return integer number of user errors occurred

dispErrors() public method

displays errors not displayed
public dispErrors ( ) : void
return void

dispFatalError() protected method

display fatal error and exit
protected dispFatalError ( Error $error ) : void
$error Error the error
return void

dispPageEnd() protected method

display HTML footer
protected dispPageEnd ( ) : void
return void

dispPageStart() protected method

display HTML header
protected dispPageStart ( Error $error = null ) : void
$error Error the error
return void

dispUserErrors() public method

Displays user errors not displayed
public dispUserErrors ( ) : void
return void

getCurrentErrors() public method

Does not include the errors saved in the SESSION
public getCurrentErrors ( ) : Error[]
return Error[]

getDispErrors() public method

renders errors not displayed
public getDispErrors ( ) : string
return string

getDispUserErrors() public method

Renders user errors not displayed
public getDispUserErrors ( ) : string
return string

getErrors() public method

returns array with all errors
public getErrors ( boolean $check = true ) : Error[]
$check boolean Whether to check for session errors
return Error[]

handleError() public method

This calls the addError() function, escaping the error string Ignores the errors wherever Error Control Operator (@) is used.
public handleError ( integer $errno, string $errstr, string $errfile, integer $errline ) : void
$errno integer error number
$errstr string error string
$errfile string error file
$errline integer error line
return void

hasDisplayErrors() public method

whether there are errors to display or not
public hasDisplayErrors ( ) : boolean
return boolean

hasErrors() public method

whether errors occurred or not
public hasErrors ( ) : boolean
return boolean

hasErrorsForPrompt() public method

Needed because user warnings raised are also collected by global error handler. This distinguishes between the actual errors and user errors raised to warn user.
public hasErrorsForPrompt ( ) : boolean
return boolean true if there are errors to be "prompted", false otherwise

hasUserErrors() public method

whether use errors occurred or not
public hasUserErrors ( ) : boolean
return boolean

reportErrors() public method

Must be called at the end of each script by the $GLOBALS['error_handler'] only.
public reportErrors ( ) : void
return void

savePreviousErrors() public method

Saves current errors in session as previous errors. Required to save current errors in case 'ask'
public savePreviousErrors ( ) : void
return void

setHideLocation() public method

Toggles location hiding
public setHideLocation ( boolean $hide ) : void
$hide boolean Whether to hide
return void

sliceErrors() public method

Pops recent errors from the storage
public sliceErrors ( integer $count ) : Error[]
$count integer Old error count
return Error[]

triggerError() public method

trigger a custom error
public triggerError ( string $errorInfo, integer $errorNumber = null ) : void
$errorInfo string error message
$errorNumber integer error number
return void

Property Details

$errors protected property

..
protected Error[],PMA\libraries $errors
return Error[]

$hide_location protected property

Hide location of errors
protected $hide_location