Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • Debug
  • Helpers
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Debug

Debug class useful for don't forgetting where debug traces are.

Automatically decorates print_r() and var_dump() with following information: – file and line of the caller – name of function/method containing the call – name of the parameter passed during call

Example:

function f($value) {Debug::printr($value);}

Result:

[function f() in file /path/to/file.php, line 31]
$value =
Array
(
    [0] => 'xyz'
)

See examples/debug.php for a complete example.

Namespace: GAubry\Helpers
Located at helpers/src/GAubry/Helpers/Debug.php
Methods summary
private
# __construct( )

Constructor.

Constructor.

CodeCoverageIgnore

public static array
# getCaller( string $sFunctionName = '', array $aStack = array() )

Returns an array containing function name, filename and line in filename of the caller. If called out of any function, then return '' as function name. To return the caller of your function, either call get_caller(), or get_caller(__FUNCTION__).

Returns an array containing function name, filename and line in filename of the caller. If called out of any function, then return '' as function name. To return the caller of your function, either call get_caller(), or get_caller(__FUNCTION__).

Parameters

$sFunctionName
string
$sFunctionName function whose caller is searched
$aStack
array
stack trace, or debug_backtrace() by default

Returns

array
triplet: (string)function name or '', (string)filename or '', (int)line in filename or 0

Author

Aram Kocharyan
Geoffroy Aubry

See

http://stackoverflow.com/a/4767754
private static string
# getVarName( string $sFunction, string $sFile, integer $iLine )

Return the name of the first parameter of the penultimate function call.

Return the name of the first parameter of the penultimate function call.

TODO bug if multiple calls in the same line…

Parameters

$sFunction
string
$sFunction function called
$sFile
string
$sFile file containing a call to $sFunction
$iLine
integer
$iLine line in $sFile containing a call to $sFunction

Returns

string
the name of the first parameter of the penultimate function call.

Author

Sebastián Grignoli
Geoffroy Aubry

See

http://stackoverflow.com/a/6837836
private static
# displayTrace( string $sPattern, string $sValue )

Use specified pattern to display function name, filename, line in filename, varname in parameter and value of this parameter of the caller.

Use specified pattern to display function name, filename, line in filename, varname in parameter and value of this parameter of the caller.

Parameters

$sPattern
string
$sPattern key of self::$sDisplayPatterns
$sValue
string
$sValue value of the parameter of the caller

See

GAubry\Helpers\Debug::$sDisplayPatterns
public static
# htmlVarDump( mixed $mValue )

Display an HTML trace containing a var_dump() of the specified value.

Display an HTML trace containing a var_dump() of the specified value.

Parameters

$mValue
mixed
$mValue value to pass to var_dump()
public static
# htmlPrintr( mixed $mValue )

Display an HTML trace containing a print_r() of the specified value.

Display an HTML trace containing a print_r() of the specified value.

Parameters

$mValue
mixed
$mValue value to pass to print_r()
public static
# varDump( mixed $mValue )

Display a CLI trace containing a var_dump() of the specified value.

Display a CLI trace containing a var_dump() of the specified value.

Parameters

$mValue
mixed
$mValue value to pass to var_dump()
public static
# printr( mixed $mValue )

Display a CLI trace containing a print_r() of the specified value.

Display a CLI trace containing a print_r() of the specified value.

Parameters

$mValue
mixed
$mValue value to pass to print_r()
Properties summary
public static array $sDisplayPatterns array( 'html' => '<pre><i>[function %1$s in file %2$s, line %3$d]</i><br /><b>%4$s</b> = %5$s</pre>', // @codingStandardsIgnoreStart HEREDOC syntax is not supported in array by pdepend… 'cli' => "\033[2;33;40m[function \033[1m%1\$s\033[2m in file \033[1m%2\$s\033[2m, line \033[1m%3\$d\033[2m]\n\033[1m%4\$s\033[2m = \033[0m\n%5\$s\n" // @codingStandardsIgnoreEnd )
#

Patterns for both HTML and CLI rendering:
%1$s = function name or '∅' if no function
%2$s = filename,
%3$d = line in filename,
%4$s = varname in parameter,
%5$s = value of parameter

Patterns for both HTML and CLI rendering: %1$s = function name or '∅' if no function %2$s = filename, %3$d = line in filename, %4$s = varname in parameter, %5$s = value of parameter

See

GAubry\Helpers\Debug::displayTrace()
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0