PHP Class PMA\libraries\Error

Inheritance: extends Message
Show file Open project: phpmyadmin/phpmyadmin Class Usage Examples

Public Properties

Property Type Description
$errorlevel array Error levels
$errortype array Error types

Protected Properties

Property Type Description
$backtrace array Holds the backtrace for this error
$file string The file in which the error occurred
$hide_location Hide location of errors
$line integer The line in which the error occurred

Public Methods

Method Description
__construct ( integer $errno, string $errstr, string $errfile, integer $errline ) Constructor
formatBacktrace ( array $backtrace, string $separator, string $lines ) : string return formatted backtrace field
getArg ( string $arg, string $function ) : string Get a single function argument
getBacktrace ( integer $count ) : array returns PMA\libraries\Error::$_backtrace for first $count frames pass $count = -1 to get full backtrace.
getBacktraceDisplay ( ) : string Get HTML backtrace
getDisplay ( ) : string Gets the error as string of HTML
getFile ( ) : string returns PMA\libraries\Error::$file
getFunctionCall ( array $step, string $separator ) : string Formats function call in a backtrace
getHash ( ) : string returns unique PMA\libraries\Error::$hash, if not exists it will be created
getHtmlTitle ( ) : string returns title prepared for HTML Title-Tag
getLevel ( ) : string returns level of error
getLine ( ) : integer returns PMA\libraries\Error::$line
getTitle ( ) : string returns title for error
getType ( ) : string returns type of error
isUserError ( ) : boolean whether this error is a user error
processBacktrace ( array $backtrace ) : array Process backtrace to avoid path disclossures, objects and so on
relPath ( string $path ) : string return short relative path to phpMyAdmin basedir
setBacktrace ( array $backtrace ) : void sets PMA\libraries\Error::$_backtrace
setFile ( string $file ) : void sets PMA\libraries\Error::$_file
setHideLocation ( boolean $hide ) : void Toggles location hiding
setLine ( integer $line ) : void sets PMA\libraries\Error::$_line

Method Details

__construct() public method

Constructor
public __construct ( integer $errno, string $errstr, string $errfile, integer $errline )
$errno integer error number
$errstr string error message
$errfile string file
$errline integer line

formatBacktrace() public static method

return formatted backtrace field
public static formatBacktrace ( array $backtrace, string $separator, string $lines ) : string
$backtrace array Backtrace data
$separator string Arguments separator to use
$lines string Lines separator to use
return string formatted backtrace

getArg() public static method

if $function is one of include/require the $arg is converted to a relative path
public static getArg ( string $arg, string $function ) : string
$arg string argument to process
$function string function name
return string

getBacktrace() public method

The same can be done by not passing $count at all.
public getBacktrace ( integer $count ) : array
$count integer Number of stack frames.
return array PMA\libraries\Error::$_backtrace

getBacktraceDisplay() public method

Get HTML backtrace
public getBacktraceDisplay ( ) : string
return string

getDisplay() public method

Gets the error as string of HTML
public getDisplay ( ) : string
return string

getFile() public method

returns PMA\libraries\Error::$file
public getFile ( ) : string
return string PMA\libraries\Error::$file

getFunctionCall() public static method

Formats function call in a backtrace
public static getFunctionCall ( array $step, string $separator ) : string
$step array backtrace step
$separator string Arguments separator to use
return string

getHash() public method

returns unique PMA\libraries\Error::$hash, if not exists it will be created
public getHash ( ) : string
return string PMA\libraries\Error::$hash

getHtmlTitle() public method

returns title prepared for HTML Title-Tag
public getHtmlTitle ( ) : string
return string HTML escaped and truncated title

getLevel() public method

returns level of error
public getLevel ( ) : string
return string level of error

getLine() public method

returns PMA\libraries\Error::$line
public getLine ( ) : integer
return integer PMA\libraries\Error::$line

getTitle() public method

returns title for error
public getTitle ( ) : string
return string

getType() public method

returns type of error
public getType ( ) : string
return string type of error

isUserError() public method

whether this error is a user error
public isUserError ( ) : boolean
return boolean

processBacktrace() public static method

Process backtrace to avoid path disclossures, objects and so on
public static processBacktrace ( array $backtrace ) : array
$backtrace array backtrace
return array

relPath() public static method

prevent path disclosure in error message, and make users feel safe to submit error reports
public static relPath ( string $path ) : string
$path string path to be shorten
return string shortened path

setBacktrace() public method

We don't store full arguments to avoid wakeup or memory problems.
public setBacktrace ( array $backtrace ) : void
$backtrace array backtrace
return void

setFile() public method

sets PMA\libraries\Error::$_file
public setFile ( string $file ) : void
$file string the file
return void

setHideLocation() public method

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

setLine() public method

sets PMA\libraries\Error::$_line
public setLine ( integer $line ) : void
$line integer the line
return void

Property Details

$backtrace protected property

Holds the backtrace for this error
protected array $backtrace
return array

$errorlevel public static property

Error levels
public static array $errorlevel
return array

$errortype public static property

Error types
public static array $errortype
return array

$file protected property

The file in which the error occurred
protected string $file
return string

$hide_location protected property

Hide location of errors
protected $hide_location

$line protected property

The line in which the error occurred
protected int $line
return integer