Download the PHP package simplecomplex/inspect without Composer
On this page you can find all versions of the php package simplecomplex/inspect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplecomplex/inspect
More information about simplecomplex/inspect
Files in simplecomplex/inspect
Package inspect
Short Description PHP and Javascript library for inspecting variables and stack traces.
License MIT
Homepage https://github.com/simplecomplex/inspect
Informations about the package inspect
(PHP+JS) Inspect: variable dumps and stack traces
- Description
- License
- Requirements
Get Inspect
Principal methods and options
(int) $options
depth
: max object/array recursion; DEPTH_DEFAULT/TRACE_DEPTH_DEFAULT
(array) $options
- (int)
depth
: max object/array recursion; DEPTH_DEFAULT/TRACE_DEPTH_DEFAULT - (int)
limit
: max trace frame; TRACE_LIMIT_DEFAULT - (int)
code
: error code, overrides exception code; none - (int)
truncate
: string truncation; TRUNCATE_DEFAULT - (arr)
skip_keys
: skip those object/array keys; none - (arr)
needles
: replace in strings; NEEDLES/NEEDLES_ESCAPE_HTML - (arr)
replacers
: replace in strings; REPLACERS/REPLACERS_ESCAPE_HTML - (bool)
escape_html
: replace in strings; ESCAPE_HTML - (int)
output_max
: replace in strings; OUTPUT_DEFAULT - (int)
exectime_percent
: replace in strings; EXEC_TIMEOUT_DEFAULT - (bool)
rootdir_replace
: replace root dir in strings; ROOT_DIR_REPLACE - (int)
wrappers
: number of wrapping functions/methods, to be hidden; zero
inspect($subject, $options = []): Inspector
Do variable inspection, unless arg $subject is a throwable; then trace.
variable($subject, $options = []): Inspector
Force variable inspection, even if subject is a throwable.
trace($throwableOrNull, $options = []): Inspector
Trace exception or do back-trace.
Logging
The Inspector returned by inspect|variable|trace() is stringable. Pass it directly to a PSR logger:
Or use the Inspector's own chainable PSR logger-like method:
log($level = 'debug', $message = '', array $context = []): void
Javascript
(object) options
- (string)
message
: content headline and options as string also interprets to message (except when 'protos'/'func_body') - (integer)
depth
: array|object recursion max (default 10, max 10) - (boolean)
protos
: analyze prototypal properties too - (boolean)
func_body
: print bodies of functions - (string)
type
: default 'inspect'/'inspect trace' - (string)
severity
: default 'debug'/'error'
To console:
Description
Produces tidy and informative variable dumps and exception/back traces.
Tailormade and ready for logging - the inspect/variable/trace() methods return a stringable object.
Safe
The inspector and tracer guarantee not to fail.
A simple PHP:var_dump() is prone to raise a PHP error if you dump a large or complex array like $GLOBALS, due to references (recursion).
Inspect limits it's recursion into sub arrays/objects. It also keeps track of how large an output it produces. And it finally makes sure that max execution time doesn't get exceeded.
Secure
Inspect hides the values of array/object buckets named 'pw', 'pass' and 'password'.
And values of other sensitives can be hidden using 'skip_keys' option.
PHP and Javascript
Inspect consists of a PHP library for serverside inspection and tracing, and a Javascript library for clientside ditto.
NB: The Javascript library has not been maintained since 2015.
Maturity
The library has existed in various forms since 2010. The core has been refined continuously whereas the wrapping has evolved from a rather oldschool OOP pattern over a solid but non-orthodox Drupal style, to well-behaved PSR/Composer patterns.
Used in - extended by - Drupal
The backbone of the Drupal Inspect module is SimpleComplex Inspect. The Drupal module (D7 as well as D8) extends Inspect to accomodate to the context - that is: uses Drupal's APIs and features when it makes sense.
MIT licensed
License and copyright. Explained.
Requirements
- PHP >=8.1
All versions of inspect with dependencies
ext-ctype Version *