fix
This commit is contained in:
+10
-20
@@ -6,10 +6,8 @@ namespace Laminas\Escaper;
|
||||
|
||||
use function bin2hex;
|
||||
use function ctype_digit;
|
||||
use function function_exists;
|
||||
use function hexdec;
|
||||
use function htmlspecialchars;
|
||||
use function iconv;
|
||||
use function in_array;
|
||||
use function mb_convert_encoding;
|
||||
use function ord;
|
||||
@@ -38,7 +36,7 @@ class Escaper
|
||||
* entities that XML supports. Using HTML entities would result in this error:
|
||||
* XML Parsing Error: undefined entity
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected static $htmlNamedEntityMap = [
|
||||
34 => 'quot', // quotation mark
|
||||
@@ -67,6 +65,7 @@ class Escaper
|
||||
* Static Matcher which escapes characters for HTML Attribute contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $htmlAttrMatcher;
|
||||
|
||||
@@ -74,6 +73,7 @@ class Escaper
|
||||
* Static Matcher which escapes characters for Javascript contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $jsMatcher;
|
||||
|
||||
@@ -81,6 +81,7 @@ class Escaper
|
||||
* Static Matcher which escapes characters for CSS Attribute contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $cssMatcher;
|
||||
|
||||
@@ -255,7 +256,7 @@ class Escaper
|
||||
* Callback function for preg_replace_callback that applies HTML Attribute
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array $matches
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function htmlAttrMatcher($matches)
|
||||
@@ -302,7 +303,7 @@ class Escaper
|
||||
* Callback function for preg_replace_callback that applies Javascript
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array $matches
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function jsMatcher($matches)
|
||||
@@ -325,7 +326,7 @@ class Escaper
|
||||
* Callback function for preg_replace_callback that applies CSS
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array $matches
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function cssMatcher($matches)
|
||||
@@ -391,32 +392,21 @@ class Escaper
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding conversion helper which wraps iconv and mbstring where they exist or throws
|
||||
* and exception where neither is available.
|
||||
* Encoding conversion helper which wraps mb_convert_encoding
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $to
|
||||
* @param array|string $from
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
protected function convertEncoding($string, $to, $from)
|
||||
{
|
||||
if (function_exists('iconv')) {
|
||||
$result = iconv($from, $to, $string);
|
||||
} elseif (function_exists('mb_convert_encoding')) {
|
||||
$result = mb_convert_encoding($string, $to, $from);
|
||||
} else {
|
||||
throw new Exception\RuntimeException(
|
||||
static::class
|
||||
. ' requires either the iconv or mbstring extension to be installed'
|
||||
. ' when escaping for non UTF-8 strings.'
|
||||
);
|
||||
}
|
||||
$result = mb_convert_encoding($string, $to, $from);
|
||||
|
||||
if ($result === false) {
|
||||
return ''; // return non-fatal blank string on encoding errors from users
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-4
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
@@ -52,6 +52,10 @@ class TimestampPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\in_array($var, self::$blacklist, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+4
@@ -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
@@ -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
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user