helpers.php
Table of Contents
- dump() : string|void
- Dumps information about a variable, like var_dump() but with improved syntax and coloring.
- debugr() : DebugR
- Shorthand for sending DebugR messages.
- value() : mixed
- Return the value of a variable or return null if the valiable not exist. (Prevents "Undefined variable" notices) WARNING! As a side-effect non existing variables are set to null.
- array_value() : mixed
- Return the value of the array element or return null if the element doesn't exist. (Prevents "Undefined index" notices).
- error() : mixed
- Report a fatal error (and stop executing).
- warning() : mixed
- Report a warning.
- notice() : mixed
- Report a notice.
- deprecated() : mixed
- Report deprecated functionality.
- report_exception() : mixed
- Report an exception.
Functions
dump()
Dumps information about a variable, like var_dump() but with improved syntax and coloring.
dump(mixed $variable[, bool $export = false ]) : string|void
Parameters
- $variable : mixed
- $export : bool = false
Return values
string|void —debugr()
Shorthand for sending DebugR messages.
debugr([mixed $variable = null ]) : DebugR
debugr()->log($var); instead of \Sledgehammer\DebugR::log($var); debugr($var); instead of \Sledgehammer\DebugR::dump($var).
Parameters
- $variable : mixed = null
Return values
DebugR —value()
Return the value of a variable or return null if the valiable not exist. (Prevents "Undefined variable" notices) WARNING! As a side-effect non existing variables are set to null.
value(mixed &$variable) : mixed
If you pass array element to value($var['index'])
and $var didn't exist, an array is created: array('index' => null)
Use \Sledgehammer\array_value() which doesn't have this side effect for array.
Example: if (value($_GET['foo']) == 'bar') { instead of if (isset($_GET['foo']) && $_GET['foo'] == 'bar') {
Parameters
- $variable : mixed
Return values
mixed —array_value()
Return the value of the array element or return null if the element doesn't exist. (Prevents "Undefined index" notices).
array_value(array<string|int, mixed> $array, string $key) : mixed
Example: if (\Sledgehammer\array_value($_GET, 'foo') == 'bar') { instead of if (isset($_GET['foo']) && $_GET['foo'] == 'bar') {
Parameters
- $array : array<string|int, mixed>
- $key : string
Return values
mixed —error()
Report a fatal error (and stop executing).
error(string $message[, mixed $information = null ]) : mixed
It's preferred to throw Exceptions, which allows the calling code to react to the error.
Parameters
- $message : string
-
The error
- $information : mixed = null
-
[optional] Additional information
Return values
mixed —warning()
Report a warning.
warning(string $message[, mixed $information = null ]) : mixed
Parameters
- $message : string
-
The warning
- $information : mixed = null
-
[optional] Additional information
Return values
mixed —notice()
Report a notice.
notice(string $message[, mixed $information = null ]) : mixed
Parameters
- $message : string
-
The notice
- $information : mixed = null
-
[optional] Additional information
Return values
mixed —deprecated()
Report deprecated functionality.
deprecated([string $message = 'This functionality will no longer be supported in upcomming releases' ][, mixed $information = null ]) : mixed
Parameters
- $message : string = 'This functionality will no longer be supported in upcomming releases'
-
The message
- $information : mixed = null
-
[optional] Additional information
Return values
mixed —report_exception()
Report an exception.
report_exception(Exception $exception) : mixed
Parameters
- $exception : Exception