PHP Class ref, php-ref

Author: digitalnature - http://digitalnature.eu
Mostrar archivo Open project: digitalnature/php-ref Class Usage Examples

Protected Properties

Property Type Description
$config
$debug
$env
$fmt
$startTime
$time
$timeout

Public Methods

Method Description
__construct ( string | RFormatter $format = 'html' ) Constructor
__get ( string $name ) Enforce proper use of this class
__set ( string $name, mixed $value ) Enforce proper use of this class
config ( string $key, mixed | null $value = null ) : mixed Set or get configuration options
getBacktrace ( ) : array | false Get relevant backtrace info for last ref call
getDebugInfo ( )
getInputExpressions ( array &$options = null ) : array Determines the input expression(s) passed to the shortcut function
getTime ( $precision = 4 ) : double Total CPU time used by the class
getTimeoutPoint ( )
parseComment ( string $comment, string | null $key = null ) : array | string | null Parses a DocBlock comment into a data structure.
query ( mixed $subject, string $expression = null ) Generate structured information about a variable/value/expression (subject)
splitRegex ( string $pattern ) : array Split a regex into its components
timeFunc ( integer $iterations, callable $function, &$output = null ) : double Executes a function the given number of times and returns the elapsed time.
timer ( integer $id = 1, integer $precision = 4 ) : void | double Timer utility

Protected Methods

Method Description
evaluate ( &$subject, boolean $specialStr = false ) : mixed Evaluates the given variable
evaluateExp ( string $expression = null ) : string Scans for known classes and functions inside the provided expression, and linkifies them when possible
fromReflector ( Reflector $reflector, string $single = '', Reflector $context = null ) : string Generate class / function info
getParentClasses ( Reflector $class ) : array Get all parent classes of a class
hasInstanceTimedOut ( )
linkify ( Reflector $reflector, string | null $constant = null ) : string | null Generates an URL that points to the documentation page relevant for the requested context
strLen ( string $string ) : integer Calculates real string length
strPad ( $input, integer $padLen, string $padStr = ' ', integer $padType = STR_PAD_RIGHT ) : string Safe str_pad alternative

Method Details

__construct() public method

Constructor
public __construct ( string | RFormatter $format = 'html' )
$format string | RFormatter Output format ID, or formatter instance defaults to 'html'

__get() public method

Enforce proper use of this class
public __get ( string $name )
$name string

__set() public method

Enforce proper use of this class
public __set ( string $name, mixed $value )
$name string
$value mixed

config() public static method

Set or get configuration options
public static config ( string $key, mixed | null $value = null ) : mixed
$key string
$value mixed | null
return mixed

evaluate() protected method

Evaluates the given variable
protected evaluate ( &$subject, boolean $specialStr = false ) : mixed
$specialStr boolean Should this be interpreted as a special string?
return mixed Result (both HTML and text modes generate strings)

evaluateExp() protected method

Scans for known classes and functions inside the provided expression, and linkifies them when possible
protected evaluateExp ( string $expression = null ) : string
$expression string Expression to format
return string Formatted output

fromReflector() protected method

Generate class / function info
protected fromReflector ( Reflector $reflector, string $single = '', Reflector $context = null ) : string
$reflector Reflector Class name or reflection object
$single string Skip parent classes
$context Reflector Object context (for methods)
return string

getBacktrace() public static method

Get relevant backtrace info for last ref call
public static getBacktrace ( ) : array | false
return array | false

getDebugInfo() public static method

public static getDebugInfo ( )

getInputExpressions() public static method

Determines the input expression(s) passed to the shortcut function
public static getInputExpressions ( array &$options = null ) : array
$options array
return array Array of string expressions

getParentClasses() protected static method

Get all parent classes of a class
protected static getParentClasses ( Reflector $class ) : array
$class Reflector Reflection object
return array Array of ReflectionClass objects (starts with the ancestor, ends with the given class)

getTime() public static method

Total CPU time used by the class
public static getTime ( $precision = 4 ) : double
return double

getTimeoutPoint() public static method

public static getTimeoutPoint ( )

hasInstanceTimedOut() protected method

protected hasInstanceTimedOut ( )

linkify() protected method

For internal functions and classes, the URI will point to the local PHP manual if installed and configured, otherwise to php.net/manual (the english one)
protected linkify ( Reflector $reflector, string | null $constant = null ) : string | null
$reflector Reflector Reflector object (used to determine the URL scheme for internal stuff)
$constant string | null Constant name, if this is a request to linkify a constant
return string | null URL

parseComment() public static method

Parses a DocBlock comment into a data structure.
public static parseComment ( string $comment, string | null $key = null ) : array | string | null
$comment string DocBlock comment (must start with /**)
$key string | null Field to return (optional)
return array | string | null Array containing all fields, array/string with the contents of the requested field, or null if the comment is empty/invalid

query() public method

Output is flushed to the screen
public query ( mixed $subject, string $expression = null )
$subject mixed
$expression string

splitRegex() public static method

Based on "Regex Colorizer" by Steven Levithan (this is a translation from javascript)
public static splitRegex ( string $pattern ) : array
$pattern string
return array

strLen() protected static method

Calculates real string length
protected static strLen ( string $string ) : integer
$string string
return integer

strPad() protected static method

Safe str_pad alternative
protected static strPad ( $input, integer $padLen, string $padStr = ' ', integer $padType = STR_PAD_RIGHT ) : string
$padLen integer
$padStr string
$padType integer
return string

timeFunc() public static method

Keep in mind that the returned time includes function call overhead (including microtime calls) x iteration count. This is why this is better suited for determining which of two or more functions is the fastest, rather than finding out how fast is a single function.
public static timeFunc ( integer $iterations, callable $function, &$output = null ) : double
$iterations integer Number of times the function will be executed
$function callable Function to execute
return double Elapsed time

timer() public static method

First call of this function will start the timer. The second call will stop the timer and return the elapsed time since the timer started. Multiple timers can be controlled simultaneously by specifying a timer ID.
Since: 1.0
public static timer ( integer $id = 1, integer $precision = 4 ) : void | double
$id integer Timer ID, optional
$precision integer Precision of the result, optional
return void | double Elapsed time, or void if the timer was just started

Property Details

$config protected_oe static_oe property

protected static $config

$debug protected_oe static_oe property

protected static $debug

$env protected_oe static_oe property

protected static $env

$fmt protected_oe property

protected $fmt

$startTime protected_oe property

protected $startTime

$time protected_oe static_oe property

protected static $time

$timeout protected_oe static_oe property

protected static $timeout