Initial
This commit is contained in:
177
system/ThirdParty/Kint/Zval/BlobValue.php
vendored
Normal file
177
system/ThirdParty/Kint/Zval/BlobValue.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class BlobValue extends Value
|
||||
{
|
||||
/**
|
||||
* @var array Character encodings to detect
|
||||
*
|
||||
* @see https://secure.php.net/function.mb-detect-order
|
||||
*
|
||||
* In practice, mb_detect_encoding can only successfully determine the
|
||||
* difference between the following common charsets at once without
|
||||
* breaking things for one of the other charsets:
|
||||
* - ASCII
|
||||
* - UTF-8
|
||||
* - SJIS
|
||||
* - EUC-JP
|
||||
*
|
||||
* The order of the charsets is significant. If you put UTF-8 before ASCII
|
||||
* it will never match ASCII, because UTF-8 is a superset of ASCII.
|
||||
* Similarly, SJIS and EUC-JP frequently match UTF-8 strings, so you should
|
||||
* check UTF-8 first. SJIS and EUC-JP seem to work either way, but SJIS is
|
||||
* more common so it should probably be first.
|
||||
*
|
||||
* While you're free to experiment with other charsets, remember to keep
|
||||
* this behavior in mind when setting up your char_encodings array.
|
||||
*
|
||||
* This depends on the mbstring extension
|
||||
*/
|
||||
public static $char_encodings = [
|
||||
'ASCII',
|
||||
'UTF-8',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array Legacy character encodings to detect
|
||||
*
|
||||
* @see https://secure.php.net/function.iconv
|
||||
*
|
||||
* Assuming the other encoding checks fail, this will perform a
|
||||
* simple iconv conversion to check for invalid bytes. If any are
|
||||
* found it will not match.
|
||||
*
|
||||
* This can be useful for ambiguous single byte encodings like
|
||||
* windows-125x and iso-8859-x which have practically undetectable
|
||||
* differences because they use every single byte available.
|
||||
*
|
||||
* This is *NOT* reliable and should not be trusted implicitly. As
|
||||
* with char_encodings, the order of the charsets is significant.
|
||||
*
|
||||
* This depends on the iconv extension
|
||||
*/
|
||||
public static $legacy_encodings = [];
|
||||
|
||||
public $type = 'string';
|
||||
public $encoding = false;
|
||||
public $hints = ['string'];
|
||||
|
||||
public function getType()
|
||||
{
|
||||
if (false === $this->encoding) {
|
||||
return 'binary '.$this->type;
|
||||
}
|
||||
|
||||
if ('ASCII' === $this->encoding) {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
return $this->encoding.' '.$this->type;
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if ($rep = $this->value) {
|
||||
return '"'.$rep->contents.'"';
|
||||
}
|
||||
}
|
||||
|
||||
public function transplant(Value $old)
|
||||
{
|
||||
parent::transplant($old);
|
||||
|
||||
if ($old instanceof self) {
|
||||
$this->encoding = $old->encoding;
|
||||
}
|
||||
}
|
||||
|
||||
public static function strlen($string, $encoding = false)
|
||||
{
|
||||
if (\function_exists('mb_strlen')) {
|
||||
if (false === $encoding) {
|
||||
$encoding = self::detectEncoding($string);
|
||||
}
|
||||
|
||||
if ($encoding && 'ASCII' !== $encoding) {
|
||||
return \mb_strlen($string, $encoding);
|
||||
}
|
||||
}
|
||||
|
||||
return \strlen($string);
|
||||
}
|
||||
|
||||
public static function substr($string, $start, $length = null, $encoding = false)
|
||||
{
|
||||
if (\function_exists('mb_substr')) {
|
||||
if (false === $encoding) {
|
||||
$encoding = self::detectEncoding($string);
|
||||
}
|
||||
|
||||
if ($encoding && 'ASCII' !== $encoding) {
|
||||
return \mb_substr($string, $start, $length, $encoding);
|
||||
}
|
||||
}
|
||||
|
||||
// Special case for substr/mb_substr discrepancy
|
||||
if ('' === $string) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return \substr($string, $start, isset($length) ? $length : PHP_INT_MAX);
|
||||
}
|
||||
|
||||
public static function detectEncoding($string)
|
||||
{
|
||||
if (\function_exists('mb_detect_encoding')) {
|
||||
if ($ret = \mb_detect_encoding($string, self::$char_encodings, true)) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty much every character encoding uses first 32 bytes as control
|
||||
// characters. If it's not a multi-byte format it's safe to say matching
|
||||
// any control character besides tab, nl, and cr means it's binary.
|
||||
if (\preg_match('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]/', $string)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (\function_exists('iconv')) {
|
||||
foreach (self::$legacy_encodings as $encoding) {
|
||||
if (@\iconv($encoding, $encoding, $string) === $string) {
|
||||
return $encoding;
|
||||
}
|
||||
}
|
||||
} elseif (!\function_exists('mb_detect_encoding')) { // @codeCoverageIgnore
|
||||
// If a user has neither mb_detect_encoding, nor iconv, nor the
|
||||
// polyfills, there's not much we can do about it...
|
||||
// Pretend it's ASCII and pray the browser renders it properly.
|
||||
return 'ASCII'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
68
system/ThirdParty/Kint/Zval/ClosureValue.php
vendored
Normal file
68
system/ThirdParty/Kint/Zval/ClosureValue.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class ClosureValue extends InstanceValue
|
||||
{
|
||||
public $parameters = [];
|
||||
public $hints = ['object', 'callable', 'closure'];
|
||||
|
||||
private $paramcache;
|
||||
|
||||
public function getAccessPath()
|
||||
{
|
||||
if (null !== $this->access_path) {
|
||||
return parent::getAccessPath().'('.$this->getParams().')';
|
||||
}
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
if (null !== $this->paramcache) {
|
||||
return $this->paramcache;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
|
||||
foreach ($this->parameters as $p) {
|
||||
$type = $p->getType();
|
||||
|
||||
$ref = $p->reference ? '&' : '';
|
||||
|
||||
if ($type) {
|
||||
$out[] = $type.' '.$ref.$p->getName();
|
||||
} else {
|
||||
$out[] = $ref.$p->getName();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->paramcache = \implode(', ', $out);
|
||||
}
|
||||
}
|
||||
53
system/ThirdParty/Kint/Zval/DateTimeValue.php
vendored
Normal file
53
system/ThirdParty/Kint/Zval/DateTimeValue.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class DateTimeValue extends InstanceValue
|
||||
{
|
||||
public $dt;
|
||||
|
||||
public $hints = ['object', 'datetime'];
|
||||
|
||||
public function __construct(DateTime $dt)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dt = clone $dt;
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
$stamp = $this->dt->format('Y-m-d H:i:s');
|
||||
if ((int) ($micro = $this->dt->format('u'))) {
|
||||
$stamp .= '.'.$micro;
|
||||
}
|
||||
$stamp .= $this->dt->format('P T');
|
||||
|
||||
return $stamp;
|
||||
}
|
||||
}
|
||||
78
system/ThirdParty/Kint/Zval/InstanceValue.php
vendored
Normal file
78
system/ThirdParty/Kint/Zval/InstanceValue.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class InstanceValue extends Value
|
||||
{
|
||||
public $type = 'object';
|
||||
public $classname;
|
||||
public $spl_object_hash;
|
||||
public $filename;
|
||||
public $startline;
|
||||
public $hints = ['object'];
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->classname;
|
||||
}
|
||||
|
||||
public function transplant(Value $old)
|
||||
{
|
||||
parent::transplant($old);
|
||||
|
||||
if ($old instanceof self) {
|
||||
$this->classname = $old->classname;
|
||||
$this->spl_object_hash = $old->spl_object_hash;
|
||||
$this->filename = $old->filename;
|
||||
$this->startline = $old->startline;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sortByHierarchy($a, $b)
|
||||
{
|
||||
if (\is_string($a) && \is_string($b)) {
|
||||
$aclass = $a;
|
||||
$bclass = $b;
|
||||
} elseif (!($a instanceof Value) || !($b instanceof Value)) {
|
||||
return 0;
|
||||
} elseif ($a instanceof self && $b instanceof self) {
|
||||
$aclass = $a->classname;
|
||||
$bclass = $b->classname;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (\is_subclass_of($aclass, $bclass)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (\is_subclass_of($bclass, $aclass)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
253
system/ThirdParty/Kint/Zval/MethodValue.php
vendored
Normal file
253
system/ThirdParty/Kint/Zval/MethodValue.php
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use Kint\Utils;
|
||||
use Kint\Zval\Representation\DocstringRepresentation;
|
||||
use ReflectionFunctionAbstract;
|
||||
use ReflectionMethod;
|
||||
|
||||
class MethodValue extends Value
|
||||
{
|
||||
public $type = 'method';
|
||||
public $filename;
|
||||
public $startline;
|
||||
public $endline;
|
||||
public $parameters = [];
|
||||
public $abstract;
|
||||
public $final;
|
||||
public $internal;
|
||||
public $docstring;
|
||||
public $returntype;
|
||||
public $return_reference = false;
|
||||
public $hints = ['callable', 'method'];
|
||||
public $showparams = true;
|
||||
|
||||
private $paramcache;
|
||||
|
||||
public function __construct(ReflectionFunctionAbstract $method)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->name = $method->getName();
|
||||
$this->filename = $method->getFileName();
|
||||
$this->startline = $method->getStartLine();
|
||||
$this->endline = $method->getEndLine();
|
||||
$this->internal = $method->isInternal();
|
||||
$this->docstring = $method->getDocComment();
|
||||
$this->return_reference = $method->returnsReference();
|
||||
|
||||
foreach ($method->getParameters() as $param) {
|
||||
$this->parameters[] = new ParameterValue($param);
|
||||
}
|
||||
|
||||
if (KINT_PHP70) {
|
||||
$this->returntype = $method->getReturnType();
|
||||
if ($this->returntype) {
|
||||
$this->returntype = Utils::getTypeString($this->returntype);
|
||||
}
|
||||
}
|
||||
|
||||
if ($method instanceof ReflectionMethod) {
|
||||
$this->static = $method->isStatic();
|
||||
$this->operator = $this->static ? Value::OPERATOR_STATIC : Value::OPERATOR_OBJECT;
|
||||
$this->abstract = $method->isAbstract();
|
||||
$this->final = $method->isFinal();
|
||||
$this->owner_class = $method->getDeclaringClass()->name;
|
||||
$this->access = Value::ACCESS_PUBLIC;
|
||||
if ($method->isProtected()) {
|
||||
$this->access = Value::ACCESS_PROTECTED;
|
||||
} elseif ($method->isPrivate()) {
|
||||
$this->access = Value::ACCESS_PRIVATE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->internal) {
|
||||
return;
|
||||
}
|
||||
|
||||
$docstring = new DocstringRepresentation(
|
||||
$this->docstring,
|
||||
$this->filename,
|
||||
$this->startline
|
||||
);
|
||||
|
||||
$docstring->implicit_label = true;
|
||||
$this->addRepresentation($docstring);
|
||||
$this->value = $docstring;
|
||||
}
|
||||
|
||||
public function setAccessPathFrom(InstanceValue $parent)
|
||||
{
|
||||
static $magic = [
|
||||
'__call' => true,
|
||||
'__callstatic' => true,
|
||||
'__clone' => true,
|
||||
'__construct' => true,
|
||||
'__debuginfo' => true,
|
||||
'__destruct' => true,
|
||||
'__get' => true,
|
||||
'__invoke' => true,
|
||||
'__isset' => true,
|
||||
'__set' => true,
|
||||
'__set_state' => true,
|
||||
'__sleep' => true,
|
||||
'__tostring' => true,
|
||||
'__unset' => true,
|
||||
'__wakeup' => true,
|
||||
];
|
||||
|
||||
$name = \strtolower($this->name);
|
||||
|
||||
if ('__construct' === $name) {
|
||||
$this->access_path = 'new \\'.$parent->getType();
|
||||
} elseif ('__invoke' === $name) {
|
||||
$this->access_path = $parent->access_path;
|
||||
} elseif ('__clone' === $name) {
|
||||
$this->access_path = 'clone '.$parent->access_path;
|
||||
$this->showparams = false;
|
||||
} elseif ('__tostring' === $name) {
|
||||
$this->access_path = '(string) '.$parent->access_path;
|
||||
$this->showparams = false;
|
||||
} elseif (isset($magic[$name])) {
|
||||
$this->access_path = null;
|
||||
} elseif ($this->static) {
|
||||
$this->access_path = '\\'.$this->owner_class.'::'.$this->name;
|
||||
} else {
|
||||
$this->access_path = $parent->access_path.'->'.$this->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if (!$this->value || !($this->value instanceof DocstringRepresentation)) {
|
||||
return parent::getValueShort();
|
||||
}
|
||||
|
||||
$ds = $this->value->getDocstringWithoutComments();
|
||||
|
||||
if (!$ds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ds = \explode("\n", $ds);
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($ds as $line) {
|
||||
if (0 === \strlen(\trim($line)) || '@' === $line[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= $line.' ';
|
||||
}
|
||||
|
||||
if (\strlen($out)) {
|
||||
return \rtrim($out);
|
||||
}
|
||||
}
|
||||
|
||||
public function getModifiers()
|
||||
{
|
||||
$mods = [
|
||||
$this->abstract ? 'abstract' : null,
|
||||
$this->final ? 'final' : null,
|
||||
$this->getAccess(),
|
||||
$this->static ? 'static' : null,
|
||||
];
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($mods as $word) {
|
||||
if (null !== $word) {
|
||||
$out .= $word.' ';
|
||||
}
|
||||
}
|
||||
|
||||
if (\strlen($out)) {
|
||||
return \rtrim($out);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAccessPath()
|
||||
{
|
||||
if (null !== $this->access_path) {
|
||||
if ($this->showparams) {
|
||||
return parent::getAccessPath().'('.$this->getParams().')';
|
||||
}
|
||||
|
||||
return parent::getAccessPath();
|
||||
}
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
if (null !== $this->paramcache) {
|
||||
return $this->paramcache;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
|
||||
foreach ($this->parameters as $p) {
|
||||
$type = $p->getType();
|
||||
if ($type) {
|
||||
$type .= ' ';
|
||||
}
|
||||
|
||||
$default = $p->getDefault();
|
||||
if ($default) {
|
||||
$default = ' = '.$default;
|
||||
}
|
||||
|
||||
$ref = $p->reference ? '&' : '';
|
||||
|
||||
$out[] = $type.$ref.$p->getName().$default;
|
||||
}
|
||||
|
||||
return $this->paramcache = \implode(', ', $out);
|
||||
}
|
||||
|
||||
public function getPhpDocUrl()
|
||||
{
|
||||
if (!$this->internal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->owner_class) {
|
||||
$class = \strtolower($this->owner_class);
|
||||
} else {
|
||||
$class = 'function';
|
||||
}
|
||||
|
||||
$funcname = \str_replace('_', '-', \strtolower($this->name));
|
||||
|
||||
if (0 === \strpos($funcname, '--') && 0 !== \strpos($funcname, '-', 2)) {
|
||||
$funcname = \substr($funcname, 2);
|
||||
}
|
||||
|
||||
return 'https://secure.php.net/'.$class.'.'.$funcname;
|
||||
}
|
||||
}
|
||||
99
system/ThirdParty/Kint/Zval/ParameterValue.php
vendored
Normal file
99
system/ThirdParty/Kint/Zval/ParameterValue.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use Kint\Utils;
|
||||
use ReflectionException;
|
||||
use ReflectionParameter;
|
||||
|
||||
class ParameterValue extends Value
|
||||
{
|
||||
public $type_hint;
|
||||
public $default;
|
||||
public $position;
|
||||
public $hints = ['parameter'];
|
||||
|
||||
public function __construct(ReflectionParameter $param)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (KINT_PHP70) {
|
||||
if ($type = $param->getType()) {
|
||||
$this->type_hint = Utils::getTypeString($type);
|
||||
}
|
||||
} else {
|
||||
if ($param->isArray()) {
|
||||
$this->type_hint = 'array';
|
||||
} else {
|
||||
try {
|
||||
if ($this->type_hint = $param->getClass()) {
|
||||
$this->type_hint = $this->type_hint->name;
|
||||
}
|
||||
} catch (ReflectionException $e) {
|
||||
\preg_match('/\\[\\s\\<\\w+?>\\s([\\w]+)/s', $param->__toString(), $matches);
|
||||
$this->type_hint = isset($matches[1]) ? $matches[1] : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->reference = $param->isPassedByReference();
|
||||
$this->name = $param->getName();
|
||||
$this->position = $param->getPosition();
|
||||
|
||||
if ($param->isDefaultValueAvailable()) {
|
||||
$default = $param->getDefaultValue();
|
||||
switch (\gettype($default)) {
|
||||
case 'NULL':
|
||||
$this->default = 'null';
|
||||
break;
|
||||
case 'boolean':
|
||||
$this->default = $default ? 'true' : 'false';
|
||||
break;
|
||||
case 'array':
|
||||
$this->default = \count($default) ? 'array(...)' : 'array()';
|
||||
break;
|
||||
default:
|
||||
$this->default = \var_export($default, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type_hint;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return '$'.$this->name;
|
||||
}
|
||||
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
}
|
||||
573
system/ThirdParty/Kint/Zval/Representation/ColorRepresentation.php
vendored
Normal file
573
system/ThirdParty/Kint/Zval/Representation/ColorRepresentation.php
vendored
Normal file
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class ColorRepresentation extends Representation
|
||||
{
|
||||
const COLOR_NAME = 1;
|
||||
const COLOR_HEX_3 = 2;
|
||||
const COLOR_HEX_6 = 3;
|
||||
const COLOR_RGB = 4;
|
||||
const COLOR_RGBA = 5;
|
||||
const COLOR_HSL = 6;
|
||||
const COLOR_HSLA = 7;
|
||||
const COLOR_HEX_4 = 8;
|
||||
const COLOR_HEX_8 = 9;
|
||||
|
||||
public static $color_map = [
|
||||
'aliceblue' => 'f0f8ff',
|
||||
'antiquewhite' => 'faebd7',
|
||||
'aqua' => '00ffff',
|
||||
'aquamarine' => '7fffd4',
|
||||
'azure' => 'f0ffff',
|
||||
'beige' => 'f5f5dc',
|
||||
'bisque' => 'ffe4c4',
|
||||
'black' => '000000',
|
||||
'blanchedalmond' => 'ffebcd',
|
||||
'blue' => '0000ff',
|
||||
'blueviolet' => '8a2be2',
|
||||
'brown' => 'a52a2a',
|
||||
'burlywood' => 'deb887',
|
||||
'cadetblue' => '5f9ea0',
|
||||
'chartreuse' => '7fff00',
|
||||
'chocolate' => 'd2691e',
|
||||
'coral' => 'ff7f50',
|
||||
'cornflowerblue' => '6495ed',
|
||||
'cornsilk' => 'fff8dc',
|
||||
'crimson' => 'dc143c',
|
||||
'cyan' => '00ffff',
|
||||
'darkblue' => '00008b',
|
||||
'darkcyan' => '008b8b',
|
||||
'darkgoldenrod' => 'b8860b',
|
||||
'darkgray' => 'a9a9a9',
|
||||
'darkgreen' => '006400',
|
||||
'darkgrey' => 'a9a9a9',
|
||||
'darkkhaki' => 'bdb76b',
|
||||
'darkmagenta' => '8b008b',
|
||||
'darkolivegreen' => '556b2f',
|
||||
'darkorange' => 'ff8c00',
|
||||
'darkorchid' => '9932cc',
|
||||
'darkred' => '8b0000',
|
||||
'darksalmon' => 'e9967a',
|
||||
'darkseagreen' => '8fbc8f',
|
||||
'darkslateblue' => '483d8b',
|
||||
'darkslategray' => '2f4f4f',
|
||||
'darkslategrey' => '2f4f4f',
|
||||
'darkturquoise' => '00ced1',
|
||||
'darkviolet' => '9400d3',
|
||||
'deeppink' => 'ff1493',
|
||||
'deepskyblue' => '00bfff',
|
||||
'dimgray' => '696969',
|
||||
'dimgrey' => '696969',
|
||||
'dodgerblue' => '1e90ff',
|
||||
'firebrick' => 'b22222',
|
||||
'floralwhite' => 'fffaf0',
|
||||
'forestgreen' => '228b22',
|
||||
'fuchsia' => 'ff00ff',
|
||||
'gainsboro' => 'dcdcdc',
|
||||
'ghostwhite' => 'f8f8ff',
|
||||
'gold' => 'ffd700',
|
||||
'goldenrod' => 'daa520',
|
||||
'gray' => '808080',
|
||||
'green' => '008000',
|
||||
'greenyellow' => 'adff2f',
|
||||
'grey' => '808080',
|
||||
'honeydew' => 'f0fff0',
|
||||
'hotpink' => 'ff69b4',
|
||||
'indianred' => 'cd5c5c',
|
||||
'indigo' => '4b0082',
|
||||
'ivory' => 'fffff0',
|
||||
'khaki' => 'f0e68c',
|
||||
'lavender' => 'e6e6fa',
|
||||
'lavenderblush' => 'fff0f5',
|
||||
'lawngreen' => '7cfc00',
|
||||
'lemonchiffon' => 'fffacd',
|
||||
'lightblue' => 'add8e6',
|
||||
'lightcoral' => 'f08080',
|
||||
'lightcyan' => 'e0ffff',
|
||||
'lightgoldenrodyellow' => 'fafad2',
|
||||
'lightgray' => 'd3d3d3',
|
||||
'lightgreen' => '90ee90',
|
||||
'lightgrey' => 'd3d3d3',
|
||||
'lightpink' => 'ffb6c1',
|
||||
'lightsalmon' => 'ffa07a',
|
||||
'lightseagreen' => '20b2aa',
|
||||
'lightskyblue' => '87cefa',
|
||||
'lightslategray' => '778899',
|
||||
'lightslategrey' => '778899',
|
||||
'lightsteelblue' => 'b0c4de',
|
||||
'lightyellow' => 'ffffe0',
|
||||
'lime' => '00ff00',
|
||||
'limegreen' => '32cd32',
|
||||
'linen' => 'faf0e6',
|
||||
'magenta' => 'ff00ff',
|
||||
'maroon' => '800000',
|
||||
'mediumaquamarine' => '66cdaa',
|
||||
'mediumblue' => '0000cd',
|
||||
'mediumorchid' => 'ba55d3',
|
||||
'mediumpurple' => '9370db',
|
||||
'mediumseagreen' => '3cb371',
|
||||
'mediumslateblue' => '7b68ee',
|
||||
'mediumspringgreen' => '00fa9a',
|
||||
'mediumturquoise' => '48d1cc',
|
||||
'mediumvioletred' => 'c71585',
|
||||
'midnightblue' => '191970',
|
||||
'mintcream' => 'f5fffa',
|
||||
'mistyrose' => 'ffe4e1',
|
||||
'moccasin' => 'ffe4b5',
|
||||
'navajowhite' => 'ffdead',
|
||||
'navy' => '000080',
|
||||
'oldlace' => 'fdf5e6',
|
||||
'olive' => '808000',
|
||||
'olivedrab' => '6b8e23',
|
||||
'orange' => 'ffa500',
|
||||
'orangered' => 'ff4500',
|
||||
'orchid' => 'da70d6',
|
||||
'palegoldenrod' => 'eee8aa',
|
||||
'palegreen' => '98fb98',
|
||||
'paleturquoise' => 'afeeee',
|
||||
'palevioletred' => 'db7093',
|
||||
'papayawhip' => 'ffefd5',
|
||||
'peachpuff' => 'ffdab9',
|
||||
'peru' => 'cd853f',
|
||||
'pink' => 'ffc0cb',
|
||||
'plum' => 'dda0dd',
|
||||
'powderblue' => 'b0e0e6',
|
||||
'purple' => '800080',
|
||||
'rebeccapurple' => '663399',
|
||||
'red' => 'ff0000',
|
||||
'rosybrown' => 'bc8f8f',
|
||||
'royalblue' => '4169e1',
|
||||
'saddlebrown' => '8b4513',
|
||||
'salmon' => 'fa8072',
|
||||
'sandybrown' => 'f4a460',
|
||||
'seagreen' => '2e8b57',
|
||||
'seashell' => 'fff5ee',
|
||||
'sienna' => 'a0522d',
|
||||
'silver' => 'c0c0c0',
|
||||
'skyblue' => '87ceeb',
|
||||
'slateblue' => '6a5acd',
|
||||
'slategray' => '708090',
|
||||
'slategrey' => '708090',
|
||||
'snow' => 'fffafa',
|
||||
'springgreen' => '00ff7f',
|
||||
'steelblue' => '4682b4',
|
||||
'tan' => 'd2b48c',
|
||||
'teal' => '008080',
|
||||
'thistle' => 'd8bfd8',
|
||||
'tomato' => 'ff6347',
|
||||
// To quote MDN:
|
||||
// "Technically, transparent is a shortcut for rgba(0,0,0,0)."
|
||||
'transparent' => '00000000',
|
||||
'turquoise' => '40e0d0',
|
||||
'violet' => 'ee82ee',
|
||||
'wheat' => 'f5deb3',
|
||||
'white' => 'ffffff',
|
||||
'whitesmoke' => 'f5f5f5',
|
||||
'yellow' => 'ffff00',
|
||||
'yellowgreen' => '9acd32',
|
||||
];
|
||||
|
||||
public $r = 0;
|
||||
public $g = 0;
|
||||
public $b = 0;
|
||||
public $a = 1.0;
|
||||
public $variant;
|
||||
public $implicit_label = true;
|
||||
public $hints = ['color'];
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
parent::__construct('Color');
|
||||
|
||||
$this->contents = $value;
|
||||
$this->setValues($value);
|
||||
}
|
||||
|
||||
public function getColor($variant = null)
|
||||
{
|
||||
if (!$variant) {
|
||||
$variant = $this->variant;
|
||||
}
|
||||
|
||||
switch ($variant) {
|
||||
case self::COLOR_NAME:
|
||||
$hex = \sprintf('%02x%02x%02x', $this->r, $this->g, $this->b);
|
||||
$hex_alpha = \sprintf('%02x%02x%02x%02x', $this->r, $this->g, $this->b, \round($this->a * 0xFF));
|
||||
|
||||
return \array_search($hex, self::$color_map, true) ?: \array_search($hex_alpha, self::$color_map, true);
|
||||
case self::COLOR_HEX_3:
|
||||
if (0 === $this->r % 0x11 && 0 === $this->g % 0x11 && 0 === $this->b % 0x11) {
|
||||
return \sprintf(
|
||||
'#%1X%1X%1X',
|
||||
\round($this->r / 0x11),
|
||||
\round($this->g / 0x11),
|
||||
\round($this->b / 0x11)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
case self::COLOR_HEX_6:
|
||||
return \sprintf('#%02X%02X%02X', $this->r, $this->g, $this->b);
|
||||
case self::COLOR_RGB:
|
||||
if (1.0 === $this->a) {
|
||||
return \sprintf('rgb(%d, %d, %d)', $this->r, $this->g, $this->b);
|
||||
}
|
||||
|
||||
return \sprintf('rgb(%d, %d, %d, %s)', $this->r, $this->g, $this->b, \round($this->a, 4));
|
||||
case self::COLOR_RGBA:
|
||||
return \sprintf('rgba(%d, %d, %d, %s)', $this->r, $this->g, $this->b, \round($this->a, 4));
|
||||
case self::COLOR_HSL:
|
||||
$val = self::rgbToHsl($this->r, $this->g, $this->b);
|
||||
if (1.0 === $this->a) {
|
||||
return \vsprintf('hsl(%d, %d%%, %d%%)', $val);
|
||||
}
|
||||
|
||||
return \sprintf('hsl(%d, %d%%, %d%%, %s)', $val[0], $val[1], $val[2], \round($this->a, 4));
|
||||
case self::COLOR_HSLA:
|
||||
$val = self::rgbToHsl($this->r, $this->g, $this->b);
|
||||
|
||||
return \sprintf('hsla(%d, %d%%, %d%%, %s)', $val[0], $val[1], $val[2], \round($this->a, 4));
|
||||
case self::COLOR_HEX_4:
|
||||
if (0 === $this->r % 0x11 && 0 === $this->g % 0x11 && 0 === $this->b % 0x11 && 0 === ((int) ($this->a * 255)) % 0x11) {
|
||||
return \sprintf(
|
||||
'#%1X%1X%1X%1X',
|
||||
\round($this->r / 0x11),
|
||||
\round($this->g / 0x11),
|
||||
\round($this->b / 0x11),
|
||||
\round($this->a * 0xF)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
case self::COLOR_HEX_8:
|
||||
return \sprintf('#%02X%02X%02X%02X', $this->r, $this->g, $this->b, \round($this->a * 0xFF));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasAlpha($variant = null)
|
||||
{
|
||||
if (null === $variant) {
|
||||
$variant = $this->variant;
|
||||
}
|
||||
|
||||
switch ($variant) {
|
||||
case self::COLOR_NAME:
|
||||
case self::COLOR_RGB:
|
||||
case self::COLOR_HSL:
|
||||
return \abs($this->a - 1) >= 0.0001;
|
||||
case self::COLOR_RGBA:
|
||||
case self::COLOR_HSLA:
|
||||
case self::COLOR_HEX_4:
|
||||
case self::COLOR_HEX_8:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setValues($value)
|
||||
{
|
||||
$value = \strtolower(\trim($value));
|
||||
// Find out which variant of color input it is
|
||||
if (isset(self::$color_map[$value])) {
|
||||
if (!$this->setValuesFromHex(self::$color_map[$value])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$variant = self::COLOR_NAME;
|
||||
} elseif ('#' === $value[0]) {
|
||||
$variant = $this->setValuesFromHex(\substr($value, 1));
|
||||
|
||||
if (!$variant) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$variant = $this->setValuesFromFunction($value);
|
||||
|
||||
if (!$variant) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If something has gone horribly wrong
|
||||
if ($this->r > 0xFF || $this->g > 0xFF || $this->b > 0xFF || $this->a > 1) {
|
||||
$this->variant = null; // @codeCoverageIgnore
|
||||
} else {
|
||||
$this->variant = $variant;
|
||||
$this->r = (int) $this->r;
|
||||
$this->g = (int) $this->g;
|
||||
$this->b = (int) $this->b;
|
||||
$this->a = (float) $this->a;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setValuesFromHex($hex)
|
||||
{
|
||||
if (!\ctype_xdigit($hex)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (\strlen($hex)) {
|
||||
case 3:
|
||||
$variant = self::COLOR_HEX_3;
|
||||
break;
|
||||
case 6:
|
||||
$variant = self::COLOR_HEX_6;
|
||||
break;
|
||||
case 4:
|
||||
$variant = self::COLOR_HEX_4;
|
||||
break;
|
||||
case 8:
|
||||
$variant = self::COLOR_HEX_8;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($variant) {
|
||||
case self::COLOR_HEX_4:
|
||||
$this->a = \hexdec($hex[3]) / 0xF;
|
||||
// no break
|
||||
case self::COLOR_HEX_3:
|
||||
$this->r = \hexdec($hex[0]) * 0x11;
|
||||
$this->g = \hexdec($hex[1]) * 0x11;
|
||||
$this->b = \hexdec($hex[2]) * 0x11;
|
||||
break;
|
||||
case self::COLOR_HEX_8:
|
||||
$this->a = \hexdec(\substr($hex, 6, 2)) / 0xFF;
|
||||
// no break
|
||||
case self::COLOR_HEX_6:
|
||||
$hex = \str_split($hex, 2);
|
||||
$this->r = \hexdec($hex[0]);
|
||||
$this->g = \hexdec($hex[1]);
|
||||
$this->b = \hexdec($hex[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
return $variant;
|
||||
}
|
||||
|
||||
protected function setValuesFromFunction($value)
|
||||
{
|
||||
if (!\preg_match('/^((?:rgb|hsl)a?)\\s*\\(([0-9\\.%,\\s\\/\\-]+)\\)$/i', $value, $match)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (\strtolower($match[1])) {
|
||||
case 'rgb':
|
||||
$variant = self::COLOR_RGB;
|
||||
break;
|
||||
case 'rgba':
|
||||
$variant = self::COLOR_RGBA;
|
||||
break;
|
||||
case 'hsl':
|
||||
$variant = self::COLOR_HSL;
|
||||
break;
|
||||
case 'hsla':
|
||||
$variant = self::COLOR_HSLA;
|
||||
break;
|
||||
default:
|
||||
return null; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$params = \preg_replace('/[,\\s\\/]+/', ',', \trim($match[2]));
|
||||
$params = \explode(',', $params);
|
||||
$params = \array_map('trim', $params);
|
||||
|
||||
if (\count($params) < 3 || \count($params) > 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($params as $i => &$color) {
|
||||
if (false !== \strpos($color, '%')) {
|
||||
$color = (float) \str_replace('%', '', $color);
|
||||
|
||||
if (3 === $i) {
|
||||
$color = $color / 100;
|
||||
} elseif (\in_array($variant, [self::COLOR_RGB, self::COLOR_RGBA], true)) {
|
||||
$color = \round($color / 100 * 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
$color = (float) $color;
|
||||
|
||||
if (0 === $i && \in_array($variant, [self::COLOR_HSL, self::COLOR_HSLA], true)) {
|
||||
$color = \fmod(\fmod($color, 360) + 360, 360);
|
||||
}
|
||||
}
|
||||
|
||||
/** @var non-empty-array<array-key, float> $params Psalm bug workaround */
|
||||
switch ($variant) {
|
||||
case self::COLOR_RGBA:
|
||||
case self::COLOR_RGB:
|
||||
if (\min($params) < 0 || \max($params) > 0xFF) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case self::COLOR_HSLA:
|
||||
case self::COLOR_HSL:
|
||||
if (\min($params) < 0 || $params[0] > 360 || \max($params[1], $params[2]) > 100) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (4 === \count($params)) {
|
||||
if ($params[3] > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->a = $params[3];
|
||||
}
|
||||
|
||||
if (self::COLOR_HSLA === $variant || self::COLOR_HSL === $variant) {
|
||||
$params = self::hslToRgb($params[0], $params[1], $params[2]);
|
||||
}
|
||||
|
||||
list($this->r, $this->g, $this->b) = $params;
|
||||
|
||||
return $variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns HSL color to RGB. Black magic.
|
||||
*
|
||||
* @param float $h Hue
|
||||
* @param float $s Saturation
|
||||
* @param float $l Lightness
|
||||
*
|
||||
* @return int[] RGB array
|
||||
*/
|
||||
public static function hslToRgb($h, $s, $l)
|
||||
{
|
||||
if (\min($h, $s, $l) < 0) {
|
||||
throw new InvalidArgumentException('The parameters for hslToRgb should be no less than 0');
|
||||
}
|
||||
|
||||
if ($h > 360 || \max($s, $l) > 100) {
|
||||
throw new InvalidArgumentException('The parameters for hslToRgb should be no more than 360, 100, and 100 respectively');
|
||||
}
|
||||
|
||||
$h /= 360;
|
||||
$s /= 100;
|
||||
$l /= 100;
|
||||
|
||||
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s;
|
||||
$m1 = $l * 2 - $m2;
|
||||
|
||||
return [
|
||||
(int) \round(self::hueToRgb($m1, $m2, $h + 1 / 3) * 0xFF),
|
||||
(int) \round(self::hueToRgb($m1, $m2, $h) * 0xFF),
|
||||
(int) \round(self::hueToRgb($m1, $m2, $h - 1 / 3) * 0xFF),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts RGB to HSL. Color inversion of previous black magic is white magic?
|
||||
*
|
||||
* @param float|int $red Red
|
||||
* @param float|int $green Green
|
||||
* @param float|int $blue Blue
|
||||
*
|
||||
* @return float[] HSL array
|
||||
*/
|
||||
public static function rgbToHsl($red, $green, $blue)
|
||||
{
|
||||
if (\min($red, $green, $blue) < 0) {
|
||||
throw new InvalidArgumentException('The parameters for rgbToHsl should be no less than 0');
|
||||
}
|
||||
|
||||
if (\max($red, $green, $blue) > 0xFF) {
|
||||
throw new InvalidArgumentException('The parameters for rgbToHsl should be no more than 255');
|
||||
}
|
||||
|
||||
$clrMin = \min($red, $green, $blue);
|
||||
$clrMax = \max($red, $green, $blue);
|
||||
$deltaMax = $clrMax - $clrMin;
|
||||
|
||||
$L = ($clrMax + $clrMin) / 510;
|
||||
|
||||
if (0 == $deltaMax) {
|
||||
$H = 0;
|
||||
$S = 0;
|
||||
} else {
|
||||
if (0.5 > $L) {
|
||||
$S = $deltaMax / ($clrMax + $clrMin);
|
||||
} else {
|
||||
$S = $deltaMax / (510 - $clrMax - $clrMin);
|
||||
}
|
||||
|
||||
if ($clrMax === $red) {
|
||||
$H = ($green - $blue) / (6.0 * $deltaMax);
|
||||
|
||||
if (0 > $H) {
|
||||
$H += 1.0;
|
||||
}
|
||||
} elseif ($clrMax === $green) {
|
||||
$H = 1 / 3 + ($blue - $red) / (6.0 * $deltaMax);
|
||||
} else {
|
||||
$H = 2 / 3 + ($red - $green) / (6.0 * $deltaMax);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
\fmod($H * 360, 360),
|
||||
(float) ($S * 100),
|
||||
(float) ($L * 100),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for hslToRgb. Even blacker magic.
|
||||
*
|
||||
* @param float $m1
|
||||
* @param float $m2
|
||||
* @param float $hue
|
||||
*
|
||||
* @return float Color value
|
||||
*/
|
||||
private static function hueToRgb($m1, $m2, $hue)
|
||||
{
|
||||
$hue = ($hue < 0) ? $hue + 1 : (($hue > 1) ? $hue - 1 : $hue);
|
||||
if ($hue * 6 < 1) {
|
||||
return $m1 + ($m2 - $m1) * $hue * 6;
|
||||
}
|
||||
if ($hue * 2 < 1) {
|
||||
return $m2;
|
||||
}
|
||||
if ($hue * 3 < 2) {
|
||||
return $m1 + ($m2 - $m1) * (2 / 3 - $hue) * 6;
|
||||
}
|
||||
|
||||
return $m1;
|
||||
}
|
||||
}
|
||||
73
system/ThirdParty/Kint/Zval/Representation/DocstringRepresentation.php
vendored
Normal file
73
system/ThirdParty/Kint/Zval/Representation/DocstringRepresentation.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
class DocstringRepresentation extends Representation
|
||||
{
|
||||
public $file;
|
||||
public $line;
|
||||
public $class;
|
||||
public $hints = ['docstring'];
|
||||
|
||||
public function __construct($docstring, $file, $line, $class = null)
|
||||
{
|
||||
parent::__construct('Docstring');
|
||||
|
||||
$this->file = $file;
|
||||
$this->line = $line;
|
||||
$this->class = $class;
|
||||
$this->contents = $docstring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the representation's docstring without surrounding comments.
|
||||
*
|
||||
* Note that this will not work flawlessly.
|
||||
*
|
||||
* On comments with whitespace after the stars the lines will begin with
|
||||
* whitespace, since we can't accurately guess how much of an indentation
|
||||
* is required.
|
||||
*
|
||||
* And on lines without stars on the left this may eat bullet points.
|
||||
*
|
||||
* Long story short: If you want the docstring read the contents. If you
|
||||
* absolutely must have it without comments (ie renderValueShort) this will
|
||||
* probably do.
|
||||
*
|
||||
* @return null|string Docstring with comments stripped
|
||||
*/
|
||||
public function getDocstringWithoutComments()
|
||||
{
|
||||
if (!$this->contents) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$string = \substr($this->contents, 3, -2);
|
||||
$string = \preg_replace('/^\\s*\\*\\s*?(\\S|$)/m', '\\1', $string);
|
||||
|
||||
return \trim($string);
|
||||
}
|
||||
}
|
||||
71
system/ThirdParty/Kint/Zval/Representation/MicrotimeRepresentation.php
vendored
Normal file
71
system/ThirdParty/Kint/Zval/Representation/MicrotimeRepresentation.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class MicrotimeRepresentation extends Representation
|
||||
{
|
||||
public $seconds;
|
||||
public $microseconds;
|
||||
public $group;
|
||||
public $lap;
|
||||
public $total;
|
||||
public $avg;
|
||||
public $i = 0;
|
||||
public $mem = 0;
|
||||
public $mem_real = 0;
|
||||
public $mem_peak = 0;
|
||||
public $mem_peak_real = 0;
|
||||
public $hints = ['microtime'];
|
||||
|
||||
public function __construct($seconds, $microseconds, $group, $lap = null, $total = null, $i = 0)
|
||||
{
|
||||
parent::__construct('Microtime');
|
||||
|
||||
$this->seconds = (int) $seconds;
|
||||
$this->microseconds = (int) $microseconds;
|
||||
|
||||
$this->group = $group;
|
||||
$this->lap = $lap;
|
||||
$this->total = $total;
|
||||
$this->i = $i;
|
||||
|
||||
if ($i) {
|
||||
$this->avg = $total / $i;
|
||||
}
|
||||
|
||||
$this->mem = \memory_get_usage();
|
||||
$this->mem_real = \memory_get_usage(true);
|
||||
$this->mem_peak = \memory_get_peak_usage();
|
||||
$this->mem_peak_real = \memory_get_peak_usage(true);
|
||||
}
|
||||
|
||||
public function getDateTime()
|
||||
{
|
||||
return DateTime::createFromFormat('U u', $this->seconds.' '.\str_pad($this->microseconds, 6, '0', STR_PAD_LEFT));
|
||||
}
|
||||
}
|
||||
71
system/ThirdParty/Kint/Zval/Representation/Representation.php
vendored
Normal file
71
system/ThirdParty/Kint/Zval/Representation/Representation.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
class Representation
|
||||
{
|
||||
public $label;
|
||||
public $implicit_label = false;
|
||||
public $hints = [];
|
||||
public $contents = [];
|
||||
|
||||
protected $name;
|
||||
|
||||
public function __construct($label, $name = null)
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
if (null === $name) {
|
||||
$name = $label;
|
||||
}
|
||||
|
||||
$this->setName($name);
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
if (\is_array($this->contents) && \count($this->contents) > 1) {
|
||||
return $this->label.' ('.\count($this->contents).')';
|
||||
}
|
||||
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = \preg_replace('/[^a-z0-9]+/', '_', \strtolower($name));
|
||||
}
|
||||
|
||||
public function labelIsImplicit()
|
||||
{
|
||||
return $this->implicit_label;
|
||||
}
|
||||
}
|
||||
72
system/ThirdParty/Kint/Zval/Representation/SourceRepresentation.php
vendored
Normal file
72
system/ThirdParty/Kint/Zval/Representation/SourceRepresentation.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
class SourceRepresentation extends Representation
|
||||
{
|
||||
public $hints = ['source'];
|
||||
public $source = [];
|
||||
public $filename;
|
||||
public $line = 0;
|
||||
public $showfilename = false;
|
||||
|
||||
public function __construct($filename, $line, $padding = 7)
|
||||
{
|
||||
parent::__construct('Source');
|
||||
|
||||
$this->filename = $filename;
|
||||
$this->line = $line;
|
||||
|
||||
$start_line = \max($line - $padding, 1);
|
||||
$length = $line + $padding + 1 - $start_line;
|
||||
$this->source = self::getSource($filename, $start_line, $length);
|
||||
if (null !== $this->source) {
|
||||
$this->contents = \implode("\n", $this->source);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets section of source code.
|
||||
*
|
||||
* @param string $filename Full path to file
|
||||
* @param int $start_line The first line to display (1 based)
|
||||
* @param null|int $length Amount of lines to show
|
||||
*
|
||||
* @return null|array
|
||||
*/
|
||||
public static function getSource($filename, $start_line = 1, $length = null)
|
||||
{
|
||||
if (!$filename || !\file_exists($filename) || !\is_readable($filename)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$source = \preg_split("/\r\n|\n|\r/", \file_get_contents($filename));
|
||||
$source = \array_combine(\range(1, \count($source)), $source);
|
||||
$source = \array_slice($source, $start_line - 1, $length, true);
|
||||
|
||||
return $source;
|
||||
}
|
||||
}
|
||||
177
system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php
vendored
Normal file
177
system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval\Representation;
|
||||
|
||||
use Kint\Utils;
|
||||
use SplFileInfo;
|
||||
|
||||
class SplFileInfoRepresentation extends Representation
|
||||
{
|
||||
public $perms = null;
|
||||
public $flags;
|
||||
public $path;
|
||||
public $realpath = null;
|
||||
public $linktarget = null;
|
||||
public $size;
|
||||
public $is_dir = false;
|
||||
public $is_file = false;
|
||||
public $is_link = false;
|
||||
public $owner = null;
|
||||
public $group = null;
|
||||
public $ctime;
|
||||
public $mtime;
|
||||
public $typename = 'Unknown file';
|
||||
public $typeflag = '-';
|
||||
public $hints = ['fspath'];
|
||||
|
||||
public function __construct(SplFileInfo $fileInfo)
|
||||
{
|
||||
parent::__construct('SplFileInfo');
|
||||
|
||||
if ($fileInfo->getRealPath()) {
|
||||
$this->realpath = $fileInfo->getRealPath();
|
||||
$this->perms = $fileInfo->getPerms();
|
||||
$this->size = $fileInfo->getSize();
|
||||
$this->owner = $fileInfo->getOwner();
|
||||
$this->group = $fileInfo->getGroup();
|
||||
$this->ctime = $fileInfo->getCTime();
|
||||
$this->mtime = $fileInfo->getMTime();
|
||||
}
|
||||
|
||||
$this->path = $fileInfo->getPathname();
|
||||
|
||||
$this->is_dir = $fileInfo->isDir();
|
||||
$this->is_file = $fileInfo->isFile();
|
||||
$this->is_link = $fileInfo->isLink();
|
||||
|
||||
if ($this->is_link) {
|
||||
$this->linktarget = $fileInfo->getLinkTarget();
|
||||
}
|
||||
|
||||
switch ($this->perms & 0xF000) {
|
||||
case 0xC000:
|
||||
$this->typename = 'Socket';
|
||||
$this->typeflag = 's';
|
||||
break;
|
||||
case 0x6000:
|
||||
$this->typename = 'Block device';
|
||||
$this->typeflag = 'b';
|
||||
break;
|
||||
case 0x2000:
|
||||
$this->typename = 'Character device';
|
||||
$this->typeflag = 'c';
|
||||
break;
|
||||
case 0x1000:
|
||||
$this->typename = 'Named pipe';
|
||||
$this->typeflag = 'p';
|
||||
break;
|
||||
default:
|
||||
if ($this->is_file) {
|
||||
if ($this->is_link) {
|
||||
$this->typename = 'File symlink';
|
||||
$this->typeflag = 'l';
|
||||
} else {
|
||||
$this->typename = 'File';
|
||||
$this->typeflag = '-';
|
||||
}
|
||||
} elseif ($this->is_dir) {
|
||||
if ($this->is_link) {
|
||||
$this->typename = 'Directory symlink';
|
||||
$this->typeflag = 'l';
|
||||
} else {
|
||||
$this->typename = 'Directory';
|
||||
$this->typeflag = 'd';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->flags = [$this->typeflag];
|
||||
|
||||
// User
|
||||
$this->flags[] = (($this->perms & 0400) ? 'r' : '-');
|
||||
$this->flags[] = (($this->perms & 0200) ? 'w' : '-');
|
||||
if ($this->perms & 0100) {
|
||||
$this->flags[] = ($this->perms & 04000) ? 's' : 'x';
|
||||
} else {
|
||||
$this->flags[] = ($this->perms & 04000) ? 'S' : '-';
|
||||
}
|
||||
|
||||
// Group
|
||||
$this->flags[] = (($this->perms & 0040) ? 'r' : '-');
|
||||
$this->flags[] = (($this->perms & 0020) ? 'w' : '-');
|
||||
if ($this->perms & 0010) {
|
||||
$this->flags[] = ($this->perms & 02000) ? 's' : 'x';
|
||||
} else {
|
||||
$this->flags[] = ($this->perms & 02000) ? 'S' : '-';
|
||||
}
|
||||
|
||||
// Other
|
||||
$this->flags[] = (($this->perms & 0004) ? 'r' : '-');
|
||||
$this->flags[] = (($this->perms & 0002) ? 'w' : '-');
|
||||
if ($this->perms & 0001) {
|
||||
$this->flags[] = ($this->perms & 01000) ? 's' : 'x';
|
||||
} else {
|
||||
$this->flags[] = ($this->perms & 01000) ? 'S' : '-';
|
||||
}
|
||||
|
||||
$this->contents = \implode($this->flags).' '.$this->owner.' '.$this->group;
|
||||
$this->contents .= ' '.$this->getSize().' '.$this->getMTime().' ';
|
||||
|
||||
if ($this->is_link && $this->linktarget) {
|
||||
$this->contents .= $this->path.' -> '.$this->linktarget;
|
||||
} elseif (null !== $this->realpath && \strlen($this->realpath) < \strlen($this->path)) {
|
||||
$this->contents .= $this->realpath;
|
||||
} else {
|
||||
$this->contents .= $this->path;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->typename.' ('.$this->getSize().')';
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
if ($this->size) {
|
||||
$size = Utils::getHumanReadableBytes($this->size);
|
||||
|
||||
return \round($size['value'], 2).$size['unit'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getMTime()
|
||||
{
|
||||
$year = \date('Y', $this->mtime);
|
||||
|
||||
if ($year !== \date('Y')) {
|
||||
return \date('M d Y', $this->mtime);
|
||||
}
|
||||
|
||||
return \date('M d H:i', $this->mtime);
|
||||
}
|
||||
}
|
||||
49
system/ThirdParty/Kint/Zval/ResourceValue.php
vendored
Normal file
49
system/ThirdParty/Kint/Zval/ResourceValue.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class ResourceValue extends Value
|
||||
{
|
||||
public $resource_type;
|
||||
|
||||
public function getType()
|
||||
{
|
||||
if ($this->resource_type) {
|
||||
return $this->resource_type.' resource';
|
||||
}
|
||||
|
||||
return 'resource';
|
||||
}
|
||||
|
||||
public function transplant(Value $old)
|
||||
{
|
||||
parent::transplant($old);
|
||||
|
||||
if ($old instanceof self) {
|
||||
$this->resource_type = $old->resource_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
system/ThirdParty/Kint/Zval/SimpleXMLElementValue.php
vendored
Normal file
48
system/ThirdParty/Kint/Zval/SimpleXMLElementValue.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class SimpleXMLElementValue extends InstanceValue
|
||||
{
|
||||
public $hints = ['object', 'simplexml_element'];
|
||||
|
||||
protected $is_string_value = false;
|
||||
|
||||
/**
|
||||
* @param bool $is_string_value
|
||||
*/
|
||||
public function setIsStringValue($is_string_value)
|
||||
{
|
||||
$this->is_string_value = $is_string_value;
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if ($this->is_string_value && ($rep = $this->value) && 'contents' === $rep->getName() && 'string' === \gettype($rep->contents)) {
|
||||
return '"'.$rep->contents.'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
54
system/ThirdParty/Kint/Zval/StreamValue.php
vendored
Normal file
54
system/ThirdParty/Kint/Zval/StreamValue.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use Kint\Kint;
|
||||
|
||||
class StreamValue extends ResourceValue
|
||||
{
|
||||
public $stream_meta;
|
||||
|
||||
public function __construct(array $meta = null)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->stream_meta = $meta;
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if (empty($this->stream_meta['uri'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uri = $this->stream_meta['uri'];
|
||||
|
||||
if (\stream_is_local($uri)) {
|
||||
return Kint::shortenPath($uri);
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
54
system/ThirdParty/Kint/Zval/ThrowableValue.php
vendored
Normal file
54
system/ThirdParty/Kint/Zval/ThrowableValue.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Throwable;
|
||||
|
||||
class ThrowableValue extends InstanceValue
|
||||
{
|
||||
public $message;
|
||||
public $hints = ['object', 'throwable'];
|
||||
|
||||
public function __construct($throw)
|
||||
{
|
||||
if (!$throw instanceof Exception && (!KINT_PHP70 || !$throw instanceof Throwable)) {
|
||||
throw new InvalidArgumentException('ThrowableValue must be constructed with a Throwable');
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->message = $throw->getMessage();
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if (\strlen($this->message)) {
|
||||
return '"'.$this->message.'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
105
system/ThirdParty/Kint/Zval/TraceFrameValue.php
vendored
Normal file
105
system/ThirdParty/Kint/Zval/TraceFrameValue.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Kint\Zval\Representation\Representation;
|
||||
use Kint\Zval\Representation\SourceRepresentation;
|
||||
use ReflectionFunction;
|
||||
use ReflectionMethod;
|
||||
|
||||
class TraceFrameValue extends Value
|
||||
{
|
||||
public $trace;
|
||||
public $hints = ['trace_frame'];
|
||||
|
||||
public function __construct(Value $base, array $raw_frame)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->transplant($base);
|
||||
|
||||
if (!isset($this->value)) {
|
||||
throw new InvalidArgumentException('Tried to create TraceFrameValue from Value with no value representation');
|
||||
}
|
||||
|
||||
$this->trace = [
|
||||
'function' => $raw_frame['function'],
|
||||
'line' => isset($raw_frame['line']) ? $raw_frame['line'] : null,
|
||||
'file' => isset($raw_frame['file']) ? $raw_frame['file'] : null,
|
||||
'class' => isset($raw_frame['class']) ? $raw_frame['class'] : null,
|
||||
'type' => isset($raw_frame['type']) ? $raw_frame['type'] : null,
|
||||
'object' => null,
|
||||
'args' => null,
|
||||
];
|
||||
|
||||
if ($this->trace['class'] && \method_exists($this->trace['class'], $this->trace['function'])) {
|
||||
$func = new ReflectionMethod($this->trace['class'], $this->trace['function']);
|
||||
$this->trace['function'] = new MethodValue($func);
|
||||
} elseif (!$this->trace['class'] && \function_exists($this->trace['function'])) {
|
||||
$func = new ReflectionFunction($this->trace['function']);
|
||||
$this->trace['function'] = new MethodValue($func);
|
||||
}
|
||||
|
||||
foreach ($this->value->contents as $frame_prop) {
|
||||
if ('object' === $frame_prop->name) {
|
||||
$this->trace['object'] = $frame_prop;
|
||||
$this->trace['object']->name = null;
|
||||
$this->trace['object']->operator = Value::OPERATOR_NONE;
|
||||
}
|
||||
if ('args' === $frame_prop->name) {
|
||||
$this->trace['args'] = $frame_prop->value->contents;
|
||||
|
||||
if ($this->trace['function'] instanceof MethodValue) {
|
||||
foreach (\array_values($this->trace['function']->parameters) as $param) {
|
||||
if (isset($this->trace['args'][$param->position])) {
|
||||
$this->trace['args'][$param->position]->name = $param->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->clearRepresentations();
|
||||
|
||||
if (isset($this->trace['file'], $this->trace['line']) && \is_readable($this->trace['file'])) {
|
||||
$this->addRepresentation(new SourceRepresentation($this->trace['file'], $this->trace['line']));
|
||||
}
|
||||
|
||||
if ($this->trace['args']) {
|
||||
$args = new Representation('Arguments');
|
||||
$args->contents = $this->trace['args'];
|
||||
$this->addRepresentation($args);
|
||||
}
|
||||
|
||||
if ($this->trace['object']) {
|
||||
$callee = new Representation('object');
|
||||
$callee->label = 'Callee object ['.$this->trace['object']->classname.']';
|
||||
$callee->contents[] = $this->trace['object'];
|
||||
$this->addRepresentation($callee);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
system/ThirdParty/Kint/Zval/TraceValue.php
vendored
Normal file
45
system/ThirdParty/Kint/Zval/TraceValue.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
class TraceValue extends Value
|
||||
{
|
||||
public $hints = ['trace'];
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'Debug Backtrace';
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
if (!$this->size) {
|
||||
return 'empty';
|
||||
}
|
||||
|
||||
return parent::getSize();
|
||||
}
|
||||
}
|
||||
248
system/ThirdParty/Kint/Zval/Value.php
vendored
Normal file
248
system/ThirdParty/Kint/Zval/Value.php
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Kint\Zval;
|
||||
|
||||
use Kint\Zval\Representation\Representation;
|
||||
|
||||
class Value
|
||||
{
|
||||
const ACCESS_NONE = null;
|
||||
const ACCESS_PUBLIC = 1;
|
||||
const ACCESS_PROTECTED = 2;
|
||||
const ACCESS_PRIVATE = 3;
|
||||
|
||||
const OPERATOR_NONE = null;
|
||||
const OPERATOR_ARRAY = 1;
|
||||
const OPERATOR_OBJECT = 2;
|
||||
const OPERATOR_STATIC = 3;
|
||||
|
||||
public $name;
|
||||
public $type;
|
||||
public $static = false;
|
||||
public $const = false;
|
||||
public $access = self::ACCESS_NONE;
|
||||
public $owner_class;
|
||||
public $access_path;
|
||||
public $operator = self::OPERATOR_NONE;
|
||||
public $reference = false;
|
||||
public $depth = 0;
|
||||
public $size;
|
||||
public $value;
|
||||
public $hints = [];
|
||||
|
||||
protected $representations = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function addRepresentation(Representation $rep, $pos = null)
|
||||
{
|
||||
if (isset($this->representations[$rep->getName()])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null === $pos) {
|
||||
$this->representations[$rep->getName()] = $rep;
|
||||
} else {
|
||||
$this->representations = \array_merge(
|
||||
\array_slice($this->representations, 0, $pos),
|
||||
[$rep->getName() => $rep],
|
||||
\array_slice($this->representations, $pos)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function replaceRepresentation(Representation $rep, $pos = null)
|
||||
{
|
||||
if (null === $pos) {
|
||||
$this->representations[$rep->getName()] = $rep;
|
||||
} else {
|
||||
$this->removeRepresentation($rep);
|
||||
$this->addRepresentation($rep, $pos);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeRepresentation($rep)
|
||||
{
|
||||
if ($rep instanceof Representation) {
|
||||
unset($this->representations[$rep->getName()]);
|
||||
} elseif (\is_string($rep)) {
|
||||
unset($this->representations[$rep]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRepresentation($name)
|
||||
{
|
||||
if (isset($this->representations[$name])) {
|
||||
return $this->representations[$name];
|
||||
}
|
||||
}
|
||||
|
||||
public function getRepresentations()
|
||||
{
|
||||
return $this->representations;
|
||||
}
|
||||
|
||||
public function clearRepresentations()
|
||||
{
|
||||
$this->representations = [];
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getModifiers()
|
||||
{
|
||||
$out = $this->getAccess();
|
||||
|
||||
if ($this->const) {
|
||||
$out .= ' const';
|
||||
}
|
||||
|
||||
if ($this->static) {
|
||||
$out .= ' static';
|
||||
}
|
||||
|
||||
if (null !== $out && \strlen($out)) {
|
||||
return \ltrim($out);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAccess()
|
||||
{
|
||||
switch ($this->access) {
|
||||
case self::ACCESS_PRIVATE:
|
||||
return 'private';
|
||||
case self::ACCESS_PROTECTED:
|
||||
return 'protected';
|
||||
case self::ACCESS_PUBLIC:
|
||||
return 'public';
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getOperator()
|
||||
{
|
||||
switch ($this->operator) {
|
||||
case self::OPERATOR_ARRAY:
|
||||
return '=>';
|
||||
case self::OPERATOR_OBJECT:
|
||||
return '->';
|
||||
case self::OPERATOR_STATIC:
|
||||
return '::';
|
||||
}
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function getValueShort()
|
||||
{
|
||||
if ($rep = $this->value) {
|
||||
if ('boolean' === $this->type) {
|
||||
return $rep->contents ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ('integer' === $this->type || 'double' === $this->type) {
|
||||
return $rep->contents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAccessPath()
|
||||
{
|
||||
return $this->access_path;
|
||||
}
|
||||
|
||||
public function transplant(Value $old)
|
||||
{
|
||||
$this->name = $old->name;
|
||||
$this->size = $old->size;
|
||||
$this->access_path = $old->access_path;
|
||||
$this->access = $old->access;
|
||||
$this->static = $old->static;
|
||||
$this->const = $old->const;
|
||||
$this->type = $old->type;
|
||||
$this->depth = $old->depth;
|
||||
$this->owner_class = $old->owner_class;
|
||||
$this->operator = $old->operator;
|
||||
$this->reference = $old->reference;
|
||||
$this->value = $old->value;
|
||||
$this->representations += $old->representations;
|
||||
$this->hints = \array_merge($this->hints, $old->hints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new basic object with a name and access path.
|
||||
*
|
||||
* @param null|string $name
|
||||
* @param null|string $access_path
|
||||
*
|
||||
* @return \Kint\Zval\Value
|
||||
*/
|
||||
public static function blank($name = null, $access_path = null)
|
||||
{
|
||||
$o = new self();
|
||||
$o->name = $name;
|
||||
$o->access_path = $access_path;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
public static function sortByAccess(Value $a, Value $b)
|
||||
{
|
||||
static $sorts = [
|
||||
self::ACCESS_PUBLIC => 1,
|
||||
self::ACCESS_PROTECTED => 2,
|
||||
self::ACCESS_PRIVATE => 3,
|
||||
self::ACCESS_NONE => 4,
|
||||
];
|
||||
|
||||
return $sorts[$a->access] - $sorts[$b->access];
|
||||
}
|
||||
|
||||
public static function sortByName(Value $a, Value $b)
|
||||
{
|
||||
$ret = \strnatcasecmp($a->name, $b->name);
|
||||
|
||||
if (0 === $ret) {
|
||||
return (int) \is_int($b->name) - (int) \is_int($a->name);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user