This commit is contained in:
Olusesan Ameye
2022-10-02 00:26:03 +00:00
parent f8b7061089
commit b4604e02b5
17 changed files with 69 additions and 44 deletions
+5 -4
View File
@@ -150,6 +150,7 @@ class Kint
'Kint\\Parser\\ClosurePlugin',
'Kint\\Parser\\ColorPlugin',
'Kint\\Parser\\DateTimePlugin',
'Kint\\Parser\\EnumPlugin',
'Kint\\Parser\\FsPathPlugin',
'Kint\\Parser\\IteratorPlugin',
'Kint\\Parser\\JsonPlugin',
@@ -548,9 +549,11 @@ class Kint
*
* Functionally equivalent to Kint::dump(1) or Kint::dump(debug_backtrace())
*
* @param mixed ...$args
*
* @return int|string
*/
public static function dump()
public static function dump(...$args)
{
if (false === static::$enabled_mode) {
return 0;
@@ -558,8 +561,6 @@ class Kint
Utils::normalizeAliases(static::$aliases);
$args = \func_get_args();
$call_info = static::getCallInfo(static::$aliases, \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), \count($args));
$statics = static::getStatics();
@@ -587,7 +588,7 @@ class Kint
isset($call_info['params']) ? $call_info['params'] : [],
\count($args)
);
$output = $kintstance->dumpAll($args, $bases);
$output = $kintstance->dumpAll(\array_values($args), $bases);
if (static::$return || \in_array('@', $call_info['modifiers'], true)) {
return $output;
+6
View File
@@ -30,6 +30,7 @@ use Kint\Zval\Representation\Representation;
use Kint\Zval\Value;
use ReflectionClass;
use ReflectionProperty;
use UnitEnum;
class ClassStaticsPlugin extends Plugin
{
@@ -56,6 +57,11 @@ class ClassStaticsPlugin extends Plugin
$consts = [];
foreach ($reflection->getConstants() as $name => $val) {
// Skip enum constants
if ($var instanceof UnitEnum && $val instanceof UnitEnum && $o->classname == \get_class($val)) {
continue;
}
$const = Value::blank($name, '\\'.$class.'::'.$name);
$const->const = true;
$const->depth = $o->depth + 1;
+11 -2
View File
@@ -34,6 +34,7 @@ use Kint\Zval\ResourceValue;
use Kint\Zval\Value;
use ReflectionObject;
use stdClass;
use TypeError;
class Parser
{
@@ -191,6 +192,10 @@ class Parser
public function childHasPath(InstanceValue $parent, Value $child)
{
if ('__PHP_Incomplete_Class' === $parent->classname) {
return false;
}
if ('object' === $parent->type && (null !== $parent->access_path || $child->static || $child->const)) {
if (Value::ACCESS_PUBLIC === $child->access) {
return true;
@@ -434,7 +439,7 @@ class Parser
$rep = new Representation('Properties');
if (KINT_PHP74) {
if (KINT_PHP74 && '__PHP_Incomplete_Class' != $object->classname) {
$rprops = $reflector->getProperties();
foreach ($rprops as $rprop) {
@@ -524,7 +529,11 @@ class Parser
}
$stash = $val;
$copy[$i] = $refmarker;
try {
$copy[$i] = $refmarker;
} catch (TypeError $e) {
$child->reference = true;
}
if ($val === $refmarker) {
$child->reference = true;
$val = $stash;
+4
View File
@@ -52,6 +52,10 @@ class TimestampPlugin extends Plugin
return;
}
if ($var < 0) {
return;
}
if (\in_array($var, self::$blacklist, true)) {
return;
}
+1 -1
View File
@@ -32,7 +32,7 @@ use Throwable;
class CliRenderer extends TextRenderer
{
/**
* @var bool enable colors when Kint is run in *UNIX* command line
* @var bool enable colors
*/
public static $cli_colors = true;
+2
View File
@@ -42,6 +42,7 @@ class TextRenderer extends Renderer
'microtime' => 'Kint\\Renderer\\Text\\MicrotimePlugin',
'recursion' => 'Kint\\Renderer\\Text\\RecursionPlugin',
'trace' => 'Kint\\Renderer\\Text\\TracePlugin',
'enum' => 'Kint\\Renderer\\Text\\EnumPlugin',
];
/**
@@ -55,6 +56,7 @@ class TextRenderer extends Renderer
'Kint\\Parser\\MicrotimePlugin',
'Kint\\Parser\\StreamPlugin',
'Kint\\Parser\\TracePlugin',
'Kint\\Parser\\EnumPlugin',
];
/**
+4
View File
@@ -109,6 +109,10 @@ final class Utils
if (\file_exists($installed) && \is_readable($installed)) {
$packages = \json_decode(\file_get_contents($installed), true);
if (!\is_array($packages)) {
continue;
}
foreach ($packages as $package) {
if (isset($package['extra'][$key]) && \is_array($package['extra'][$key])) {
$extras = \array_replace($extras, $package['extra'][$key]);
+8 -12
View File
@@ -30,13 +30,13 @@ if (!\function_exists('d')) {
/**
* Alias of Kint::dump().
*
* @param mixed ...$args
*
* @return int|string
*/
function d()
function d(...$args)
{
$args = \func_get_args();
return \call_user_func_array(['Kint', 'dump'], $args);
return Kint::dump(...$args);
}
Kint::$aliases[] = 'd';
@@ -49,16 +49,13 @@ if (!\function_exists('s')) {
* Alias of Kint::dump(), however the output is in plain htmlescaped text
* with some minor visibility enhancements added.
*
* If run in CLI mode, output is not escaped.
* If run in CLI colors are disabled
*
* To force rendering mode without autodetecting anything:
*
* Kint::$enabled_mode = Kint::MODE_PLAIN;
* Kint::dump( $variable );
* @param mixed ...$args
*
* @return int|string
*/
function s()
function s(...$args)
{
if (false === Kint::$enabled_mode) {
return 0;
@@ -77,8 +74,7 @@ if (!\function_exists('s')) {
CliRenderer::$cli_colors = false;
$args = \func_get_args();
$out = \call_user_func_array(['Kint', 'dump'], $args);
$out = Kint::dump(...$args);
Kint::$enabled_mode = $kstash;
CliRenderer::$cli_colors = $cstash;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long