repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ProxyPlugin.php
system/ThirdParty/Kint/Parser/ProxyPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\ContextInterface; /** * @psalm-import-type ParserTrigger from Parser * * @psalm-api */ class ProxyPlugin implements PluginBeginInterface, PluginCompleteInterface { protected array $types; /** @psalm-var ParserTrigger */ protected int $triggers; /** @psalm-var callable */ protected $callback; private ?Parser $parser = null; /** * @psalm-param ParserTrigger $triggers * @psalm-param callable $callback */ public function __construct(array $types, int $triggers, $callback) { $this->types = $types; $this->triggers = $triggers; $this->callback = $callback; } public function setParser(Parser $p): void { $this->parser = $p; } public function getTypes(): array { return $this->types; } public function getTriggers(): int { return $this->triggers; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { return \call_user_func_array($this->callback, [ &$var, $c, Parser::TRIGGER_BEGIN, $this->parser, ]); } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { return \call_user_func_array($this->callback, [ &$var, $v, $trigger, $this->parser, ]); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/StreamPlugin.php
system/ThirdParty/Kint/Parser/StreamPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\ArrayContext; use Kint\Value\ResourceValue; use Kint\Value\StreamValue; use TypeError; class StreamPlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['resource']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$v instanceof ResourceValue) { return $v; } // Doublecheck that the resource is open before we get the metadata if (!\is_resource($var)) { return $v; } try { $meta = \stream_get_meta_data($var); } catch (TypeError $e) { return $v; } $c = $v->getContext(); $parser = $this->getParser(); $parsed_meta = []; foreach ($meta as $key => $val) { $base = new ArrayContext($key); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'stream_get_meta_data('.$ap.')['.\var_export($key, true).']'; } $val = $parser->parse($val, $base); $val->flags |= AbstractValue::FLAG_GENERATED; $parsed_meta[] = $val; } $stream = new StreamValue($c, $parsed_meta, $meta['uri'] ?? null); $stream->flags = $v->flags; $stream->appendRepresentations($v->getRepresentations()); return $stream; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ClassHooksPlugin.php
system/ThirdParty/Kint/Parser/ClassHooksPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\MethodContext; use Kint\Value\Context\PropertyContext; use Kint\Value\DeclaredCallableBag; use Kint\Value\InstanceValue; use Kint\Value\MethodValue; use Kint\Value\Representation\ContainerRepresentation; use ReflectionProperty; class ClassHooksPlugin extends AbstractPlugin implements PluginCompleteInterface { public static bool $verbose = false; /** @psalm-var array<class-string, array<string, MethodValue[]>> */ private array $cache = []; /** @psalm-var array<class-string, array<string, MethodValue[]>> */ private array $cache_verbose = []; public function getTypes(): array { return ['object']; } public function getTriggers(): int { if (!KINT_PHP84) { return Parser::TRIGGER_NONE; // @codeCoverageIgnore } return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$v instanceof InstanceValue) { return $v; } $props = $v->getRepresentation('properties'); if (!$props instanceof ContainerRepresentation) { return $v; } foreach ($props->getContents() as $prop) { $c = $prop->getContext(); if (!$c instanceof PropertyContext || PropertyContext::HOOK_NONE === $c->hooks) { continue; } $cname = $c->getName(); $cowner = $c->owner_class; if (!isset($this->cache_verbose[$cowner][$cname])) { $ref = new ReflectionProperty($cowner, $cname); $hooks = $ref->getHooks(); foreach ($hooks as $hook) { if (!self::$verbose && false === $hook->getDocComment()) { continue; } $m = new MethodValue( new MethodContext($hook), new DeclaredCallableBag($hook) ); $this->cache_verbose[$cowner][$cname][] = $m; if (false !== $hook->getDocComment()) { $this->cache[$cowner][$cname][] = $m; } } $this->cache[$cowner][$cname] ??= []; if (self::$verbose) { $this->cache_verbose[$cowner][$cname] ??= []; } } $cache = self::$verbose ? $this->cache_verbose : $this->cache; $cache = $cache[$cowner][$cname] ?? []; if (\count($cache)) { $prop->addRepresentation(new ContainerRepresentation('Hooks', $cache, 'propertyhooks')); } } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/MysqliPlugin.php
system/ThirdParty/Kint/Parser/MysqliPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\PropertyContext; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use mysqli; use Throwable; /** * Adds support for mysqli object parsing. * * Due to the way mysqli is implemented in PHP, this will cause * warnings on certain mysqli objects if screaming is enabled. */ class MysqliPlugin extends AbstractPlugin implements PluginCompleteInterface { // These 'properties' are actually globals public const ALWAYS_READABLE = [ 'client_version' => true, 'connect_errno' => true, 'connect_error' => true, ]; // These are readable on empty mysqli objects, but not on failed connections public const EMPTY_READABLE = [ 'client_info' => true, 'errno' => true, 'error' => true, ]; // These are only readable on connected mysqli objects public const CONNECTED_READABLE = [ 'affected_rows' => true, 'error_list' => true, 'field_count' => true, 'host_info' => true, 'info' => true, 'insert_id' => true, 'server_info' => true, 'server_version' => true, 'sqlstate' => true, 'protocol_version' => true, 'thread_id' => true, 'warning_count' => true, ]; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_COMPLETE; } /** * Before 8.1: Properties were nulls when cast to array * After 8.1: Properties are readonly and uninitialized when cast to array (Aka missing). */ public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof mysqli || !$v instanceof InstanceValue) { return $v; } $props = $v->getRepresentation('properties'); if (!$props instanceof ContainerRepresentation) { return $v; } /** * @psalm-var ?string $var->sqlstate * @psalm-var ?string $var->client_info * Psalm bug #4502 */ try { $connected = \is_string(@$var->sqlstate); } catch (Throwable $t) { $connected = false; } try { $empty = !$connected && \is_string(@$var->client_info); } catch (Throwable $t) { // @codeCoverageIgnore // Only possible in PHP 8.0. Before 8.0 there's no exception, // after 8.1 there are no failed connection objects $empty = false; // @codeCoverageIgnore } $parser = $this->getParser(); $new_contents = []; foreach ($props->getContents() as $key => $obj) { $new_contents[$key] = $obj; $c = $obj->getContext(); if (!$c instanceof PropertyContext) { continue; } if (isset(self::CONNECTED_READABLE[$c->getName()])) { $c->readonly = KINT_PHP81; if (!$connected) { // No failed connections after PHP 8.1 continue; // @codeCoverageIgnore } } elseif (isset(self::EMPTY_READABLE[$c->getName()])) { $c->readonly = KINT_PHP81; // No failed connections after PHP 8.1 if (!$connected && !$empty) { // @codeCoverageIgnore continue; // @codeCoverageIgnore } } elseif (!isset(self::ALWAYS_READABLE[$c->getName()])) { continue; // @codeCoverageIgnore } $c->readonly = KINT_PHP81; // Only handle unparsed properties if ((KINT_PHP81 ? 'uninitialized' : 'null') !== $obj->getType()) { continue; } $param = $var->{$c->getName()}; // If it really was a null if (!KINT_PHP81 && null === $param) { continue; // @codeCoverageIgnore } $new_contents[$key] = $parser->parse($param, $c); } $new_contents = \array_values($new_contents); $v->setChildren($new_contents); if ($new_contents) { $v->replaceRepresentation(new ContainerRepresentation('Properties', $new_contents)); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ArrayObjectPlugin.php
system/ThirdParty/Kint/Parser/ArrayObjectPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use ArrayObject; use Kint\Value\AbstractValue; use Kint\Value\Context\ContextInterface; class ArrayObjectPlugin extends AbstractPlugin implements PluginBeginInterface { public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_BEGIN; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { if (!$var instanceof ArrayObject) { return null; } $flags = $var->getFlags(); if (ArrayObject::STD_PROP_LIST === $flags) { return null; } $parser = $this->getParser(); $var->setFlags(ArrayObject::STD_PROP_LIST); $v = $parser->parse($var, $c); $var->setFlags($flags); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ClosurePlugin.php
system/ThirdParty/Kint/Parser/ClosurePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Closure; use Kint\Value\AbstractValue; use Kint\Value\ClosureValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ContainerRepresentation; use ReflectionFunction; use ReflectionReference; class ClosurePlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof Closure) { return $v; } $c = $v->getContext(); $object = new ClosureValue($c, $var); $object->flags = $v->flags; $object->appendRepresentations($v->getRepresentations()); $object->removeRepresentation('properties'); $closure = new ReflectionFunction($var); $statics = []; if ($v = $closure->getClosureThis()) { $statics = ['this' => $v]; } $statics = $statics + $closure->getStaticVariables(); $cdepth = $c->getDepth(); if (\count($statics)) { $statics_parsed = []; $parser = $this->getParser(); foreach ($statics as $name => $_) { $base = new BaseContext('$'.$name); $base->depth = $cdepth + 1; $base->reference = null !== ReflectionReference::fromArrayElement($statics, $name); $statics_parsed[$name] = $parser->parse($statics[$name], $base); } $object->addRepresentation(new ContainerRepresentation('Uses', $statics_parsed), 0); } return $object; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/DateTimePlugin.php
system/ThirdParty/Kint/Parser/DateTimePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use DateTimeInterface; use Error; use Kint\Value\AbstractValue; use Kint\Value\DateTimeValue; use Kint\Value\InstanceValue; class DateTimePlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof DateTimeInterface || !$v instanceof InstanceValue) { return $v; } try { $dtv = new DateTimeValue($v->getContext(), $var); } catch (Error $e) { // Only happens if someone makes a DateTimeInterface with a private __clone return $v; } $dtv->setChildren($v->getChildren()); $dtv->flags = $v->flags; $dtv->appendRepresentations($v->getRepresentations()); return $dtv; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ThrowablePlugin.php
system/ThirdParty/Kint/Parser/ThrowablePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\InstanceValue; use Kint\Value\Representation\SourceRepresentation; use Kint\Value\ThrowableValue; use RuntimeException; use Throwable; class ThrowablePlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof Throwable || !$v instanceof InstanceValue) { return $v; } $throw = new ThrowableValue($v->getContext(), $var); $throw->setChildren($v->getChildren()); $throw->flags = $v->flags; $throw->appendRepresentations($v->getRepresentations()); try { $throw->addRepresentation(new SourceRepresentation($var->getFile(), $var->getLine(), null, true), 0); } catch (RuntimeException $e) { } return $throw; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/EnumPlugin.php
system/ThirdParty/Kint/Parser/EnumPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\EnumValue; use Kint\Value\Representation\ContainerRepresentation; use UnitEnum; class EnumPlugin extends AbstractPlugin implements PluginCompleteInterface { private array $cache = []; public function getTypes(): array { return ['object']; } public function getTriggers(): int { if (!KINT_PHP81) { return Parser::TRIGGER_NONE; } return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof UnitEnum) { return $v; } $c = $v->getContext(); $class = \get_class($var); if (!isset($this->cache[$class])) { $contents = []; foreach ($var->cases() as $case) { $base = new BaseContext($case->name); $base->access_path = '\\'.$class.'::'.$case->name; $base->depth = $c->getDepth() + 1; $contents[] = new EnumValue($base, $case); } /** @psalm-var non-empty-array<EnumValue> $contents */ $this->cache[$class] = new ContainerRepresentation('Enum values', $contents, 'enum'); } $object = new EnumValue($c, $var); $object->flags = $v->flags; $object->appendRepresentations($v->getRepresentations()); $object->addRepresentation($this->cache[$class], 0); return $object; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/BlacklistPlugin.php
system/ThirdParty/Kint/Parser/BlacklistPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\ContextInterface; use Kint\Value\InstanceValue; use Psr\Container\ContainerInterface; use Psr\EventDispatcher\EventDispatcherInterface; class BlacklistPlugin extends AbstractPlugin implements PluginBeginInterface { /** * List of classes and interfaces to blacklist. * * @var class-string[] */ public static array $blacklist = []; /** * List of classes and interfaces to blacklist except when dumped directly. * * @var class-string[] */ public static array $shallow_blacklist = [ ContainerInterface::class, EventDispatcherInterface::class, ]; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_BEGIN; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { foreach (self::$blacklist as $class) { if ($var instanceof $class) { return $this->blacklistValue($var, $c); } } if ($c->getDepth() <= 0) { return null; } foreach (self::$shallow_blacklist as $class) { if ($var instanceof $class) { return $this->blacklistValue($var, $c); } } return null; } /** * @param object &$var */ protected function blacklistValue(&$var, ContextInterface $c): InstanceValue { $object = new InstanceValue($c, \get_class($var), \spl_object_hash($var), \spl_object_id($var)); $object->flags |= AbstractValue::FLAG_BLACKLIST; return $object; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ClassStaticsPlugin.php
system/ThirdParty/Kint/Parser/ClassStaticsPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\ClassConstContext; use Kint\Value\Context\ClassDeclaredContext; use Kint\Value\Context\StaticPropertyContext; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\UninitializedValue; use ReflectionClass; use ReflectionClassConstant; use ReflectionProperty; use UnitEnum; class ClassStaticsPlugin extends AbstractPlugin implements PluginCompleteInterface { /** @psalm-var array<class-string, array<1|0, array<AbstractValue>>> */ private array $cache = []; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } /** * @psalm-template T of AbstractValue * * @psalm-param mixed $var * @psalm-param T $v * * @psalm-return T */ public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$v instanceof InstanceValue) { return $v; } $deep = 0 === $this->getParser()->getDepthLimit(); $r = new ReflectionClass($v->getClassName()); if ($statics = $this->getStatics($r, $v->getContext()->getDepth() + 1)) { $v->addRepresentation(new ContainerRepresentation('Static properties', \array_values($statics), 'statics')); } if ($consts = $this->getCachedConstants($r, $deep)) { $v->addRepresentation(new ContainerRepresentation('Class constants', \array_values($consts), 'constants')); } return $v; } /** @psalm-return array<AbstractValue> */ private function getStatics(ReflectionClass $r, int $depth): array { $cdepth = $depth ?: 1; $class = $r->getName(); $parent = $r->getParentClass(); $parent_statics = $parent ? $this->getStatics($parent, $depth) : []; $statics = []; foreach ($r->getProperties(ReflectionProperty::IS_STATIC) as $pr) { $canon_name = \strtolower($pr->getDeclaringClass()->name.'::'.$pr->name); if ($pr->getDeclaringClass()->name === $class) { $statics[$canon_name] = $this->buildStaticValue($pr, $cdepth); } elseif (isset($parent_statics[$canon_name])) { $statics[$canon_name] = $parent_statics[$canon_name]; unset($parent_statics[$canon_name]); } else { // This should never happen since abstract static properties can't exist $statics[$canon_name] = $this->buildStaticValue($pr, $cdepth); // @codeCoverageIgnore } } foreach ($parent_statics as $canon_name => $value) { $statics[$canon_name] = $value; } return $statics; } private function buildStaticValue(ReflectionProperty $pr, int $depth): AbstractValue { $context = new StaticPropertyContext( $pr->name, $pr->getDeclaringClass()->name, ClassDeclaredContext::ACCESS_PUBLIC ); $context->depth = $depth; $context->final = KINT_PHP84 && $pr->isFinal(); if ($pr->isProtected()) { $context->access = ClassDeclaredContext::ACCESS_PROTECTED; } elseif ($pr->isPrivate()) { $context->access = ClassDeclaredContext::ACCESS_PRIVATE; } $parser = $this->getParser(); if ($context->isAccessible($parser->getCallerClass())) { $context->access_path = '\\'.$context->owner_class.'::$'.$context->name; } $pr->setAccessible(true); /** * @psalm-suppress TooFewArguments * Appears to have been fixed in master. */ if (!$pr->isInitialized()) { $context->access_path = null; return new UninitializedValue($context); } $val = $pr->getValue(); $out = $this->getParser()->parse($val, $context); $context->access_path = null; return $out; } /** @psalm-return array<AbstractValue> */ private function getCachedConstants(ReflectionClass $r, bool $deep): array { $parser = $this->getParser(); $cdepth = $parser->getDepthLimit() ?: 1; $deepkey = (int) $deep; $class = $r->getName(); // Separate cache for dumping with/without depth limit // This means we can do immediate depth limit on normal dumps if (!isset($this->cache[$class][$deepkey])) { $consts = []; $parent_consts = []; if ($parent = $r->getParentClass()) { $parent_consts = $this->getCachedConstants($parent, $deep); } foreach ($r->getConstants() as $name => $val) { $cr = new ReflectionClassConstant($class, $name); // Skip enum constants if ($cr->class === $class && \is_a($class, UnitEnum::class, true)) { continue; } $canon_name = \strtolower($cr->getDeclaringClass()->name.'::'.$name); if ($cr->getDeclaringClass()->name === $class) { $context = $this->buildConstContext($cr); $context->depth = $cdepth; $consts[$canon_name] = $parser->parse($val, $context); $context->access_path = null; } elseif (isset($parent_consts[$canon_name])) { $consts[$canon_name] = $parent_consts[$canon_name]; } else { $context = $this->buildConstContext($cr); $context->depth = $cdepth; $consts[$canon_name] = $parser->parse($val, $context); $context->access_path = null; } unset($parent_consts[$canon_name]); } $this->cache[$class][$deepkey] = $consts + $parent_consts; } return $this->cache[$class][$deepkey]; } private function buildConstContext(ReflectionClassConstant $cr): ClassConstContext { $context = new ClassConstContext( $cr->name, $cr->getDeclaringClass()->name, ClassDeclaredContext::ACCESS_PUBLIC ); $context->final = KINT_PHP81 && $cr->isFinal(); if ($cr->isProtected()) { $context->access = ClassDeclaredContext::ACCESS_PROTECTED; } elseif ($cr->isPrivate()) { $context->access = ClassDeclaredContext::ACCESS_PRIVATE; } else { $context->access_path = '\\'.$context->owner_class.'::'.$context->name; } return $context; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/HtmlPlugin.php
system/ThirdParty/Kint/Parser/HtmlPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Dom\HTMLDocument; use DOMException; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ValueRepresentation; class HtmlPlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['string']; } public function getTriggers(): int { if (!KINT_PHP84) { return Parser::TRIGGER_NONE; // @codeCoverageIgnore } return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if ('<!doctype html>' !== \strtolower(\substr($var, 0, 15))) { return $v; } try { $html = HTMLDocument::createFromString($var, LIBXML_NOERROR); } catch (DOMException $e) { // @codeCoverageIgnore return $v; // @codeCoverageIgnore } $c = $v->getContext(); $base = new BaseContext('childNodes'); $base->depth = $c->getDepth(); if (null !== ($ap = $c->getAccessPath())) { $base->access_path = '\\Dom\\HTMLDocument::createFromString('.$ap.')->childNodes'; } $out = $this->getParser()->parse($html->childNodes, $base); $iter = $out->getRepresentation('iterator'); if ($out->flags & AbstractValue::FLAG_DEPTH_LIMIT) { $out->flags |= AbstractValue::FLAG_GENERATED; $v->addRepresentation(new ValueRepresentation('HTML', $out), 0); } elseif ($iter instanceof ContainerRepresentation) { $v->addRepresentation(new ContainerRepresentation('HTML', $iter->getContents()), 0); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ClassMethodsPlugin.php
system/ThirdParty/Kint/Parser/ClassMethodsPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\MethodContext; use Kint\Value\DeclaredCallableBag; use Kint\Value\InstanceValue; use Kint\Value\MethodValue; use Kint\Value\Representation\ContainerRepresentation; use ReflectionClass; use ReflectionMethod; class ClassMethodsPlugin extends AbstractPlugin implements PluginCompleteInterface { public static bool $show_access_path = true; /** * Whether to go out of the way to show constructor paths * when the instance isn't accessible. * * Disabling this improves performance. */ public static bool $show_constructor_path = false; /** @psalm-var array<class-string, MethodValue[]> */ private array $instance_cache = []; /** @psalm-var array<class-string, MethodValue[]> */ private array $static_cache = []; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } /** * @psalm-template T of AbstractValue * * @psalm-param mixed $var * @psalm-param T $v * * @psalm-return T */ public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$v instanceof InstanceValue) { return $v; } $class = $v->getClassName(); $scope = $this->getParser()->getCallerClass(); if ($contents = $this->getCachedMethods($class)) { if (self::$show_access_path) { if (null !== $v->getContext()->getAccessPath()) { // If we have an access path we can generate them for the children foreach ($contents as $key => $val) { if ($val->getContext()->isAccessible($scope)) { $val = clone $val; $val->getContext()->setAccessPathFromParent($v); $contents[$key] = $val; } } } elseif (self::$show_constructor_path && isset($contents['__construct'])) { // __construct is the only exception: The only non-static method // that can be called without access to the parent instance. // Technically I guess it really is a static method but so long // as PHP continues to refer to it as a normal one so will we. $val = $contents['__construct']; if ($val->getContext()->isAccessible($scope)) { $val = clone $val; $val->getContext()->setAccessPathFromParent($v); $contents['__construct'] = $val; } } } $v->addRepresentation(new ContainerRepresentation('Methods', $contents)); } if ($contents = $this->getCachedStaticMethods($class)) { $v->addRepresentation(new ContainerRepresentation('Static methods', $contents)); } return $v; } /** * @psalm-param class-string $class * * @psalm-return MethodValue[] */ private function getCachedMethods(string $class): array { if (!isset($this->instance_cache[$class])) { $methods = []; $r = new ReflectionClass($class); $parent_methods = []; if ($parent = \get_parent_class($class)) { $parent_methods = $this->getCachedMethods($parent); } foreach ($r->getMethods() as $mr) { if ($mr->isStatic()) { continue; } $canon_name = \strtolower($mr->name); if ($mr->isPrivate() && '__construct' !== $canon_name) { $canon_name = \strtolower($mr->getDeclaringClass()->name).'::'.$canon_name; } if ($mr->getDeclaringClass()->name === $class) { $method = new MethodValue(new MethodContext($mr), new DeclaredCallableBag($mr)); $methods[$canon_name] = $method; unset($parent_methods[$canon_name]); } elseif (isset($parent_methods[$canon_name])) { $method = $parent_methods[$canon_name]; unset($parent_methods[$canon_name]); if (!$method->getContext()->inherited) { $method = clone $method; $method->getContext()->inherited = true; } $methods[$canon_name] = $method; } elseif ($mr->getDeclaringClass()->isInterface()) { $c = new MethodContext($mr); $c->inherited = true; $methods[$canon_name] = new MethodValue($c, new DeclaredCallableBag($mr)); } } foreach ($parent_methods as $name => $method) { if (!$method->getContext()->inherited) { $method = clone $method; $method->getContext()->inherited = true; } if ('__construct' === $name) { $methods['__construct'] = $method; } else { $methods[] = $method; } } $this->instance_cache[$class] = $methods; } return $this->instance_cache[$class]; } /** * @psalm-param class-string $class * * @psalm-return MethodValue[] */ private function getCachedStaticMethods(string $class): array { if (!isset($this->static_cache[$class])) { $methods = []; $r = new ReflectionClass($class); $parent_methods = []; if ($parent = \get_parent_class($class)) { $parent_methods = $this->getCachedStaticMethods($parent); } foreach ($r->getMethods(ReflectionMethod::IS_STATIC) as $mr) { $canon_name = \strtolower($mr->getDeclaringClass()->name.'::'.$mr->name); if ($mr->getDeclaringClass()->name === $class) { $method = new MethodValue(new MethodContext($mr), new DeclaredCallableBag($mr)); $methods[$canon_name] = $method; } elseif (isset($parent_methods[$canon_name])) { $methods[$canon_name] = $parent_methods[$canon_name]; } elseif ($mr->getDeclaringClass()->isInterface()) { $c = new MethodContext($mr); $c->inherited = true; $methods[$canon_name] = new MethodValue($c, new DeclaredCallableBag($mr)); } unset($parent_methods[$canon_name]); } $this->static_cache[$class] = $methods + $parent_methods; } return $this->static_cache[$class]; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/IteratorPlugin.php
system/ThirdParty/Kint/Parser/IteratorPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Dom\NamedNodeMap; use Dom\NodeList; use DOMNamedNodeMap; use DOMNodeList; use Kint\Value\AbstractValue; use Kint\Value\ArrayValue; use Kint\Value\Context\BaseContext; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ValueRepresentation; use Kint\Value\UninitializedValue; use mysqli_result; use PDOStatement; use SimpleXMLElement; use SplFileObject; use Throwable; use Traversable; class IteratorPlugin extends AbstractPlugin implements PluginCompleteInterface { /** * List of classes and interfaces to blacklist. * * Certain classes (Such as PDOStatement) irreversibly lose information * when traversed. Others are just huge. Either way, put them in here * and you won't have to worry about them being parsed. * * @psalm-var class-string[] */ public static array $blacklist = [ NamedNodeMap::class, NodeList::class, DOMNamedNodeMap::class, DOMNodeList::class, mysqli_result::class, PDOStatement::class, SimpleXMLElement::class, SplFileObject::class, ]; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$var instanceof Traversable || !$v instanceof InstanceValue || $v->getRepresentation('iterator')) { return $v; } $c = $v->getContext(); foreach (self::$blacklist as $class) { /** * @psalm-suppress RedundantCondition * Psalm bug #11076 */ if ($var instanceof $class) { $base = new BaseContext($class.' Iterator Contents'); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'iterator_to_array('.$ap.', false)'; } $b = new UninitializedValue($base); $b->flags |= AbstractValue::FLAG_BLACKLIST; $v->addRepresentation(new ValueRepresentation('Iterator', $b)); return $v; } } try { $data = \iterator_to_array($var, false); } catch (Throwable $t) { return $v; } if (!\count($data)) { return $v; } $base = new BaseContext('Iterator Contents'); $base->depth = $c->getDepth(); if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'iterator_to_array('.$ap.', false)'; } $iter_val = $this->getParser()->parse($data, $base); // Since we didn't get TRIGGER_DEPTH_LIMIT and set the iterator to the // same depth we can assume at least 1 level deep will exist if ($iter_val instanceof ArrayValue && $iterator_items = $iter_val->getContents()) { $r = new ContainerRepresentation('Iterator', $iterator_items); $iterator_items = \array_values($iterator_items); } else { $r = new ValueRepresentation('Iterator', $iter_val); $iterator_items = [$iter_val]; } if ((bool) $v->getChildren()) { $v->addRepresentation($r); } else { $v->setChildren($iterator_items); $v->addRepresentation($r, 0); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/PluginCompleteInterface.php
system/ThirdParty/Kint/Parser/PluginCompleteInterface.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; /** * @psalm-import-type ParserTrigger from Parser */ interface PluginCompleteInterface extends PluginInterface { /** * @psalm-param mixed &$var * @psalm-param ParserTrigger $trigger */ public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/DomPlugin.php
system/ThirdParty/Kint/Parser/DomPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Dom\Attr; use Dom\CharacterData; use Dom\Document; use Dom\DocumentType; use Dom\Element; use Dom\HTMLElement; use Dom\NamedNodeMap; use Dom\Node; use Dom\NodeList; use DOMAttr; use DOMCharacterData; use DOMDocumentType; use DOMElement; use DOMNamedNodeMap; use DOMNode; use DOMNodeList; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ClassDeclaredContext; use Kint\Value\Context\ContextInterface; use Kint\Value\Context\PropertyContext; use Kint\Value\DomNodeListValue; use Kint\Value\DomNodeValue; use Kint\Value\FixedWidthValue; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\StringValue; use LogicException; class DomPlugin extends AbstractPlugin implements PluginBeginInterface { /** * Reflection doesn't work below 8.1, also it won't show readonly status. * * In order to ensure this is stable enough we're only going to provide * properties for element and node. If subclasses like attr or document * have their own fields then tough shit we're not showing them. * * @psalm-var non-empty-array<string, bool> Property names to readable status */ public const NODE_PROPS = [ 'nodeType' => true, 'nodeName' => true, 'baseURI' => true, 'isConnected' => true, 'ownerDocument' => true, 'parentNode' => true, 'parentElement' => true, 'childNodes' => true, 'firstChild' => true, 'lastChild' => true, 'previousSibling' => true, 'nextSibling' => true, 'nodeValue' => true, 'textContent' => false, ]; /** * @psalm-var non-empty-array<string, bool> Property names to readable status */ public const ELEMENT_PROPS = [ 'namespaceURI' => true, 'prefix' => true, 'localName' => true, 'tagName' => true, 'id' => false, 'className' => false, 'classList' => true, 'attributes' => true, 'firstElementChild' => true, 'lastElementChild' => true, 'childElementCount' => true, 'previousElementSibling' => true, 'nextElementSibling' => true, 'innerHTML' => false, 'outerHTML' => false, 'substitutedNodeValue' => false, ]; public const DOM_NS_VERSIONS = [ 'outerHTML' => KINT_PHP85, ]; /** * @psalm-var non-empty-array<string, bool> Property names to readable status */ public const DOMNODE_PROPS = [ 'nodeName' => true, 'nodeValue' => false, 'nodeType' => true, 'parentNode' => true, 'parentElement' => true, 'childNodes' => true, 'firstChild' => true, 'lastChild' => true, 'previousSibling' => true, 'nextSibling' => true, 'attributes' => true, 'isConnected' => true, 'ownerDocument' => true, 'namespaceURI' => true, 'prefix' => false, 'localName' => true, 'baseURI' => true, 'textContent' => false, ]; /** * @psalm-var non-empty-array<string, bool> Property names to readable status */ public const DOMELEMENT_PROPS = [ 'tagName' => true, 'className' => false, 'id' => false, 'schemaTypeInfo' => true, 'firstElementChild' => true, 'lastElementChild' => true, 'childElementCount' => true, 'previousElementSibling' => true, 'nextElementSibling' => true, ]; public const DOM_VERSIONS = [ 'parentElement' => KINT_PHP83, 'isConnected' => KINT_PHP83, 'className' => KINT_PHP83, 'id' => KINT_PHP83, 'firstElementChild' => KINT_PHP80, 'lastElementChild' => KINT_PHP80, 'childElementCount' => KINT_PHP80, 'previousElementSibling' => KINT_PHP80, 'nextElementSibling' => KINT_PHP80, ]; /** * List of properties to skip parsing. * * The properties of a Dom\Node can do a *lot* of damage to debuggers. The * Dom\Node contains not one, not two, but 13 different ways to recurse into itself: * * parentNode * * firstChild * * lastChild * * previousSibling * * nextSibling * * parentElement * * firstElementChild * * lastElementChild * * previousElementSibling * * nextElementSibling * * childNodes * * attributes * * ownerDocument * * All of this combined: the tiny SVGs used as the caret in Kint were already * enough to make parsing and rendering take over a second, and send memory * usage over 128 megs, back in the old DOM API. So we blacklist every field * we don't strictly need and hope that that's good enough. * * In retrospect -- this is probably why print_r does the same * * @psalm-var array<string, true> */ public static array $blacklist = [ 'parentNode' => true, 'firstChild' => true, 'lastChild' => true, 'previousSibling' => true, 'nextSibling' => true, 'firstElementChild' => true, 'lastElementChild' => true, 'parentElement' => true, 'previousElementSibling' => true, 'nextElementSibling' => true, 'ownerDocument' => true, ]; /** * Show all properties and methods. */ public static bool $verbose = false; protected ClassMethodsPlugin $methods_plugin; protected ClassStaticsPlugin $statics_plugin; public function __construct(Parser $parser) { parent::__construct($parser); $this->methods_plugin = new ClassMethodsPlugin($parser); $this->statics_plugin = new ClassStaticsPlugin($parser); } public function setParser(Parser $p): void { parent::setParser($p); $this->methods_plugin->setParser($p); $this->statics_plugin->setParser($p); } public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_BEGIN; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { // Attributes and chardata (Which is parent of comments and text // nodes) don't need children or attributes of their own if ($var instanceof Attr || $var instanceof CharacterData || $var instanceof DOMAttr || $var instanceof DOMCharacterData) { return $this->parseText($var, $c); } if ($var instanceof NamedNodeMap || $var instanceof NodeList || $var instanceof DOMNamedNodeMap || $var instanceof DOMNodeList) { return $this->parseList($var, $c); } if ($var instanceof Node || $var instanceof DOMNode) { return $this->parseNode($var, $c); } return null; } /** @psalm-param Node|DOMNode $var */ private function parseProperty(object $var, string $prop, ContextInterface $c): AbstractValue { if (!isset($var->{$prop})) { return new FixedWidthValue($c, null); } $parser = $this->getParser(); $value = $var->{$prop}; if (\is_scalar($value)) { return $parser->parse($value, $c); } if (isset(self::$blacklist[$prop])) { $b = new InstanceValue($c, \get_class($value), \spl_object_hash($value), \spl_object_id($value)); $b->flags |= AbstractValue::FLAG_GENERATED | AbstractValue::FLAG_BLACKLIST; return $b; } // Everything we can handle in parseBegin if ($value instanceof Attr || $value instanceof CharacterData || $value instanceof DOMAttr || $value instanceof DOMCharacterData || $value instanceof NamedNodeMap || $value instanceof NodeList || $value instanceof DOMNamedNodeMap || $value instanceof DOMNodeList || $value instanceof Node || $value instanceof DOMNode) { $out = $this->parseBegin($value, $c); } if (!isset($out)) { // Shouldn't ever happen $out = $parser->parse($value, $c); // @codeCoverageIgnore } $out->flags |= AbstractValue::FLAG_GENERATED; return $out; } /** @psalm-param Attr|CharacterData|DOMAttr|DOMCharacterData $var */ private function parseText(object $var, ContextInterface $c): AbstractValue { if ($c instanceof BaseContext && null !== $c->access_path) { $c->access_path .= '->nodeValue'; } return $this->parseProperty($var, 'nodeValue', $c); } /** @psalm-param NamedNodeMap|NodeList|DOMNamedNodeMap|DOMNodeList $var */ private function parseList(object $var, ContextInterface $c): InstanceValue { if ($var instanceof NodeList || $var instanceof DOMNodeList) { $v = new DomNodeListValue($c, $var); } else { $v = new InstanceValue($c, \get_class($var), \spl_object_hash($var), \spl_object_id($var)); } $parser = $this->getParser(); $pdepth = $parser->getDepthLimit(); // Depth limit // Use empty iterator representation since we need it to point out depth limits if (($var instanceof NodeList || $var instanceof DOMNodeList) && $pdepth && $c->getDepth() >= $pdepth) { $v->flags |= AbstractValue::FLAG_DEPTH_LIMIT; return $v; } if (self::$verbose) { $v = $this->methods_plugin->parseComplete($var, $v, Parser::TRIGGER_SUCCESS); $v = $this->statics_plugin->parseComplete($var, $v, Parser::TRIGGER_SUCCESS); } if (0 === $var->length) { $v->setChildren([]); return $v; } $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); $contents = []; foreach ($var as $key => $item) { $base_obj = new BaseContext($item->nodeName); $base_obj->depth = $cdepth + 1; if ($var instanceof NamedNodeMap || $var instanceof DOMNamedNodeMap) { if (null !== $ap) { $base_obj->access_path = $ap.'['.\var_export($item->nodeName, true).']'; } } else { // NodeList if (null !== $ap) { $base_obj->access_path = $ap.'['.\var_export($key, true).']'; } } if ($item instanceof HTMLElement) { $base_obj->name = $item->localName; } $item = $parser->parse($item, $base_obj); $item->flags |= AbstractValue::FLAG_GENERATED; $contents[] = $item; } $v->setChildren($contents); if ($contents) { $v->addRepresentation(new ContainerRepresentation('Iterator', $contents), 0); } return $v; } /** @psalm-param Node|DOMNode $var */ private function parseNode(object $var, ContextInterface $c): DomNodeValue { $class = \get_class($var); $pdepth = $this->getParser()->getDepthLimit(); if ($pdepth && $c->getDepth() >= $pdepth) { $v = new DomNodeValue($c, $var); $v->flags |= AbstractValue::FLAG_DEPTH_LIMIT; return $v; } if (($var instanceof DocumentType || $var instanceof DOMDocumentType) && $c instanceof BaseContext && $c->name === $var->nodeName) { $c->name = '!DOCTYPE '.$c->name; } $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); $properties = []; $children = []; $attributes = []; foreach (self::getKnownProperties($var) as $prop => $readonly) { $prop_c = new PropertyContext($prop, $class, ClassDeclaredContext::ACCESS_PUBLIC); $prop_c->depth = $cdepth + 1; $prop_c->readonly = KINT_PHP81 && $readonly; if (null !== $ap) { $prop_c->access_path = $ap.'->'.$prop; } $properties[] = $prop_obj = $this->parseProperty($var, $prop, $prop_c); if ('childNodes' === $prop) { if (!$prop_obj instanceof DomNodeListValue) { throw new LogicException('childNodes property parsed incorrectly'); // @codeCoverageIgnore } $children = self::getChildren($prop_obj); } elseif ('attributes' === $prop) { $attributes = $prop_obj->getRepresentation('iterator'); $attributes = $attributes instanceof ContainerRepresentation ? $attributes->getContents() : []; } elseif ('classList' === $prop) { if ($iter = $prop_obj->getRepresentation('iterator')) { $prop_obj->removeRepresentation($iter); $prop_obj->addRepresentation($iter, 0); } } } $v = new DomNodeValue($c, $var); // If we're in text mode, we can see children through the childNodes property $v->setChildren($properties); if ($children) { $v->addRepresentation(new ContainerRepresentation('Children', $children, null, true)); } if ($attributes) { $v->addRepresentation(new ContainerRepresentation('Attributes', $attributes)); } if (self::$verbose) { $v->addRepresentation(new ContainerRepresentation('Properties', $properties)); $v = $this->methods_plugin->parseComplete($var, $v, Parser::TRIGGER_SUCCESS); $v = $this->statics_plugin->parseComplete($var, $v, Parser::TRIGGER_SUCCESS); } return $v; } /** * @psalm-param Node|DOMNode $var * * @psalm-return non-empty-array<string, bool> */ public static function getKnownProperties(object $var): array { if ($var instanceof Node) { $known_properties = self::NODE_PROPS; if ($var instanceof Element) { $known_properties += self::ELEMENT_PROPS; } if ($var instanceof Document) { $known_properties['textContent'] = true; } if ($var instanceof Attr || $var instanceof CharacterData) { $known_properties['nodeValue'] = false; } foreach (self::DOM_NS_VERSIONS as $key => $val) { /** * @psalm-var bool $val * Psalm bug #4509 */ if (false === $val) { unset($known_properties[$key]); // @codeCoverageIgnore } } } else { $known_properties = self::DOMNODE_PROPS; if ($var instanceof DOMElement) { $known_properties += self::DOMELEMENT_PROPS; } foreach (self::DOM_VERSIONS as $key => $val) { /** * @psalm-var bool $val * Psalm bug #4509 */ if (false === $val) { unset($known_properties[$key]); // @codeCoverageIgnore } } } /** @psalm-var non-empty-array $known_properties */ if (!self::$verbose) { $known_properties = \array_intersect_key($known_properties, [ 'nodeValue' => null, 'childNodes' => null, 'attributes' => null, ]); } return $known_properties; } /** @psalm-return list<AbstractValue> */ private static function getChildren(DomNodeListValue $property): array { if (0 === $property->getLength()) { return []; } if ($property->flags & AbstractValue::FLAG_DEPTH_LIMIT) { return [$property]; } $list_items = $property->getChildren(); if (null === $list_items) { // This is here for psalm but all DomNodeListValue should // either be depth_limit or have array children return []; // @codeCoverageIgnore } $children = []; foreach ($list_items as $node) { // Remove text nodes if theyre empty if ($node instanceof StringValue && '#text' === $node->getContext()->getName()) { /** * @psalm-suppress InvalidArgument * Psalm bug #11055 */ if (\ctype_space($node->getValue()) || '' === $node->getValue()) { continue; } } $children[] = $node; } return $children; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/SplFileInfoPlugin.php
system/ThirdParty/Kint/Parser/SplFileInfoPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\InstanceValue; use Kint\Value\Representation\SplFileInfoRepresentation; use Kint\Value\SplFileInfoValue; use SplFileInfo; use SplFileObject; class SplFileInfoPlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { // SplFileObject throws exceptions in normal use in places SplFileInfo doesn't if (!$var instanceof SplFileInfo || $var instanceof SplFileObject) { return $v; } if (!$v instanceof InstanceValue) { return $v; } $out = new SplFileInfoValue($v->getContext(), $var); $out->setChildren($v->getChildren()); $out->flags = $v->flags; $out->addRepresentation(new SplFileInfoRepresentation(clone $var)); $out->appendRepresentations($v->getRepresentations()); return $out; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/FsPathPlugin.php
system/ThirdParty/Kint/Parser/FsPathPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Representation\SplFileInfoRepresentation; use SplFileInfo; use TypeError; class FsPathPlugin extends AbstractPlugin implements PluginCompleteInterface { public static array $blacklist = ['/', '.']; public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (\strlen($var) > 2048) { return $v; } if (!\preg_match('/[\\/\\'.DIRECTORY_SEPARATOR.']/', $var)) { return $v; } if (\preg_match('/[?<>"*|]/', $var)) { return $v; } try { if (!@\file_exists($var)) { return $v; } } catch (TypeError $e) {// @codeCoverageIgnore // Only possible in PHP 7 return $v; // @codeCoverageIgnore } if (\in_array($var, self::$blacklist, true)) { return $v; } $v->addRepresentation(new SplFileInfoRepresentation(new SplFileInfo($var)), 0); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ProfilePlugin.php
system/ThirdParty/Kint/Parser/ProfilePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ContextInterface; use Kint\Value\FixedWidthValue; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ProfileRepresentation; /** @psalm-api */ class ProfilePlugin extends AbstractPlugin implements PluginBeginInterface, PluginCompleteInterface { protected array $instance_counts = []; protected array $instance_complexity = []; protected array $instance_count_stack = []; protected array $class_complexity = []; protected array $class_count_stack = []; public function getTypes(): array { return ['string', 'object', 'array', 'integer', 'double', 'resource']; } public function getTriggers(): int { return Parser::TRIGGER_BEGIN | Parser::TRIGGER_COMPLETE; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { if (0 === $c->getDepth()) { $this->instance_counts = []; $this->instance_complexity = []; $this->instance_count_stack = []; $this->class_complexity = []; $this->class_count_stack = []; } if (\is_object($var)) { $hash = \spl_object_hash($var); $this->instance_counts[$hash] ??= 0; $this->instance_complexity[$hash] ??= 0; $this->instance_count_stack[$hash] ??= 0; if (0 === $this->instance_count_stack[$hash]) { foreach (\class_parents($var) as $class) { $this->class_count_stack[$class] ??= 0; ++$this->class_count_stack[$class]; } foreach (\class_implements($var) as $iface) { $this->class_count_stack[$iface] ??= 0; ++$this->class_count_stack[$iface]; } } ++$this->instance_count_stack[$hash]; } return null; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if ($v instanceof InstanceValue) { --$this->instance_count_stack[$v->getSplObjectHash()]; if (0 === $this->instance_count_stack[$v->getSplObjectHash()]) { foreach (\class_parents($var) as $class) { --$this->class_count_stack[$class]; } foreach (\class_implements($var) as $iface) { --$this->class_count_stack[$iface]; } } } // Don't check subs if we're in recursion or array limit if (~$trigger & Parser::TRIGGER_SUCCESS) { return $v; } $sub_complexity = 1; foreach ($v->getRepresentations() as $rep) { if ($rep instanceof ContainerRepresentation) { foreach ($rep->getContents() as $value) { $profile = $value->getRepresentation('profiling'); $sub_complexity += $profile instanceof ProfileRepresentation ? $profile->complexity : 1; } } else { ++$sub_complexity; } } if ($v instanceof InstanceValue) { ++$this->instance_counts[$v->getSplObjectHash()]; if (0 === $this->instance_count_stack[$v->getSplObjectHash()]) { $this->instance_complexity[$v->getSplObjectHash()] += $sub_complexity; $this->class_complexity[$v->getClassName()] ??= 0; $this->class_complexity[$v->getClassName()] += $sub_complexity; foreach (\class_parents($var) as $class) { $this->class_complexity[$class] ??= 0; if (0 === $this->class_count_stack[$class]) { $this->class_complexity[$class] += $sub_complexity; } } foreach (\class_implements($var) as $iface) { $this->class_complexity[$iface] ??= 0; if (0 === $this->class_count_stack[$iface]) { $this->class_complexity[$iface] += $sub_complexity; } } } } if (0 === $v->getContext()->getDepth()) { $contents = []; \arsort($this->class_complexity); foreach ($this->class_complexity as $name => $complexity) { $contents[] = new FixedWidthValue(new BaseContext($name), $complexity); } if ($contents) { $v->addRepresentation(new ContainerRepresentation('Class complexity', $contents), 0); } } $rep = new ProfileRepresentation($sub_complexity); /** @psalm-suppress UnsupportedReferenceUsage */ if ($v instanceof InstanceValue) { $rep->instance_counts = &$this->instance_counts[$v->getSplObjectHash()]; $rep->instance_complexity = &$this->instance_complexity[$v->getSplObjectHash()]; } $v->addRepresentation($rep, 0); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/XmlPlugin.php
system/ThirdParty/Kint/Parser/XmlPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Dom\Node; use Dom\XMLDocument; use DOMDocument; use DOMException; use DOMNode; use InvalidArgumentException; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\ValueRepresentation; use Throwable; class XmlPlugin extends AbstractPlugin implements PluginCompleteInterface { /** * Which method to parse the variable with. * * DOMDocument provides more information including the text between nodes, * however it's memory usage is very high and it takes longer to parse and * render. Plus it's a pain to work with. So SimpleXML is the default. * * @psalm-var 'SimpleXML'|'DOMDocument'|'XMLDocument' */ public static string $parse_method = 'SimpleXML'; public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if ('<?xml' !== \substr($var, 0, 5)) { return $v; } if (!\method_exists($this, 'xmlTo'.self::$parse_method)) { return $v; } $c = $v->getContext(); $out = \call_user_func([$this, 'xmlTo'.self::$parse_method], $var, $c); if (null === $out) { return $v; } $out->flags |= AbstractValue::FLAG_GENERATED; $v->addRepresentation(new ValueRepresentation('XML', $out), 0); return $v; } /** @psalm-suppress PossiblyUnusedMethod */ protected function xmlToSimpleXML(string $var, ContextInterface $c): ?AbstractValue { $errors = \libxml_use_internal_errors(true); try { $xml = \simplexml_load_string($var); if (!(bool) $xml) { throw new InvalidArgumentException('Bad XML parse in XmlPlugin::xmlToSimpleXML'); } } catch (Throwable $t) { return null; } finally { \libxml_use_internal_errors($errors); \libxml_clear_errors(); } $base = new BaseContext($xml->getName()); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'simplexml_load_string('.$ap.')'; } return $this->getParser()->parse($xml, $base); } /** * Get the DOMDocument info. * * If it errors loading then we wouldn't have gotten this far in the first place. * * @psalm-suppress PossiblyUnusedMethod * * @psalm-param non-empty-string $var */ protected function xmlToDOMDocument(string $var, ContextInterface $c): ?AbstractValue { try { $xml = new DOMDocument(); $check = $xml->loadXML($var, LIBXML_NOWARNING | LIBXML_NOERROR); if (false === $check) { throw new InvalidArgumentException('Bad XML parse in XmlPlugin::xmlToDOMDocument'); } } catch (Throwable $t) { return null; } $xml = $xml->firstChild; /** * @psalm-var DOMNode $xml * Psalm bug #11120 */ $base = new BaseContext($xml->nodeName); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = '(function($s){$x = new \\DomDocument(); $x->loadXML($s); return $x;})('.$ap.')->firstChild'; } return $this->getParser()->parse($xml, $base); } /** @psalm-suppress PossiblyUnusedMethod */ protected function xmlToXMLDocument(string $var, ContextInterface $c): ?AbstractValue { if (!KINT_PHP84) { return null; // @codeCoverageIgnore } try { $xml = XMLDocument::createFromString($var, LIBXML_NOWARNING | LIBXML_NOERROR); } catch (DOMException $e) { return null; } $xml = $xml->firstChild; /** * @psalm-var Node $xml * Psalm bug #11120 */ $base = new BaseContext($xml->nodeName); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = '\\Dom\\XMLDocument::createFromString('.$ap.')->firstChild'; } return $this->getParser()->parse($xml, $base); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/PluginBeginInterface.php
system/ThirdParty/Kint/Parser/PluginBeginInterface.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\ContextInterface; interface PluginBeginInterface extends PluginInterface { /** * @psalm-param mixed &$var */ public function parseBegin(&$var, ContextInterface $c): ?AbstractValue; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ToStringPlugin.php
system/ThirdParty/Kint/Parser/ToStringPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ValueRepresentation; use ReflectionClass; use SimpleXMLElement; use SplFileInfo; use Throwable; class ToStringPlugin extends AbstractPlugin implements PluginCompleteInterface { public static array $blacklist = [ SimpleXMLElement::class, SplFileInfo::class, ]; public function getTypes(): array { return ['object']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { $reflection = new ReflectionClass($var); if (!$reflection->hasMethod('__toString')) { return $v; } foreach (self::$blacklist as $class) { if ($var instanceof $class) { return $v; } } try { $string = (string) $var; } catch (Throwable $t) { return $v; } $c = $v->getContext(); $base = new BaseContext($c->getName()); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = '(string) '.$ap; } $string = $this->getParser()->parse($string, $base); $v->addRepresentation(new ValueRepresentation('toString', $string)); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/Parser.php
system/ThirdParty/Kint/Parser/Parser.php
<?php declare(strict_types=1); /* * 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\Parser; use DomainException; use InvalidArgumentException; use Kint\Utils; use Kint\Value\AbstractValue; use Kint\Value\ArrayValue; use Kint\Value\ClosedResourceValue; use Kint\Value\Context\ArrayContext; use Kint\Value\Context\ClassDeclaredContext; use Kint\Value\Context\ClassOwnedContext; use Kint\Value\Context\ContextInterface; use Kint\Value\Context\PropertyContext; use Kint\Value\FixedWidthValue; use Kint\Value\InstanceValue; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\StringRepresentation; use Kint\Value\ResourceValue; use Kint\Value\StringValue; use Kint\Value\UninitializedValue; use Kint\Value\UnknownValue; use Kint\Value\VirtualValue; use ReflectionClass; use ReflectionObject; use ReflectionProperty; use ReflectionReference; use Throwable; /** * @psalm-type ParserTrigger int-mask-of<Parser::TRIGGER_*> */ class Parser { /** * Plugin triggers. * * These are constants indicating trigger points for plugins * * BEGIN: Before normal parsing * SUCCESS: After successful parsing * RECURSION: After parsing cancelled by recursion * DEPTH_LIMIT: After parsing cancelled by depth limit * COMPLETE: SUCCESS | RECURSION | DEPTH_LIMIT * * While a plugin's getTriggers may return any of these only one should * be given to the plugin when PluginInterface::parse is called */ public const TRIGGER_NONE = 0; public const TRIGGER_BEGIN = 1 << 0; public const TRIGGER_SUCCESS = 1 << 1; public const TRIGGER_RECURSION = 1 << 2; public const TRIGGER_DEPTH_LIMIT = 1 << 3; public const TRIGGER_COMPLETE = self::TRIGGER_SUCCESS | self::TRIGGER_RECURSION | self::TRIGGER_DEPTH_LIMIT; /** @psalm-var ?class-string */ protected ?string $caller_class; protected int $depth_limit = 0; protected array $array_ref_stack = []; protected array $object_hashes = []; protected array $plugins = []; /** * @param int $depth_limit Maximum depth to parse data * @param ?string $caller Caller class name * * @psalm-param ?class-string $caller */ public function __construct(int $depth_limit = 0, ?string $caller = null) { $this->depth_limit = $depth_limit; $this->caller_class = $caller; } /** * Set the caller class. * * @psalm-param ?class-string $caller */ public function setCallerClass(?string $caller = null): void { $this->noRecurseCall(); $this->caller_class = $caller; } /** @psalm-return ?class-string */ public function getCallerClass(): ?string { return $this->caller_class; } /** * Set the depth limit. * * @param int $depth_limit Maximum depth to parse data, 0 for none */ public function setDepthLimit(int $depth_limit = 0): void { $this->noRecurseCall(); $this->depth_limit = $depth_limit; } public function getDepthLimit(): int { return $this->depth_limit; } /** * Parses a variable into a Kint object structure. * * @param mixed &$var The input variable */ public function parse(&$var, ContextInterface $c): AbstractValue { $type = \strtolower(\gettype($var)); if ($v = $this->applyPluginsBegin($var, $c, $type)) { return $v; } switch ($type) { case 'array': return $this->parseArray($var, $c); case 'boolean': case 'double': case 'integer': case 'null': return $this->parseFixedWidth($var, $c); case 'object': return $this->parseObject($var, $c); case 'resource': return $this->parseResource($var, $c); case 'string': return $this->parseString($var, $c); case 'resource (closed)': return $this->parseResourceClosed($var, $c); case 'unknown type': // @codeCoverageIgnore default: // These should never happen. Unknown is resource (closed) from old // PHP versions and there shouldn't be any other types. return $this->parseUnknown($var, $c); // @codeCoverageIgnore } } public function addPlugin(PluginInterface $p): void { try { $this->noRecurseCall(); } catch (DomainException $e) { // @codeCoverageIgnore \trigger_error('Calling Kint\\Parser::addPlugin from inside a parse is deprecated', E_USER_DEPRECATED); // @codeCoverageIgnore } if (!$types = $p->getTypes()) { return; } if (!$triggers = $p->getTriggers()) { return; } if ($triggers & self::TRIGGER_BEGIN && !$p instanceof PluginBeginInterface) { throw new InvalidArgumentException('Parsers triggered on begin must implement PluginBeginInterface'); } if ($triggers & self::TRIGGER_COMPLETE && !$p instanceof PluginCompleteInterface) { throw new InvalidArgumentException('Parsers triggered on completion must implement PluginCompleteInterface'); } $p->setParser($this); foreach ($types as $type) { $this->plugins[$type] ??= [ self::TRIGGER_BEGIN => [], self::TRIGGER_SUCCESS => [], self::TRIGGER_RECURSION => [], self::TRIGGER_DEPTH_LIMIT => [], ]; foreach ($this->plugins[$type] as $trigger => &$pool) { if ($triggers & $trigger) { $pool[] = $p; } } } } public function clearPlugins(): void { try { $this->noRecurseCall(); } catch (DomainException $e) { // @codeCoverageIgnore \trigger_error('Calling Kint\\Parser::clearPlugins from inside a parse is deprecated', E_USER_DEPRECATED); // @codeCoverageIgnore } $this->plugins = []; } protected function noRecurseCall(): void { $bt = \debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS); \reset($bt); /** @psalm-var class-string $caller_frame['class'] */ $caller_frame = \next($bt); foreach ($bt as $frame) { if (isset($frame['object']) && $frame['object'] === $this && 'parse' === $frame['function']) { throw new DomainException($caller_frame['class'].'::'.$caller_frame['function'].' cannot be called from inside a parse'); } } } /** * @psalm-param null|bool|float|int &$var */ private function parseFixedWidth(&$var, ContextInterface $c): AbstractValue { $v = new FixedWidthValue($c, $var); return $this->applyPluginsComplete($var, $v, self::TRIGGER_SUCCESS); } private function parseString(string &$var, ContextInterface $c): AbstractValue { $string = new StringValue($c, $var, Utils::detectEncoding($var)); if (false !== $string->getEncoding() && \strlen($var)) { $string->addRepresentation(new StringRepresentation('Contents', $var, null, true)); } return $this->applyPluginsComplete($var, $string, self::TRIGGER_SUCCESS); } private function parseArray(array &$var, ContextInterface $c): AbstractValue { $size = \count($var); $contents = []; $parentRef = ReflectionReference::fromArrayElement([&$var], 0)->getId(); if (isset($this->array_ref_stack[$parentRef])) { $array = new ArrayValue($c, $size, $contents); $array->flags |= AbstractValue::FLAG_RECURSION; return $this->applyPluginsComplete($var, $array, self::TRIGGER_RECURSION); } try { $this->array_ref_stack[$parentRef] = true; $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); if ($size > 0 && $this->depth_limit && $cdepth >= $this->depth_limit) { $array = new ArrayValue($c, $size, $contents); $array->flags |= AbstractValue::FLAG_DEPTH_LIMIT; return $this->applyPluginsComplete($var, $array, self::TRIGGER_DEPTH_LIMIT); } foreach ($var as $key => $_) { $child = new ArrayContext($key); $child->depth = $cdepth + 1; $child->reference = null !== ReflectionReference::fromArrayElement($var, $key); if (null !== $ap) { $child->access_path = $ap.'['.\var_export($key, true).']'; } $contents[$key] = $this->parse($var[$key], $child); } $array = new ArrayValue($c, $size, $contents); if ($contents) { $array->addRepresentation(new ContainerRepresentation('Contents', $contents, null, true)); } return $this->applyPluginsComplete($var, $array, self::TRIGGER_SUCCESS); } finally { unset($this->array_ref_stack[$parentRef]); } } /** * @psalm-return ReflectionProperty[] */ private function getPropsOrdered(ReflectionClass $r): array { if ($parent = $r->getParentClass()) { $props = self::getPropsOrdered($parent); } else { $props = []; } foreach ($r->getProperties() as $prop) { if ($prop->isStatic()) { continue; } if ($prop->isPrivate()) { $props[] = $prop; } else { $props[$prop->name] = $prop; } } return $props; } /** * @codeCoverageIgnore * * @psalm-return ReflectionProperty[] */ private function getPropsOrderedOld(ReflectionClass $r): array { $props = []; foreach ($r->getProperties() as $prop) { if ($prop->isStatic()) { continue; } $props[] = $prop; } while ($r = $r->getParentClass()) { foreach ($r->getProperties(ReflectionProperty::IS_PRIVATE) as $prop) { if ($prop->isStatic()) { continue; } $props[] = $prop; } } return $props; } private function parseObject(object &$var, ContextInterface $c): AbstractValue { $hash = \spl_object_hash($var); $classname = \get_class($var); if (isset($this->object_hashes[$hash])) { $object = new InstanceValue($c, $classname, $hash, \spl_object_id($var)); $object->flags |= AbstractValue::FLAG_RECURSION; return $this->applyPluginsComplete($var, $object, self::TRIGGER_RECURSION); } try { $this->object_hashes[$hash] = true; $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); if ($this->depth_limit && $cdepth >= $this->depth_limit) { $object = new InstanceValue($c, $classname, $hash, \spl_object_id($var)); $object->flags |= AbstractValue::FLAG_DEPTH_LIMIT; return $this->applyPluginsComplete($var, $object, self::TRIGGER_DEPTH_LIMIT); } if (KINT_PHP81) { $props = $this->getPropsOrdered(new ReflectionObject($var)); } else { $props = $this->getPropsOrderedOld(new ReflectionObject($var)); // @codeCoverageIgnore } $values = (array) $var; $properties = []; foreach ($props as $rprop) { $rprop->setAccessible(true); $name = $rprop->getName(); // Casting object to array: // private properties show in the form "\0$owner_class_name\0$property_name"; // protected properties show in the form "\0*\0$property_name"; // public properties show in the form "$property_name"; // http://www.php.net/manual/en/language.types.array.php#language.types.array.casting $key = $name; if ($rprop->isProtected()) { $key = "\0*\0".$name; } elseif ($rprop->isPrivate()) { $key = "\0".$rprop->getDeclaringClass()->getName()."\0".$name; } $initialized = \array_key_exists($key, $values); if ($key === (string) (int) $key) { $key = (int) $key; } if ($rprop->isDefault()) { $child = new PropertyContext( $name, $rprop->getDeclaringClass()->getName(), ClassDeclaredContext::ACCESS_PUBLIC ); $child->readonly = KINT_PHP81 && $rprop->isReadOnly(); if ($rprop->isProtected()) { $child->access = ClassDeclaredContext::ACCESS_PROTECTED; } elseif ($rprop->isPrivate()) { $child->access = ClassDeclaredContext::ACCESS_PRIVATE; } if (KINT_PHP84) { if ($rprop->isProtectedSet()) { $child->access_set = ClassDeclaredContext::ACCESS_PROTECTED; } elseif ($rprop->isPrivateSet()) { $child->access_set = ClassDeclaredContext::ACCESS_PRIVATE; } $hooks = $rprop->getHooks(); if (isset($hooks['get'])) { $child->hooks |= PropertyContext::HOOK_GET; if ($hooks['get']->returnsReference()) { $child->hooks |= PropertyContext::HOOK_GET_REF; } } if (isset($hooks['set'])) { $child->hooks |= PropertyContext::HOOK_SET; $child->hook_set_type = (string) $rprop->getSettableType(); if ($child->hook_set_type !== (string) $rprop->getType()) { $child->hooks |= PropertyContext::HOOK_SET_TYPE; } elseif ('' === $child->hook_set_type) { $child->hook_set_type = null; } } } } else { $child = new ClassOwnedContext($name, $rprop->getDeclaringClass()->getName()); } $child->reference = $initialized && null !== ReflectionReference::fromArrayElement($values, $key); $child->depth = $cdepth + 1; if (null !== $ap && $child->isAccessible($this->caller_class)) { /** @psalm-var string $child->name */ if (Utils::isValidPhpName($child->name)) { $child->access_path = $ap.'->'.$child->name; } else { $child->access_path = $ap.'->{'.\var_export($child->name, true).'}'; } } if (KINT_PHP84 && $rprop->isVirtual()) { $properties[] = new VirtualValue($child); } elseif (!$initialized) { $properties[] = new UninitializedValue($child); } else { $properties[] = $this->parse($values[$key], $child); } } $object = new InstanceValue($c, $classname, $hash, \spl_object_id($var)); if ($props) { $object->setChildren($properties); } if ($properties) { $object->addRepresentation(new ContainerRepresentation('Properties', $properties)); } return $this->applyPluginsComplete($var, $object, self::TRIGGER_SUCCESS); } finally { unset($this->object_hashes[$hash]); } } /** * @psalm-param resource $var */ private function parseResource(&$var, ContextInterface $c): AbstractValue { $resource = new ResourceValue($c, \get_resource_type($var)); $resource = $this->applyPluginsComplete($var, $resource, self::TRIGGER_SUCCESS); return $resource; } /** * @psalm-param mixed $var */ private function parseResourceClosed(&$var, ContextInterface $c): AbstractValue { $v = new ClosedResourceValue($c); $v = $this->applyPluginsComplete($var, $v, self::TRIGGER_SUCCESS); return $v; } /** * Catch-all for any unexpectedgettype. * * This should never happen. * * @codeCoverageIgnore * * @psalm-param mixed $var */ private function parseUnknown(&$var, ContextInterface $c): AbstractValue { $v = new UnknownValue($c); $v = $this->applyPluginsComplete($var, $v, self::TRIGGER_SUCCESS); return $v; } /** * Applies plugins for a yet-unparsed value. * * @param mixed &$var The input variable */ private function applyPluginsBegin(&$var, ContextInterface $c, string $type): ?AbstractValue { $plugins = $this->plugins[$type][self::TRIGGER_BEGIN] ?? []; foreach ($plugins as $plugin) { try { if ($v = $plugin->parseBegin($var, $c)) { return $v; } } catch (Throwable $e) { \trigger_error( Utils::errorSanitizeString(\get_class($e)).' was thrown in '.$e->getFile().' on line '.$e->getLine().' while executing '.Utils::errorSanitizeString(\get_class($plugin)).'->parseBegin. Error message: '.Utils::errorSanitizeString($e->getMessage()), E_USER_WARNING ); } } return null; } /** * Applies plugins for a parsed AbstractValue. * * @param mixed &$var The input variable */ private function applyPluginsComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { $plugins = $this->plugins[$v->getType()][$trigger] ?? []; foreach ($plugins as $plugin) { try { $v = $plugin->parseComplete($var, $v, $trigger); } catch (Throwable $e) { \trigger_error( Utils::errorSanitizeString(\get_class($e)).' was thrown in '.$e->getFile().' on line '.$e->getLine().' while executing '.Utils::errorSanitizeString(\get_class($plugin)).'->parseComplete. Error message: '.Utils::errorSanitizeString($e->getMessage()), E_USER_WARNING ); } } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ConstructablePluginInterface.php
system/ThirdParty/Kint/Parser/ConstructablePluginInterface.php
<?php declare(strict_types=1); /* * 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\Parser; interface ConstructablePluginInterface extends PluginInterface { public function __construct(Parser $p); }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/TracePlugin.php
system/ThirdParty/Kint/Parser/TracePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Utils; use Kint\Value\AbstractValue; use Kint\Value\ArrayValue; use Kint\Value\Context\ArrayContext; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\SourceRepresentation; use Kint\Value\Representation\ValueRepresentation; use Kint\Value\TraceFrameValue; use Kint\Value\TraceValue; use RuntimeException; /** * @psalm-import-type TraceFrame from TraceFrameValue */ class TracePlugin extends AbstractPlugin implements PluginCompleteInterface { public static array $blacklist = ['spl_autoload_call']; public static array $path_blacklist = []; public function getTypes(): array { return ['array']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!$v instanceof ArrayValue) { return $v; } // Shallow copy so we don't have to worry about touching var $trace = $var; if (!Utils::isTrace($trace)) { return $v; } $pdepth = $this->getParser()->getDepthLimit(); $c = $v->getContext(); // We need at least 2 levels in order to get $trace[n]['args'] if ($pdepth && $c->getDepth() + 2 >= $pdepth) { return $v; } $contents = $v->getContents(); self::$blacklist = Utils::normalizeAliases(self::$blacklist); $path_blacklist = self::normalizePaths(self::$path_blacklist); $frames = []; foreach ($contents as $frame) { if (!$frame instanceof ArrayValue || !$frame->getContext() instanceof ArrayContext) { continue; } $index = $frame->getContext()->getName(); if (!isset($trace[$index]) || Utils::traceFrameIsListed($trace[$index], self::$blacklist)) { continue; } if (isset($trace[$index]['file']) && false !== ($realfile = \realpath($trace[$index]['file']))) { foreach ($path_blacklist as $path) { if (0 === \strpos($realfile, $path)) { continue 2; } } } $frame = new TraceFrameValue($frame, $trace[$index]); if (null !== ($file = $frame->getFile()) && null !== ($line = $frame->getLine())) { try { $frame->addRepresentation(new SourceRepresentation($file, $line)); } catch (RuntimeException $e) { } } if ($args = $frame->getArgs()) { $frame->addRepresentation(new ContainerRepresentation('Arguments', $args)); } if ($obj = $frame->getObject()) { $frame->addRepresentation( new ValueRepresentation( 'Callee object ['.$obj->getClassName().']', $obj, 'callee_object' ) ); } $frames[$index] = $frame; } $traceobj = new TraceValue($c, \count($frames), $frames); if ($frames) { $traceobj->addRepresentation(new ContainerRepresentation('Contents', $frames, null, true)); } return $traceobj; } protected static function normalizePaths(array $paths): array { $normalized = []; foreach ($paths as $path) { $realpath = \realpath($path); if (\is_dir($realpath)) { $realpath .= DIRECTORY_SEPARATOR; } $normalized[] = $realpath; } return $normalized; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/JsonPlugin.php
system/ThirdParty/Kint/Parser/JsonPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use JsonException; use Kint\Value\AbstractValue; use Kint\Value\ArrayValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ValueRepresentation; class JsonPlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (!isset($var[0]) || ('{' !== $var[0] && '[' !== $var[0])) { return $v; } try { $json = \json_decode($var, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { return $v; } $json = (array) $json; $c = $v->getContext(); $base = new BaseContext('JSON Decode'); $base->depth = $c->getDepth(); if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'json_decode('.$ap.', true)'; } $json = $this->getParser()->parse($json, $base); if ($json instanceof ArrayValue && (~$json->flags & AbstractValue::FLAG_DEPTH_LIMIT) && $contents = $json->getContents()) { foreach ($contents as $value) { $value->flags |= AbstractValue::FLAG_GENERATED; } $v->addRepresentation(new ContainerRepresentation('Json', $contents), 0); } else { $json->flags |= AbstractValue::FLAG_GENERATED; $v->addRepresentation(new ValueRepresentation('Json', $json), 0); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/SerializePlugin.php
system/ThirdParty/Kint/Parser/SerializePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ValueRepresentation; use Kint\Value\UninitializedValue; /** @psalm-api */ class SerializePlugin extends AbstractPlugin implements PluginCompleteInterface { /** * Disables automatic unserialization on arrays and objects. * * As the PHP manual notes: * * > Unserialization can result in code being loaded and executed due to * > object instantiation and autoloading, and a malicious user may be able * > to exploit this. * * The natural way to stop that from happening is to just refuse to unserialize * stuff by default. Which is what we're doing for anything that's not scalar. */ public static bool $safe_mode = true; /** * @psalm-var bool|class-string[] */ public static $allowed_classes = false; public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { $trimmed = \rtrim($var); if ('N;' !== $trimmed && !\preg_match('/^(?:[COabis]:\\d+[:;]|d:\\d+(?:\\.\\d+);)/', $trimmed)) { return $v; } $options = ['allowed_classes' => self::$allowed_classes]; $c = $v->getContext(); $base = new BaseContext('unserialize('.$c->getName().')'); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'unserialize('.$ap; if (true === self::$allowed_classes) { $base->access_path .= ')'; } else { $base->access_path .= ', '.\var_export($options, true).')'; } } if (self::$safe_mode && \in_array($trimmed[0], ['C', 'O', 'a'], true)) { $data = new UninitializedValue($base); $data->flags |= AbstractValue::FLAG_BLACKLIST; } else { // Suppress warnings on unserializeable variable $data = @\unserialize($trimmed, $options); if (false === $data && 'b:0;' !== \substr($trimmed, 0, 4)) { return $v; } $data = $this->getParser()->parse($data, $base); } $data->flags |= AbstractValue::FLAG_GENERATED; $v->addRepresentation(new ValueRepresentation('Serialized', $data), 0); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ArrayLimitPlugin.php
system/ThirdParty/Kint/Parser/ArrayLimitPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use InvalidArgumentException; use Kint\Utils; use Kint\Value\AbstractValue; use Kint\Value\ArrayValue; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ProfileRepresentation; use Kint\Value\Representation\ValueRepresentation; class ArrayLimitPlugin extends AbstractPlugin implements PluginBeginInterface { /** * Maximum size of arrays before limiting. */ public static int $trigger = 1000; /** * Maximum amount of items to show in a limited array. */ public static int $limit = 50; /** * Don't limit arrays with string keys. */ public static bool $numeric_only = true; public function __construct(Parser $p) { if (self::$limit < 0) { throw new InvalidArgumentException('ArrayLimitPlugin::$limit can not be lower than 0'); } if (self::$limit >= self::$trigger) { throw new InvalidArgumentException('ArrayLimitPlugin::$limit can not be lower than ArrayLimitPlugin::$trigger'); } parent::__construct($p); } public function getTypes(): array { return ['array']; } public function getTriggers(): int { return Parser::TRIGGER_BEGIN; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { $parser = $this->getParser(); $pdepth = $parser->getDepthLimit(); if (!$pdepth) { return null; } $cdepth = $c->getDepth(); if ($cdepth >= $pdepth - 1) { return null; } if (\count($var) < self::$trigger) { return null; } if (self::$numeric_only && Utils::isAssoc($var)) { return null; } $slice = \array_slice($var, 0, self::$limit, true); $array = $parser->parse($slice, $c); if (!$array instanceof ArrayValue) { return null; } $base = new BaseContext($c->getName()); $base->depth = $pdepth - 1; $base->access_path = $c->getAccessPath(); $slice = \array_slice($var, self::$limit, null, true); $slice = $parser->parse($slice, $base); if (!$slice instanceof ArrayValue) { return null; } foreach ($slice->getContents() as $child) { $this->replaceDepthLimit($child, $cdepth + 1); } $out = new ArrayValue($c, \count($var), \array_merge($array->getContents(), $slice->getContents())); $out->flags = $array->flags; // Explicitly copy over profile plugin $arrayp = $array->getRepresentation('profiling'); $slicep = $slice->getRepresentation('profiling'); if ($arrayp instanceof ProfileRepresentation && $slicep instanceof ProfileRepresentation) { $out->addRepresentation(new ProfileRepresentation($arrayp->complexity + $slicep->complexity)); } // Add contents. Check is in case some bad plugin empties both $slice and $array if ($contents = $out->getContents()) { $out->addRepresentation(new ContainerRepresentation('Contents', $contents, null, true)); } return $out; } protected function replaceDepthLimit(AbstractValue $v, int $depth): void { $c = $v->getContext(); if ($c instanceof BaseContext) { $c->depth = $depth; } $pdepth = $this->getParser()->getDepthLimit(); if (($v->flags & AbstractValue::FLAG_DEPTH_LIMIT) && $pdepth && $depth < $pdepth) { $v->flags = $v->flags & ~AbstractValue::FLAG_DEPTH_LIMIT | AbstractValue::FLAG_ARRAY_LIMIT; } $reps = $v->getRepresentations(); foreach ($reps as $rep) { if ($rep instanceof ContainerRepresentation) { foreach ($rep->getContents() as $child) { $this->replaceDepthLimit($child, $depth + 1); } } elseif ($rep instanceof ValueRepresentation) { $this->replaceDepthLimit($rep->getValue(), $depth + 1); } } } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/MicrotimePlugin.php
system/ThirdParty/Kint/Parser/MicrotimePlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\MicrotimeValue; use Kint\Value\Representation\MicrotimeRepresentation; class MicrotimePlugin extends AbstractPlugin implements PluginCompleteInterface { private static ?array $last = null; private static ?float $start = null; private static int $times = 0; private static ?string $group = null; public function getTypes(): array { return ['string', 'double']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { $c = $v->getContext(); if ($c->getDepth() > 0) { return $v; } if (\is_string($var)) { if ('microtime()' !== $c->getName() || !\preg_match('/^0\\.[0-9]{8} [0-9]{10}$/', $var)) { return $v; } $usec = (int) \substr($var, 2, 6); $sec = (int) \substr($var, 11, 10); } else { if ('microtime(...)' !== $c->getName()) { return $v; } $sec = (int) \floor($var); $usec = $var - $sec; $usec = (int) \floor($usec * 1000000); } $time = $sec + ($usec / 1000000); if (null !== self::$last) { $last_time = self::$last[0] + (self::$last[1] / 1000000); $lap = $time - $last_time; ++self::$times; } else { $lap = null; self::$start = $time; } self::$last = [$sec, $usec]; if (null !== $lap) { $total = $time - self::$start; $r = new MicrotimeRepresentation($sec, $usec, self::getGroup(), $lap, $total, self::$times); } else { $r = new MicrotimeRepresentation($sec, $usec, self::getGroup()); } $out = new MicrotimeValue($v); $out->removeRepresentation('contents'); $out->addRepresentation($r); return $out; } /** @psalm-api */ public static function clean(): void { self::$last = null; self::$start = null; self::$times = 0; self::newGroup(); } private static function getGroup(): string { if (null === self::$group) { return self::newGroup(); } return self::$group; } private static function newGroup(): string { return self::$group = \bin2hex(\random_bytes(4)); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/BinaryPlugin.php
system/ThirdParty/Kint/Parser/BinaryPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Representation\BinaryRepresentation; use Kint\Value\StringValue; class BinaryPlugin extends AbstractPlugin implements PluginCompleteInterface { public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if ($v instanceof StringValue && false === $v->getEncoding()) { $v->addRepresentation(new BinaryRepresentation($v->getValue(), true), 0); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/ClassStringsPlugin.php
system/ThirdParty/Kint/Parser/ClassStringsPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\InstanceValue; use ReflectionClass; class ClassStringsPlugin extends AbstractPlugin implements PluginCompleteInterface { public static array $blacklist = []; protected ClassMethodsPlugin $methods_plugin; protected ClassStaticsPlugin $statics_plugin; public function __construct(Parser $parser) { parent::__construct($parser); $this->methods_plugin = new ClassMethodsPlugin($parser); $this->statics_plugin = new ClassStaticsPlugin($parser); } public function setParser(Parser $p): void { parent::setParser($p); $this->methods_plugin->setParser($p); $this->statics_plugin->setParser($p); } public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { $c = $v->getContext(); if ($c->getDepth() > 0) { return $v; } if (!\class_exists($var, true)) { return $v; } if (\in_array($var, self::$blacklist, true)) { return $v; } $r = new ReflectionClass($var); $fakeC = new BaseContext($c->getName()); $fakeC->access_path = null; $fakeV = new InstanceValue($fakeC, $r->getName(), 'badhash', -1); $fakeVar = null; $fakeV = $this->methods_plugin->parseComplete($fakeVar, $fakeV, Parser::TRIGGER_SUCCESS); $fakeV = $this->statics_plugin->parseComplete($fakeVar, $fakeV, Parser::TRIGGER_SUCCESS); foreach (['methods', 'static_methods', 'statics', 'constants'] as $rep) { if ($rep = $fakeV->getRepresentation($rep)) { $v->addRepresentation($rep); } } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/SimpleXMLElementPlugin.php
system/ThirdParty/Kint/Parser/SimpleXMLElementPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Utils; use Kint\Value\AbstractValue; use Kint\Value\Context\ArrayContext; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ClassOwnedContext; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\ContainerRepresentation; use Kint\Value\Representation\ValueRepresentation; use Kint\Value\SimpleXMLElementValue; use SimpleXMLElement; class SimpleXMLElementPlugin extends AbstractPlugin implements PluginBeginInterface { /** * Show all properties and methods. */ public static bool $verbose = false; protected ClassMethodsPlugin $methods_plugin; public function __construct(Parser $parser) { parent::__construct($parser); $this->methods_plugin = new ClassMethodsPlugin($parser); } public function setParser(Parser $p): void { parent::setParser($p); $this->methods_plugin->setParser($p); } public function getTypes(): array { return ['object']; } public function getTriggers(): int { // SimpleXMLElement is a weirdo. No recursion (Or rather everything is // recursion) and depth limit will have to be handled manually anyway. return Parser::TRIGGER_BEGIN; } public function parseBegin(&$var, ContextInterface $c): ?AbstractValue { if (!$var instanceof SimpleXMLElement) { return null; } return $this->parseElement($var, $c); } protected function parseElement(SimpleXMLElement &$var, ContextInterface $c): SimpleXMLElementValue { $parser = $this->getParser(); $pdepth = $parser->getDepthLimit(); $cdepth = $c->getDepth(); $depthlimit = $pdepth && $cdepth >= $pdepth; $has_children = self::hasChildElements($var); if ($depthlimit && $has_children) { $x = new SimpleXMLElementValue($c, $var, [], null); $x->flags |= AbstractValue::FLAG_DEPTH_LIMIT; return $x; } $children = $this->getChildren($c, $var); $attributes = $this->getAttributes($c, $var); $toString = (string) $var; $string_body = !$has_children && \strlen($toString); $x = new SimpleXMLElementValue($c, $var, $children, \strlen($toString) ? $toString : null); if (self::$verbose) { $x = $this->methods_plugin->parseComplete($var, $x, Parser::TRIGGER_SUCCESS); } if ($attributes) { $x->addRepresentation(new ContainerRepresentation('Attributes', $attributes), 0); } if ($string_body) { $base = new BaseContext('(string) '.$c->getName()); $base->depth = $cdepth + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = '(string) '.$ap; } $toString = $parser->parse($toString, $base); $x->addRepresentation(new ValueRepresentation('toString', $toString, null, true), 0); } if ($children) { $x->addRepresentation(new ContainerRepresentation('Children', $children), 0); } return $x; } /** @psalm-return list<AbstractValue> */ protected function getAttributes(ContextInterface $c, SimpleXMLElement $var): array { $parser = $this->getParser(); $namespaces = \array_merge(['' => null], $var->getDocNamespaces()); $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); $contents = []; foreach ($namespaces as $nsAlias => $_) { if ((bool) $nsAttribs = $var->attributes($nsAlias, true)) { foreach ($nsAttribs as $name => $attrib) { $obj = new ArrayContext($name); $obj->depth = $cdepth + 1; if (null !== $ap) { $obj->access_path = '(string) '.$ap; if ('' !== $nsAlias) { $obj->access_path .= '->attributes('.\var_export($nsAlias, true).', true)'; } $obj->access_path .= '['.\var_export($name, true).']'; } if ('' !== $nsAlias) { $obj->name = $nsAlias.':'.$obj->name; } $string = (string) $attrib; $attribute = $parser->parse($string, $obj); $contents[] = $attribute; } } } return $contents; } /** * Alright kids, let's learn about SimpleXMLElement::children! * children can take a namespace url or alias and provide a list of * child nodes. This is great since just accessing the members through * properties doesn't work on SimpleXMLElement when they have a * namespace at all! * * Unfortunately SimpleXML decided to go the retarded route of * categorizing elements by their tag name rather than by their local * name (to put it in Dom terms) so if you have something like this: * * <root xmlns:localhost="http://localhost/"> * <tag /> * <tag xmlns="http://localhost/" /> * <localhost:tag /> * </root> * * * children(null) will get the first 2 results * * children('', true) will get the first 2 results * * children('http://localhost/') will get the last 2 results * * children('localhost', true) will get the last result * * So let's just give up and stick to aliases because fuck that mess! * * @psalm-return list<SimpleXMLElementValue> */ protected function getChildren(ContextInterface $c, SimpleXMLElement $var): array { $namespaces = \array_merge(['' => null], $var->getDocNamespaces()); $cdepth = $c->getDepth(); $ap = $c->getAccessPath(); $contents = []; foreach ($namespaces as $nsAlias => $_) { if ((bool) $nsChildren = $var->children($nsAlias, true)) { $nsap = []; foreach ($nsChildren as $name => $child) { $base = new ClassOwnedContext((string) $name, SimpleXMLElement::class); $base->depth = $cdepth + 1; if ('' !== $nsAlias) { $base->name = $nsAlias.':'.$name; } if (null !== $ap) { if ('' === $nsAlias) { $base->access_path = $ap.'->'; } else { $base->access_path = $ap.'->children('.\var_export($nsAlias, true).', true)->'; } if (Utils::isValidPhpName((string) $name)) { $base->access_path .= (string) $name; } else { $base->access_path .= '{'.\var_export((string) $name, true).'}'; } if (isset($nsap[$base->access_path])) { ++$nsap[$base->access_path]; $base->access_path .= '['.$nsap[$base->access_path].']'; } else { $nsap[$base->access_path] = 0; } } $v = $this->parseElement($child, $base); $v->flags |= AbstractValue::FLAG_GENERATED; $contents[] = $v; } } } return $contents; } /** * More SimpleXMLElement bullshit. * * If we want to know if the element contains text we can cast to string. * Except if it contains text mixed with elements simplexml for some stupid * reason decides to concatenate the text from between those elements * rather than all the text in the hierarchy... * * So we have NO way of getting text nodes between elements, but we can * still tell if we have elements right? If we have elements we assume it's * not a string and call it a day! * * Well if you cast the element to an array attributes will be on it so * you'd have to remove that key, and if it's a string it'll also have the * 0 index used for the string contents too... * * Wait, can we use the 0 index to tell if it's a string? Nope! CDATA * doesn't show up AT ALL when casting to anything but string, and we'll * still get those concatenated strings of mostly whitespace if we just do * (string) and check the length. * * Luckily, I found the only way to do this reliably is through children(). * We still have to loop through all the namespaces and see if there's a * match but then we have the problem of the attributes showing up again... * * Or at least that's what var_dump says. And when we cast the result to * bool it's true too... But if we cast it to array then it's suddenly empty! * * Long story short the function below is the only way to reliably check if * a SimpleXMLElement has children */ protected static function hasChildElements(SimpleXMLElement $var): bool { $namespaces = \array_merge(['' => null], $var->getDocNamespaces()); foreach ($namespaces as $nsAlias => $_) { if ((array) $var->children($nsAlias, true)) { return true; } } return false; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/TimestampPlugin.php
system/ThirdParty/Kint/Parser/TimestampPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; use DateTimeImmutable; use Kint\Value\AbstractValue; use Kint\Value\FixedWidthValue; use Kint\Value\Representation\StringRepresentation; use Kint\Value\StringValue; class TimestampPlugin extends AbstractPlugin implements PluginCompleteInterface { public static array $blacklist = [ 2147483648, 2147483647, 1073741824, 1073741823, ]; public function getTypes(): array { return ['string', 'integer']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (\is_string($var) && !\ctype_digit($var)) { return $v; } if ($var < 0) { return $v; } if (\in_array($var, self::$blacklist, true)) { return $v; } $len = \strlen((string) $var); // Guess for anything between March 1973 and November 2286 if ($len < 9 || $len > 10) { return $v; } if (!$v instanceof StringValue && !$v instanceof FixedWidthValue) { return $v; } if (!$dt = DateTimeImmutable::createFromFormat('U', (string) $var)) { return $v; } $v->removeRepresentation('contents'); $v->addRepresentation(new StringRepresentation('Timestamp', $dt->format('c'), null, true)); return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/AbstractPlugin.php
system/ThirdParty/Kint/Parser/AbstractPlugin.php
<?php declare(strict_types=1); /* * 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\Parser; abstract class AbstractPlugin implements ConstructablePluginInterface { private Parser $parser; public function __construct(Parser $parser) { $this->parser = $parser; } public function setParser(Parser $p): void { $this->parser = $p; } protected function getParser(): Parser { return $this->parser; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Parser/Base64Plugin.php
system/ThirdParty/Kint/Parser/Base64Plugin.php
<?php declare(strict_types=1); /* * 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\Parser; use Kint\Value\AbstractValue; use Kint\Value\Context\BaseContext; use Kint\Value\Representation\ValueRepresentation; use Kint\Value\StringValue; class Base64Plugin extends AbstractPlugin implements PluginCompleteInterface { /** * The minimum length before a string will be considered for base64 decoding. */ public static int $min_length_hard = 16; /** * The minimum length before the base64 decoding will take precedence. */ public static int $min_length_soft = 50; public function getTypes(): array { return ['string']; } public function getTriggers(): int { return Parser::TRIGGER_SUCCESS; } public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractValue { if (\strlen($var) < self::$min_length_hard || \strlen($var) % 4) { return $v; } if (\preg_match('/^[A-Fa-f0-9]+$/', $var)) { return $v; } if (!\preg_match('/^[A-Za-z0-9+\\/=]+$/', $var)) { return $v; } $data = \base64_decode($var, true); if (false === $data) { return $v; } $c = $v->getContext(); $base = new BaseContext('base64_decode('.$c->getName().')'); $base->depth = $c->getDepth() + 1; if (null !== ($ap = $c->getAccessPath())) { $base->access_path = 'base64_decode('.$ap.')'; } $data = $this->getParser()->parse($data, $base); $data->flags |= AbstractValue::FLAG_GENERATED; if (!$data instanceof StringValue || false === $data->getEncoding()) { return $v; } $r = new ValueRepresentation('Base64', $data); if (\strlen($var) > self::$min_length_soft) { $v->addRepresentation($r, 0); } else { $v->addRepresentation($r); } return $v; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ResourceValue.php
system/ThirdParty/Kint/Value/ResourceValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class ResourceValue extends AbstractValue { /** @psalm-readonly */ protected string $resource_type; public function __construct(ContextInterface $context, string $resource_type) { parent::__construct($context, 'resource'); $this->resource_type = $resource_type; } public function getDisplayType(): string { return $this->resource_type.' resource'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/EnumValue.php
system/ThirdParty/Kint/Value/EnumValue.php
<?php declare(strict_types=1); /* * 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\Value; use BackedEnum; use Kint\Value\Context\ContextInterface; use UnitEnum; class EnumValue extends InstanceValue { /** @psalm-readonly */ protected UnitEnum $enumval; public function __construct(ContextInterface $context, UnitEnum $enumval) { parent::__construct($context, \get_class($enumval), \spl_object_hash($enumval), \spl_object_id($enumval)); $this->enumval = $enumval; } public function getHint(): string { return parent::getHint() ?? 'enum'; } public function getDisplayType(): string { return $this->classname.'::'.$this->enumval->name; } public function getDisplayValue(): ?string { if ($this->enumval instanceof BackedEnum) { if (\is_string($this->enumval->value)) { return '"'.$this->enumval->value.'"'; } return (string) $this->enumval->value; } return null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/FixedWidthValue.php
system/ThirdParty/Kint/Value/FixedWidthValue.php
<?php declare(strict_types=1); /* * 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\Value; use InvalidArgumentException; use Kint\Value\Context\ContextInterface; /** * @psalm-type FixedWidthType = null|boolean|integer|double */ class FixedWidthValue extends AbstractValue { /** * @psalm-readonly * * @psalm-var FixedWidthType */ protected $value; /** @psalm-param FixedWidthType $value */ public function __construct(ContextInterface $context, $value) { $type = \strtolower(\gettype($value)); if ('null' === $type || 'boolean' === $type || 'integer' === $type || 'double' === $type) { parent::__construct($context, $type); $this->value = $value; } else { throw new InvalidArgumentException('FixedWidthValue can only contain fixed width types, got '.$type); } } /** * @psalm-api * * @psalm-return FixedWidthType */ public function getValue() { return $this->value; } public function getDisplaySize(): ?string { return null; } public function getDisplayValue(): ?string { if ('boolean' === $this->type) { return ((bool) $this->value) ? 'true' : 'false'; } if ('integer' === $this->type || 'double' === $this->type) { return (string) $this->value; } return null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/DomNodeValue.php
system/ThirdParty/Kint/Value/DomNodeValue.php
<?php declare(strict_types=1); /* * 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\Value; use Dom\Node; use DOMNode; use Kint\Value\Context\ContextInterface; class DomNodeValue extends InstanceValue { /** * @psalm-param DOMNode|Node $node */ public function __construct(ContextInterface $context, object $node) { parent::__construct($context, \get_class($node), \spl_object_hash($node), \spl_object_id($node)); } public function getDisplaySize(): ?string { return null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ThrowableValue.php
system/ThirdParty/Kint/Value/ThrowableValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; use Throwable; class ThrowableValue extends InstanceValue { /** @psalm-readonly */ protected string $message; public function __construct(ContextInterface $context, Throwable $throw) { parent::__construct($context, \get_class($throw), \spl_object_hash($throw), \spl_object_id($throw)); $this->message = $throw->getMessage(); } public function getDisplayValue(): string { return '"'.$this->message.'"'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/DateTimeValue.php
system/ThirdParty/Kint/Value/DateTimeValue.php
<?php declare(strict_types=1); /* * 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\Value; use DateTimeInterface; use Kint\Value\Context\ContextInterface; class DateTimeValue extends InstanceValue { /** @psalm-readonly */ protected DateTimeInterface $dt; public function __construct(ContextInterface $context, DateTimeInterface $dt) { parent::__construct($context, \get_class($dt), \spl_object_hash($dt), \spl_object_id($dt)); $this->dt = clone $dt; } public function getHint(): string { return parent::getHint() ?? 'datetime'; } public function getDisplayValue(): string { $stamp = $this->dt->format('Y-m-d H:i:s'); if ((int) ($micro = $this->dt->format('u'))) { $stamp .= '.'.$micro; } $stamp .= $this->dt->format(' P'); $tzn = $this->dt->getTimezone()->getName(); if ('+' !== $tzn[0] && '-' !== $tzn[0]) { $stamp .= $this->dt->format(' T'); } return $stamp; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/UninitializedValue.php
system/ThirdParty/Kint/Value/UninitializedValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class UninitializedValue extends AbstractValue { public function __construct(ContextInterface $context) { parent::__construct($context, 'uninitialized'); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ArrayValue.php
system/ThirdParty/Kint/Value/ArrayValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class ArrayValue extends AbstractValue { /** @psalm-readonly */ protected int $size; /** * @psalm-readonly * * @psalm-var AbstractValue[] */ protected array $contents; /** @psalm-param AbstractValue[] $contents */ public function __construct(ContextInterface $context, int $size, array $contents) { parent::__construct($context, 'array'); $this->size = $size; $this->contents = $contents; } public function getSize(): int { return $this->size; } /** @psalm-return AbstractValue[] */ public function getContents() { return $this->contents; } public function getDisplaySize(): string { return (string) $this->size; } public function getDisplayChildren(): array { return $this->contents; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/MicrotimeValue.php
system/ThirdParty/Kint/Value/MicrotimeValue.php
<?php declare(strict_types=1); /* * 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\Value; class MicrotimeValue extends AbstractValue { /** @psalm-readonly */ protected AbstractValue $wrapped; public function __construct(AbstractValue $old) { $this->context = $old->context; $this->type = $old->type; $this->flags = $old->flags; $this->representations = $old->representations; $this->wrapped = $old; } public function getHint(): string { return parent::getHint() ?? 'microtime'; } public function getDisplaySize(): ?string { return $this->wrapped->getDisplaySize(); } public function getDisplayValue(): ?string { return $this->wrapped->getDisplayValue(); } public function getDisplayType(): string { return $this->wrapped->getDisplayType(); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/AbstractValue.php
system/ThirdParty/Kint/Value/AbstractValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\RepresentationInterface; use OutOfRangeException; /** * @psalm-import-type ValueName from ContextInterface * * @psalm-type ValueFlags int-mask-of<AbstractValue::FLAG_*> */ abstract class AbstractValue { public const FLAG_NONE = 0; public const FLAG_GENERATED = 1 << 0; public const FLAG_BLACKLIST = 1 << 1; public const FLAG_RECURSION = 1 << 2; public const FLAG_DEPTH_LIMIT = 1 << 3; public const FLAG_ARRAY_LIMIT = 1 << 4; /** @psalm-var ValueFlags */ public int $flags = self::FLAG_NONE; /** @psalm-readonly */ protected ContextInterface $context; /** @psalm-readonly string */ protected string $type; /** @psalm-var RepresentationInterface[] */ protected array $representations = []; public function __construct(ContextInterface $context, string $type) { $this->context = $context; $this->type = $type; } public function __clone() { $this->context = clone $this->context; } public function getContext(): ContextInterface { return $this->context; } public function getHint(): ?string { if (self::FLAG_NONE === $this->flags) { return null; } if ($this->flags & self::FLAG_BLACKLIST) { return 'blacklist'; } if ($this->flags & self::FLAG_RECURSION) { return 'recursion'; } if ($this->flags & self::FLAG_DEPTH_LIMIT) { return 'depth_limit'; } if ($this->flags & self::FLAG_ARRAY_LIMIT) { return 'array_limit'; } return null; } public function getType(): string { return $this->type; } public function addRepresentation(RepresentationInterface $rep, ?int $pos = null): void { if (isset($this->representations[$rep->getName()])) { throw new OutOfRangeException('Representation already exists'); } 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) ); } } public function replaceRepresentation(RepresentationInterface $rep, ?int $pos = null): void { if (null === $pos) { $this->representations[$rep->getName()] = $rep; } else { $this->removeRepresentation($rep); $this->addRepresentation($rep, $pos); } } /** * @param RepresentationInterface|string $rep */ public function removeRepresentation($rep): void { if ($rep instanceof RepresentationInterface) { unset($this->representations[$rep->getName()]); } else { // String unset($this->representations[$rep]); } } public function getRepresentation(string $name): ?RepresentationInterface { return $this->representations[$name] ?? null; } /** @psalm-return RepresentationInterface[] */ public function getRepresentations(): array { return $this->representations; } /** @psalm-param RepresentationInterface[] $reps */ public function appendRepresentations(array $reps): void { foreach ($reps as $rep) { $this->addRepresentation($rep); } } /** @psalm-api */ public function clearRepresentations(): void { $this->representations = []; } public function getDisplayType(): string { return $this->type; } public function getDisplayName(): string { return (string) $this->context->getName(); } public function getDisplaySize(): ?string { return null; } public function getDisplayValue(): ?string { return null; } /** @psalm-return AbstractValue[] */ public function getDisplayChildren(): array { return []; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/DeclaredCallableBag.php
system/ThirdParty/Kint/Value/DeclaredCallableBag.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Utils; use ReflectionFunctionAbstract; /** @psalm-api */ final class DeclaredCallableBag { use ParameterHoldingTrait; /** @psalm-readonly */ public bool $internal; /** @psalm-readonly */ public ?string $filename; /** @psalm-readonly */ public ?int $startline; /** @psalm-readonly */ public ?int $endline; /** * @psalm-readonly * * @psalm-var ?non-empty-string */ public ?string $docstring; /** @psalm-readonly */ public bool $return_reference; /** @psalm-readonly */ public ?string $returntype = null; public function __construct(ReflectionFunctionAbstract $callable) { $this->internal = $callable->isInternal(); $t = $callable->getFileName(); $this->filename = false === $t ? null : $t; $t = $callable->getStartLine(); $this->startline = false === $t ? null : $t; $t = $callable->getEndLine(); $this->endline = false === $t ? null : $t; $t = $callable->getDocComment(); $this->docstring = false === $t ? null : $t; $this->return_reference = $callable->returnsReference(); $rt = $callable->getReturnType(); if ($rt) { $this->returntype = Utils::getTypeString($rt); } $parameters = []; foreach ($callable->getParameters() as $param) { $parameters[] = new ParameterBag($param); } $this->parameters = $parameters; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/UnknownValue.php
system/ThirdParty/Kint/Value/UnknownValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class UnknownValue extends AbstractValue { public function __construct(ContextInterface $context) { parent::__construct($context, 'unknown'); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/DomNodeListValue.php
system/ThirdParty/Kint/Value/DomNodeListValue.php
<?php declare(strict_types=1); /* * 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\Value; use Dom\NodeList; use DOMNodeList; use Kint\Value\Context\ContextInterface; class DomNodeListValue extends InstanceValue { protected int $length; /** * @psalm-param DOMNodeList|NodeList $node */ public function __construct(ContextInterface $context, object $node) { parent::__construct($context, \get_class($node), \spl_object_hash($node), \spl_object_id($node)); $this->length = $node->length; } public function getLength(): int { return $this->length; } public function getDisplaySize(): string { return (string) $this->length; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ParameterBag.php
system/ThirdParty/Kint/Value/ParameterBag.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Utils; use ReflectionParameter; final class ParameterBag { /** @psalm-readonly */ public string $name; /** @psalm-readonly */ public int $position; /** @psalm-readonly */ public bool $ref; /** @psalm-readonly */ public ?string $type_hint; /** @psalm-readonly */ public ?string $default; public function __construct(ReflectionParameter $param) { $this->name = $param->getName(); $this->position = $param->getPosition(); $this->ref = $param->isPassedByReference(); $this->type_hint = ($type = $param->getType()) ? Utils::getTypeString($type) : null; 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; case 'double': case 'integer': case 'string': $this->default = \var_export($default, true); break; case 'object': $this->default = 'object('.\get_class($default).')'; break; default: $this->default = \gettype($default); break; } } else { $this->default = null; } } public function __toString() { $type = $this->type_hint; if (null !== $type) { $type .= ' '; } $default = $this->default; if (null !== $default) { $default = ' = '.$default; } $ref = $this->ref ? '&' : ''; return $type.$ref.'$'.$this->name.$default; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/StreamValue.php
system/ThirdParty/Kint/Value/StreamValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Utils; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\ContainerRepresentation; class StreamValue extends ResourceValue { /** * @psalm-readonly * * @psalm-var AbstractValue[] */ protected array $stream_meta; /** @psalm-readonly */ protected ?string $uri; /** @psalm-param AbstractValue[] $stream_meta */ public function __construct(ContextInterface $context, array $stream_meta, ?string $uri) { parent::__construct($context, 'stream'); $this->stream_meta = $stream_meta; $this->uri = $uri; if ($stream_meta) { $this->addRepresentation(new ContainerRepresentation('Stream', $stream_meta, null, true)); } } public function getHint(): string { return parent::getHint() ?? 'stream'; } public function getDisplayValue(): ?string { if (null === $this->uri) { return null; } if ('/' === $this->uri[0] && \stream_is_local($this->uri)) { return Utils::shortenPath($this->uri); } return $this->uri; } public function getDisplayChildren(): array { return $this->stream_meta; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/FunctionValue.php
system/ThirdParty/Kint/Value/FunctionValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; use Kint\Value\Representation\CallableDefinitionRepresentation; class FunctionValue extends AbstractValue { /** @psalm-readonly */ protected DeclaredCallableBag $callable_bag; /** @psalm-readonly */ protected ?CallableDefinitionRepresentation $definition_rep; public function __construct(ContextInterface $c, DeclaredCallableBag $bag) { parent::__construct($c, 'function'); $this->callable_bag = $bag; if ($this->callable_bag->internal) { $this->definition_rep = null; return; } /** * @psalm-var string $this->callable_bag->filename * @psalm-var int $this->callable_bag->startline * Psalm issue #11121 */ $this->definition_rep = new CallableDefinitionRepresentation( $this->callable_bag->filename, $this->callable_bag->startline, $this->callable_bag->docstring ); $this->addRepresentation($this->definition_rep); } public function getCallableBag(): DeclaredCallableBag { return $this->callable_bag; } /** @psalm-api */ public function getDefinitionRepresentation(): ?CallableDefinitionRepresentation { return $this->definition_rep; } public function getDisplayName(): string { return $this->context->getName().'('.$this->callable_bag->getParams().')'; } public function getDisplayValue(): ?string { if ($this->definition_rep instanceof CallableDefinitionRepresentation) { return $this->definition_rep->getDocstringFirstLine(); } return parent::getDisplayValue(); } public function getPhpDocUrl(): ?string { if (!$this->callable_bag->internal) { return null; } return 'https://www.php.net/function.'.\str_replace('_', '-', \strtolower((string) $this->context->getName())); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/MethodValue.php
system/ThirdParty/Kint/Value/MethodValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ClassDeclaredContext; use Kint\Value\Context\MethodContext; use Kint\Value\Representation\CallableDefinitionRepresentation; class MethodValue extends AbstractValue { /** @psalm-readonly */ protected DeclaredCallableBag $callable_bag; /** @psalm-readonly */ protected ?CallableDefinitionRepresentation $definition_rep; public function __construct(MethodContext $c, DeclaredCallableBag $bag) { parent::__construct($c, 'method'); $this->callable_bag = $bag; if ($this->callable_bag->internal) { $this->definition_rep = null; return; } /** * @psalm-var string $this->callable_bag->filename * @psalm-var int $this->callable_bag->startline * Psalm issue #11121 */ $this->definition_rep = new CallableDefinitionRepresentation( $this->callable_bag->filename, $this->callable_bag->startline, $this->callable_bag->docstring ); $this->addRepresentation($this->definition_rep); } public function getHint(): string { return parent::getHint() ?? 'callable'; } public function getContext(): MethodContext { /** * @psalm-var MethodContext $this->context * Psalm discuss #11116 */ return $this->context; } public function getCallableBag(): DeclaredCallableBag { return $this->callable_bag; } /** @psalm-api */ public function getDefinitionRepresentation(): ?CallableDefinitionRepresentation { return $this->definition_rep; } public function getFullyQualifiedDisplayName(): string { $c = $this->getContext(); return $c->owner_class.'::'.$c->getName().'('.$this->callable_bag->getParams().')'; } public function getDisplayName(): string { $c = $this->getContext(); if ($c->static || (ClassDeclaredContext::ACCESS_PRIVATE === $c->access && $c->inherited)) { return $this->getFullyQualifiedDisplayName(); } return $c->getName().'('.$this->callable_bag->getParams().')'; } public function getDisplayValue(): ?string { if ($this->definition_rep instanceof CallableDefinitionRepresentation) { return $this->definition_rep->getDocstringFirstLine(); } return parent::getDisplayValue(); } public function getPhpDocUrl(): ?string { if (!$this->callable_bag->internal) { return null; } $c = $this->getContext(); $class = \str_replace('\\', '-', \strtolower($c->owner_class)); $funcname = \str_replace('_', '-', \strtolower($c->getName())); if (0 === \strpos($funcname, '--') && 0 !== \strpos($funcname, '-', 2)) { $funcname = \substr($funcname, 2); } return 'https://www.php.net/'.$class.'.'.$funcname; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ClosedResourceValue.php
system/ThirdParty/Kint/Value/ClosedResourceValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class ClosedResourceValue extends AbstractValue { public function __construct(ContextInterface $context) { parent::__construct($context, 'resource (closed)'); } public function getDisplayType(): string { return 'closed resource'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/InstanceValue.php
system/ThirdParty/Kint/Value/InstanceValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class InstanceValue extends AbstractValue { /** * @psalm-readonly * * @psalm-var class-string */ protected string $classname; /** @psalm-readonly */ protected string $spl_object_hash; /** @psalm-readonly */ protected int $spl_object_id; /** * The canonical children of this value, for text renderers. * * @psalm-var null|list<AbstractValue> */ protected ?array $children = null; /** @psalm-param class-string $classname */ public function __construct( ContextInterface $context, string $classname, string $spl_object_hash, int $spl_object_id ) { parent::__construct($context, 'object'); $this->classname = $classname; $this->spl_object_hash = $spl_object_hash; $this->spl_object_id = $spl_object_id; } /** @psalm-return class-string */ public function getClassName(): string { return $this->classname; } public function getSplObjectHash(): string { return $this->spl_object_hash; } public function getSplObjectId(): int { return $this->spl_object_id; } /** @psalm-param null|list<AbstractValue> $children */ public function setChildren(?array $children): void { $this->children = $children; } /** @psalm-return null|list<AbstractValue> */ public function getChildren(): ?array { return $this->children; } public function getDisplayType(): string { return $this->classname; } public function getDisplaySize(): ?string { if (null === $this->children) { return null; } return (string) \count($this->children); } public function getDisplayChildren(): array { return $this->children ?? []; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/VirtualValue.php
system/ThirdParty/Kint/Value/VirtualValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; class VirtualValue extends AbstractValue { public function __construct(ContextInterface $context) { parent::__construct($context, 'virtual'); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/StringValue.php
system/ThirdParty/Kint/Value/StringValue.php
<?php declare(strict_types=1); /* * 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\Value; use DomainException; use Kint\Value\Context\ContextInterface; /** * @psalm-type Encoding = string|false */ class StringValue extends AbstractValue { /** @psalm-readonly */ protected string $value; /** * @psalm-readonly * * @psalm-var Encoding */ protected $encoding; /** @psalm-readonly */ protected int $length; /** @psalm-param Encoding $encoding */ public function __construct(ContextInterface $context, string $value, $encoding = false) { parent::__construct($context, 'string'); $this->value = $value; $this->encoding = $encoding; $this->length = \strlen($value); } public function getValue(): string { return $this->value; } public function getValueUtf8(): string { if (false === $this->encoding) { throw new DomainException('StringValue with no encoding can\'t be converted to UTF-8'); } if ('ASCII' === $this->encoding || 'UTF-8' === $this->encoding) { return $this->value; } return \mb_convert_encoding($this->value, 'UTF-8', $this->encoding); } /** @psalm-api */ public function getLength(): int { return $this->length; } /** @psalm-return Encoding */ public function getEncoding() { return $this->encoding; } public function getDisplayType(): string { if (false === $this->encoding) { return 'binary '.$this->type; } if ('ASCII' === $this->encoding) { return $this->type; } return $this->encoding.' '.$this->type; } public function getDisplaySize(): string { return (string) $this->length; } public function getDisplayValue(): string { return '"'.$this->value.'"'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ClosureValue.php
system/ThirdParty/Kint/Value/ClosureValue.php
<?php declare(strict_types=1); /* * 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\Value; use Closure; use Kint\Utils; use Kint\Value\Context\BaseContext; use Kint\Value\Context\ContextInterface; use ReflectionFunction; class ClosureValue extends InstanceValue { use ParameterHoldingTrait; /** @psalm-readonly */ protected ?string $filename; /** @psalm-readonly */ protected ?int $startline; public function __construct(ContextInterface $context, Closure $cl) { parent::__construct($context, \get_class($cl), \spl_object_hash($cl), \spl_object_id($cl)); /** * @psalm-suppress UnnecessaryVarAnnotation * * @psalm-var ContextInterface $this->context * Psalm bug #11113 */ $closure = new ReflectionFunction($cl); if ($closure->isUserDefined()) { $this->filename = $closure->getFileName(); $this->startline = $closure->getStartLine(); } else { $this->filename = null; $this->startline = null; } $parameters = []; foreach ($closure->getParameters() as $param) { $parameters[] = new ParameterBag($param); } $this->parameters = $parameters; if (!$this->context instanceof BaseContext) { return; } if (0 !== $this->context->getDepth()) { return; } $ap = $this->context->getAccessPath(); if (null === $ap) { return; } if (\preg_match('/^\\((function|fn)\\s*\\(/i', $ap, $match)) { $this->context->name = \strtolower($match[1]); } } /** @psalm-api */ public function getFileName(): ?string { return $this->filename; } /** @psalm-api */ public function getStartLine(): ?int { return $this->startline; } public function getDisplaySize(): ?string { return null; } public function getDisplayName(): string { return $this->context->getName().'('.$this->getParams().')'; } public function getDisplayValue(): ?string { if (null !== $this->filename && null !== $this->startline) { return Utils::shortenPath($this->filename).':'.$this->startline; } return parent::getDisplayValue(); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ColorValue.php
system/ThirdParty/Kint/Value/ColorValue.php
<?php declare(strict_types=1); /* * 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\Value; class ColorValue extends StringValue { public function getHint(): string { return parent::getHint() ?? 'color'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/SimpleXMLElementValue.php
system/ThirdParty/Kint/Value/SimpleXMLElementValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Value\Context\ContextInterface; use SimpleXMLElement; class SimpleXMLElementValue extends InstanceValue { /** @psalm-readonly */ protected ?string $text_content; /** @psalm-param list<SimpleXMLElementValue> $children */ public function __construct( ContextInterface $context, SimpleXMLElement $element, array $children, ?string $text_content ) { parent::__construct($context, \get_class($element), \spl_object_hash($element), \spl_object_id($element)); $this->children = $children; $this->text_content = $text_content; } public function getHint(): string { return parent::getHint() ?? 'simplexml_element'; } public function getDisplaySize(): ?string { if ((bool) $this->children) { return (string) \count($this->children); } if (null !== $this->text_content) { return (string) \strlen($this->text_content); } return null; } public function getDisplayValue(): ?string { if ((bool) $this->children) { return parent::getDisplayValue(); } if (null !== $this->text_content) { return '"'.$this->text_content.'"'; } return null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/TraceValue.php
system/ThirdParty/Kint/Value/TraceValue.php
<?php declare(strict_types=1); /* * 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\Value; class TraceValue extends ArrayValue { public function getHint(): string { return parent::getHint() ?? 'trace'; } public function getDisplayType(): string { return 'Debug Backtrace'; } public function getDisplaySize(): string { if ($this->size > 0) { return parent::getDisplaySize(); } return 'empty'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/TraceFrameValue.php
system/ThirdParty/Kint/Value/TraceFrameValue.php
<?php declare(strict_types=1); /* * 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\Value; use InvalidArgumentException; use Kint\Value\Context\BaseContext; use Kint\Value\Context\MethodContext; use ReflectionFunction; use ReflectionMethod; /** * @psalm-type TraceFrame array{ * function: string, * line?: int, * file?: string, * class?: class-string, * object?: object, * type?: string, * args?: list<mixed> * } */ class TraceFrameValue extends ArrayValue { /** @psalm-readonly */ protected ?string $file; /** @psalm-readonly */ protected ?int $line; /** * @psalm-readonly * * @psalm-var null|FunctionValue|MethodValue */ protected $callable; /** * @psalm-readonly * * @psalm-var list<AbstractValue> */ protected array $args; /** @psalm-readonly */ protected ?InstanceValue $object; /** * @psalm-param TraceFrame $raw_frame */ public function __construct(ArrayValue $old, $raw_frame) { parent::__construct($old->getContext(), $old->getSize(), $old->getContents()); $this->file = $raw_frame['file'] ?? null; $this->line = $raw_frame['line'] ?? null; if (isset($raw_frame['class']) && \method_exists($raw_frame['class'], $raw_frame['function'])) { $func = new ReflectionMethod($raw_frame['class'], $raw_frame['function']); $this->callable = new MethodValue( new MethodContext($func), new DeclaredCallableBag($func) ); } elseif (!isset($raw_frame['class']) && \function_exists($raw_frame['function'])) { $func = new ReflectionFunction($raw_frame['function']); $this->callable = new FunctionValue( new BaseContext($raw_frame['function']), new DeclaredCallableBag($func) ); } else { // Mostly closures, no way to get them $this->callable = null; } foreach ($this->contents as $frame_prop) { $c = $frame_prop->getContext(); if ('object' === $c->getName()) { if (!$frame_prop instanceof InstanceValue) { throw new InvalidArgumentException('object key of TraceFrameValue must be parsed to InstanceValue'); } $this->object = $frame_prop; } if ('args' === $c->getName()) { if (!$frame_prop instanceof ArrayValue) { throw new InvalidArgumentException('args key of TraceFrameValue must be parsed to ArrayValue'); } $args = \array_values($frame_prop->getContents()); if ($this->callable) { foreach ($this->callable->getCallableBag()->parameters as $param) { if (!isset($args[$param->position])) { break; // Optional args follow } $arg = $args[$param->position]; if ($arg->getContext() instanceof BaseContext) { $arg = clone $arg; $c = $arg->getContext(); if (!$c instanceof BaseContext) { throw new InvalidArgumentException('TraceFrameValue expects arg contexts to be instanceof BaseContext'); } $c->name = '$'.$param->name; $args[$param->position] = $arg; } } } $this->args = $args; } } /** * @psalm-suppress DocblockTypeContradiction * @psalm-suppress RedundantPropertyInitializationCheck * Psalm bug #11124 */ $this->args ??= []; $this->object ??= null; } public function getHint(): string { return parent::getHint() ?? 'trace_frame'; } public function getFile(): ?string { return $this->file; } public function getLine(): ?int { return $this->line; } /** @psalm-return null|FunctionValue|MethodValue */ public function getCallable() { return $this->callable; } /** @psalm-return list<AbstractValue> */ public function getArgs(): array { return $this->args; } public function getObject(): ?InstanceValue { return $this->object; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/ParameterHoldingTrait.php
system/ThirdParty/Kint/Value/ParameterHoldingTrait.php
<?php declare(strict_types=1); /* * 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\Value; trait ParameterHoldingTrait { /** * @psalm-readonly * * @psalm-var ParameterBag[] */ public array $parameters = []; public function getParams(): string { $out = []; foreach ($this->parameters as $p) { $out[] = (string) $p; } return \implode(', ', $out); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/SplFileInfoValue.php
system/ThirdParty/Kint/Value/SplFileInfoValue.php
<?php declare(strict_types=1); /* * 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\Value; use Kint\Utils; use Kint\Value\Context\ContextInterface; use RuntimeException; use SplFileInfo; class SplFileInfoValue extends InstanceValue { /** @psalm-readonly */ protected string $path; /** @psalm-readonly */ protected ?int $filesize = null; public function __construct(ContextInterface $context, SplFileInfo $info) { parent::__construct($context, \get_class($info), \spl_object_hash($info), \spl_object_id($info)); $this->path = $info->getPathname(); try { // SplFileInfo::getRealPath will return cwd when path is '' if ('' !== $this->path && $info->getRealPath()) { $this->filesize = $info->getSize(); } } catch (RuntimeException $e) { if (false === \strpos($e->getMessage(), ' open_basedir ')) { throw $e; // @codeCoverageIgnore } } } public function getHint(): string { return parent::getHint() ?? 'splfileinfo'; } /** @psalm-api */ public function getFileSize(): ?int { return $this->filesize; } public function getDisplaySize(): ?string { if (null === $this->filesize) { return null; } $size = Utils::getHumanReadableBytes($this->filesize); return $size['value'].$size['unit']; } public function getDisplayValue(): ?string { $shortpath = Utils::shortenPath($this->path); if ($shortpath !== $this->path) { return $shortpath; } return parent::getDisplayValue(); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/BinaryRepresentation.php
system/ThirdParty/Kint/Value/Representation/BinaryRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; class BinaryRepresentation extends AbstractRepresentation { /** @psalm-readonly */ protected string $value; public function __construct(string $value, bool $implicit = false) { parent::__construct('Hex dump', 'binary', $implicit); $this->value = $value; } public function getHint(): string { return 'binary'; } public function getValue(): string { return $this->value; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/ColorRepresentation.php
system/ThirdParty/Kint/Value/Representation/ColorRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use InvalidArgumentException; use LogicException; class ColorRepresentation extends AbstractRepresentation { public const COLOR_NAME = 1; public const COLOR_HEX_3 = 2; public const COLOR_HEX_6 = 3; public const COLOR_RGB = 4; public const COLOR_RGBA = 5; public const COLOR_HSL = 6; public const COLOR_HSLA = 7; public const COLOR_HEX_4 = 8; public const COLOR_HEX_8 = 9; /** @psalm-var array<truthy-string, truthy-string> */ public static array $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', ]; protected int $r; protected int $g; protected int $b; protected float $a; /** @psalm-var self::COLOR_* */ protected int $variant; public function __construct(string $value) { parent::__construct('Color', null, true); $this->setValues($value); } public function getHint(): string { return 'color'; } /** * @psalm-api * * @psalm-return self::COLOR_* */ public function getVariant(): int { return $this->variant; } /** * @psalm-param self::COLOR_* $variant * * @psalm-return ?truthy-string */ public function getColor(?int $variant = null): ?string { $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) ?: null; case self::COLOR_HEX_3: if (0 === $this->r % 0x11 && 0 === $this->g % 0x11 && 0 === $this->b % 0x11) { /** @psalm-var truthy-string */ return \sprintf( '#%1X%1X%1X', \round($this->r / 0x11), \round($this->g / 0x11), \round($this->b / 0x11) ); } return null; case self::COLOR_HEX_6: /** @psalm-var truthy-string */ return \sprintf('#%02X%02X%02X', $this->r, $this->g, $this->b); case self::COLOR_RGB: if (1.0 === $this->a) { /** @psalm-var truthy-string */ return \sprintf('rgb(%d, %d, %d)', $this->r, $this->g, $this->b); } /** @psalm-var truthy-string */ return \sprintf('rgb(%d, %d, %d, %s)', $this->r, $this->g, $this->b, \round($this->a, 4)); case self::COLOR_RGBA: /** @psalm-var truthy-string */ 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); $val[1] = \round($val[1] * 100); $val[2] = \round($val[2] * 100); if (1.0 === $this->a) { /** @psalm-var truthy-string */ return \vsprintf('hsl(%d, %d%%, %d%%)', $val); } /** @psalm-var truthy-string */ 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); $val[1] = \round($val[1] * 100); $val[2] = \round($val[2] * 100); /** @psalm-var truthy-string */ 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) { /** @psalm-var truthy-string */ return \sprintf( '#%1X%1X%1X%1X', \round($this->r / 0x11), \round($this->g / 0x11), \round($this->b / 0x11), \round($this->a * 0xF) ); } return null; case self::COLOR_HEX_8: /** @psalm-var truthy-string */ return \sprintf('#%02X%02X%02X%02X', $this->r, $this->g, $this->b, \round($this->a * 0xFF)); } return null; } public function hasAlpha(?int $variant = null): bool { $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(string $value): void { $this->a = 1.0; $value = \strtolower(\trim($value)); // Find out which variant of color input it is if (isset(self::$color_map[$value])) { $this->setValuesFromHex(self::$color_map[$value]); $variant = self::COLOR_NAME; } elseif ('#' === $value[0]) { $variant = $this->setValuesFromHex(\substr($value, 1)); } else { $variant = $this->setValuesFromFunction($value); } // If something has gone horribly wrong if ($this->r > 0xFF || $this->g > 0xFF || $this->b > 0xFF || $this->a > 1) { throw new LogicException('Something has gone wrong with color parsing'); // @codeCoverageIgnore } $this->variant = $variant; } /** @psalm-return self::COLOR_* */ protected function setValuesFromHex(string $hex): int { if (!\ctype_xdigit($hex)) { throw new InvalidArgumentException('Hex color codes must be hexadecimal'); } 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: throw new InvalidArgumentException('Hex color codes must have 3, 4, 6, or 8 characters'); } 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; } /** @psalm-return self::COLOR_* */ protected function setValuesFromFunction(string $value): int { if (!\preg_match('/^((?:rgb|hsl)a?)\\s*\\(([0-9\\.%,\\s\\/\\-]+)\\)$/i', $value, $match)) { throw new InvalidArgumentException('Couldn\'t parse color function string'); } 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: // The regex should preclude this from ever happening throw new InvalidArgumentException('Color functions must be one of rgb/rgba/hsl/hsla'); // @codeCoverageIgnore } $params = \preg_replace('/[,\\s\\/]+/', ',', \trim($match[2])); $params = \explode(',', $params); $params = \array_map('trim', $params); if (\count($params) < 3 || \count($params) > 4) { throw new InvalidArgumentException('Color functions must have 3 or 4 arguments'); } foreach ($params as $i => &$color) { if (false !== \strpos($color, '%')) { $color = (float) \str_replace('%', '', $color); if (\in_array($variant, [self::COLOR_RGB, self::COLOR_RGBA], true) && 3 !== $i) { $color = \round($color / 100 * 0xFF); } else { $color = $color / 100; } } $color = (float) $color; if (0 === $i && \in_array($variant, [self::COLOR_HSL, self::COLOR_HSLA], true)) { $color = \fmod(\fmod($color, 360) + 360, 360); } } /** * @psalm-var non-empty-array<array-key, float> $params * Psalm bug #746 (wontfix) */ switch ($variant) { case self::COLOR_RGBA: case self::COLOR_RGB: if (\min($params) < 0 || \max($params) > 0xFF) { throw new InvalidArgumentException('RGB function arguments must be between 0 and 255'); } break; case self::COLOR_HSLA: case self::COLOR_HSL: if ($params[0] < 0 || $params[0] > 360) { // Should be impossible because of the fmod work throw new InvalidArgumentException('Hue must be between 0 and 360'); // @codeCoverageIgnore } if (\min($params) < 0 || \max($params[1], $params[2]) > 1) { throw new InvalidArgumentException('Saturation/lightness must be between 0 and 1'); } break; } if (4 === \count($params)) { if ($params[3] > 1) { throw new InvalidArgumentException('Alpha must be between 0 and 1'); } $this->a = $params[3]; } if (self::COLOR_HSLA === $variant || self::COLOR_HSL === $variant) { $params = self::hslToRgb($params[0], $params[1], $params[2]); } [$this->r, $this->g, $this->b] = [(int) $params[0], (int) $params[1], (int) $params[2]]; 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(float $h, float $s, float $l): array { 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) > 1) { throw new InvalidArgumentException('The parameters for hslToRgb should be no more than 360, 1, and 1 respectively'); } $h /= 360; $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 $red Red * @param float $green Green * @param float $blue Blue * * @return float[] HSL array */ public static function rgbToHsl(float $red, float $green, float $blue): array { 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.0; $S = 0.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), $S, $L, ]; } /** * Helper function for hslToRgb. Even blacker magic. * * @return float Color value */ private static function hueToRgb(float $m1, float $m2, float $hue): float { $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; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/TableRepresentation.php
system/ThirdParty/Kint/Value/Representation/TableRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use Kint\Value\AbstractValue; class TableRepresentation extends ContainerRepresentation { /** @psalm-param non-empty-array<AbstractValue> $contents */ public function __construct(array $contents, ?string $name = null) { parent::__construct('Table', $contents, $name, false); } public function getHint(): string { return 'table'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/AbstractRepresentation.php
system/ThirdParty/Kint/Value/Representation/AbstractRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; abstract class AbstractRepresentation implements RepresentationInterface { /** @psalm-readonly */ protected string $label; /** @psalm-readonly */ protected string $name; /** @psalm-readonly */ protected bool $implicit_label; public function __construct(string $label, ?string $name = null, bool $implicit_label = false) { $this->label = $label; $this->name = \preg_replace('/[^a-z0-9]+/', '_', \strtolower($name ?? $label)); $this->implicit_label = $implicit_label; } public function getLabel(): string { return $this->label; } public function getName(): string { return $this->name; } public function labelIsImplicit(): bool { return $this->implicit_label; } public function getHint(): ?string { return null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/SourceRepresentation.php
system/ThirdParty/Kint/Value/Representation/SourceRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use RuntimeException; class SourceRepresentation extends AbstractRepresentation { private const DEFAULT_PADDING = 7; /** * @psalm-readonly * * @psalm-var non-empty-array<string> */ protected array $source; /** @psalm-readonly */ protected string $filename; /** @psalm-readonly */ protected int $line; /** @psalm-readonly */ protected bool $showfilename; public function __construct(string $filename, int $line, ?int $padding = self::DEFAULT_PADDING, bool $showfilename = false) { parent::__construct('Source'); $this->filename = $filename; $this->line = $line; $this->showfilename = $showfilename; $padding ??= self::DEFAULT_PADDING; $start_line = \max($line - $padding, 1); $length = $line + $padding + 1 - $start_line; $this->source = self::readSource($filename, $start_line, $length); } public function getHint(): string { return 'source'; } /** * @psalm-api * * @psalm-return non-empty-string */ public function getSourceSlice(): string { return \implode("\n", $this->source); } /** @psalm-return non-empty-array<string> */ public function getSourceLines(): array { return $this->source; } public function getFileName(): string { return $this->filename; } public function getLine(): int { return $this->line; } public function showFileName(): bool { return $this->showfilename; } /** * Gets section of source code. * * @psalm-return non-empty-array<string> */ private static function readSource(string $filename, int $start_line = 1, ?int $length = null): array { if (!$filename || !\file_exists($filename) || !\is_readable($filename)) { throw new RuntimeException("Couldn't read file"); } $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); if (0 === \count($source)) { throw new RuntimeException('File seemed to be empty'); } return $source; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/RepresentationInterface.php
system/ThirdParty/Kint/Value/Representation/RepresentationInterface.php
<?php declare(strict_types=1); /* * 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\Value\Representation; interface RepresentationInterface { public function getLabel(): string; public function getName(): string; public function getHint(): ?string; public function labelIsImplicit(): bool; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/MicrotimeRepresentation.php
system/ThirdParty/Kint/Value/Representation/MicrotimeRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use DateTimeImmutable; use DateTimeInterface; class MicrotimeRepresentation extends AbstractRepresentation { /** @psalm-readonly */ protected int $seconds; /** @psalm-readonly */ protected int $microseconds; /** @psalm-readonly */ protected string $group; /** @psalm-readonly */ protected ?float $lap_time; /** @psalm-readonly */ protected ?float $total_time; protected ?float $avg_time = null; /** @psalm-readonly */ protected int $mem; /** @psalm-readonly */ protected int $mem_real; /** @psalm-readonly */ protected int $mem_peak; /** @psalm-readonly */ protected int $mem_peak_real; public function __construct(int $seconds, int $microseconds, string $group, ?float $lap_time = null, ?float $total_time = null, int $i = 0) { parent::__construct('Microtime', null, true); $this->seconds = $seconds; $this->microseconds = $microseconds; $this->group = $group; $this->lap_time = $lap_time; $this->total_time = $total_time; if ($i > 0) { $this->avg_time = $total_time / $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 getHint(): string { return 'microtime'; } public function getGroup(): string { return $this->group; } public function getLapTime(): ?float { return $this->lap_time; } public function getTotalTime(): ?float { return $this->total_time; } public function getAverageTime(): ?float { return $this->avg_time; } public function getMemoryUsage(): int { return $this->mem; } public function getMemoryUsageReal(): int { return $this->mem_real; } public function getMemoryPeakUsage(): int { return $this->mem_peak; } public function getMemoryPeakUsageReal(): int { return $this->mem_peak_real; } public function getDateTime(): ?DateTimeInterface { return DateTimeImmutable::createFromFormat('U u', $this->seconds.' '.\str_pad((string) $this->microseconds, 6, '0', STR_PAD_LEFT)) ?: null; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/ContainerRepresentation.php
system/ThirdParty/Kint/Value/Representation/ContainerRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use InvalidArgumentException; use Kint\Value\AbstractValue; class ContainerRepresentation extends AbstractRepresentation { /** * @psalm-readonly * * @psalm-var non-empty-array<AbstractValue> */ protected array $contents; /** @psalm-param non-empty-array<AbstractValue> $contents */ public function __construct(string $label, array $contents, ?string $name = null, bool $implicit_label = false) { if ([] === $contents) { throw new InvalidArgumentException("ContainerRepresentation can't take empty list"); } parent::__construct($label, $name, $implicit_label); $this->contents = $contents; } /** @psalm-return non-empty-array<AbstractValue> */ public function getContents(): array { return $this->contents; } public function getLabel(): string { return parent::getLabel().' ('.\count($this->contents).')'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/CallableDefinitionRepresentation.php
system/ThirdParty/Kint/Value/Representation/CallableDefinitionRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use InvalidArgumentException; class CallableDefinitionRepresentation extends AbstractRepresentation { /** @psalm-readonly */ protected string $filename; /** @psalm-readonly */ protected int $line; /** * @psalm-readonly * * @psalm-var ?non-empty-string */ protected ?string $docstring; /** * @psalm-param ?non-empty-string $docstring */ public function __construct(string $filename, int $line, ?string $docstring) { if (null !== $docstring && !\preg_match('%^/\\*\\*.+\\*/$%s', $docstring)) { throw new InvalidArgumentException('Docstring is invalid'); } parent::__construct('Callable definition', null, true); $this->filename = $filename; $this->line = $line; $this->docstring = $docstring; } public function getHint(): string { return 'callable'; } public function getFileName(): string { return $this->filename; } public function getLine(): int { return $this->line; } /** * @psalm-api * * @psalm-return ?non-empty-string */ public function getDocstring(): ?string { return $this->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. */ public function getDocstringWithoutComments(): ?string { if (null === ($ds = $this->getDocstring())) { return null; } $string = \substr($ds, 3, -2); $string = \preg_replace('/^\\s*\\*\\s*?(\\S|$)/m', '\\1', $string); return \trim($string); } public function getDocstringFirstLine(): ?string { $ds = $this->getDocstringWithoutComments(); if (null === $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); } return null; } public function getDocstringTrimmed(): ?string { if (null === ($ds = $this->getDocstring())) { return null; } $docstring = []; foreach (\explode("\n", $ds) as $line) { $line = \trim($line); if (($line[0] ?? null) === '*') { $line = ' '.$line; } $docstring[] = $line; } return \implode("\n", $docstring); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/SplFileInfoRepresentation.php
system/ThirdParty/Kint/Value/Representation/SplFileInfoRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use Kint\Utils; use RuntimeException; use SplFileInfo; class SplFileInfoRepresentation extends StringRepresentation { public function __construct(SplFileInfo $fileInfo) { $path = $fileInfo->getPathname(); $perms = 0; $owner = null; $group = null; $mtime = null; $realpath = null; $linktarget = null; $size = null; $is_file = false; $is_dir = false; $is_link = false; $typename = 'Unknown file'; try { // SplFileInfo::getRealPath will return cwd when path is '' if ('' !== $path && $fileInfo->getRealPath()) { $perms = $fileInfo->getPerms(); $size = $fileInfo->getSize(); $owner = $fileInfo->getOwner(); $group = $fileInfo->getGroup(); $mtime = $fileInfo->getMTime(); $realpath = $fileInfo->getRealPath(); } $is_dir = $fileInfo->isDir(); $is_file = $fileInfo->isFile(); $is_link = $fileInfo->isLink(); if ($is_link) { $lt = $fileInfo->getLinkTarget(); $linktarget = false === $lt ? null : $lt; } } catch (RuntimeException $e) { if (false === \strpos($e->getMessage(), ' open_basedir ')) { throw $e; // @codeCoverageIgnore } } $typeflag = '-'; switch ($perms & 0xF000) { case 0xC000: $typename = 'Socket'; $typeflag = 's'; break; case 0x6000: $typename = 'Block device'; $typeflag = 'b'; break; case 0x2000: $typename = 'Character device'; $typeflag = 'c'; break; case 0x1000: $typename = 'Named pipe'; $typeflag = 'p'; break; default: if ($is_file) { if ($is_link) { $typename = 'File symlink'; $typeflag = 'l'; } else { $typename = 'File'; $typeflag = '-'; } } elseif ($is_dir) { if ($is_link) { $typename = 'Directory symlink'; $typeflag = 'l'; } else { $typename = 'Directory'; $typeflag = 'd'; } } break; } $flags = [$typeflag]; // User $flags[] = (($perms & 0400) ? 'r' : '-'); $flags[] = (($perms & 0200) ? 'w' : '-'); if ($perms & 0100) { $flags[] = ($perms & 04000) ? 's' : 'x'; } else { $flags[] = ($perms & 04000) ? 'S' : '-'; } // Group $flags[] = (($perms & 0040) ? 'r' : '-'); $flags[] = (($perms & 0020) ? 'w' : '-'); if ($perms & 0010) { $flags[] = ($perms & 02000) ? 's' : 'x'; } else { $flags[] = ($perms & 02000) ? 'S' : '-'; } // Other $flags[] = (($perms & 0004) ? 'r' : '-'); $flags[] = (($perms & 0002) ? 'w' : '-'); if ($perms & 0001) { $flags[] = ($perms & 01000) ? 's' : 'x'; } else { $flags[] = ($perms & 01000) ? 'S' : '-'; } $contents = \implode($flags).' '.$owner.' '.$group.' '.$size.' '; if (null !== $mtime) { if (\date('Y', $mtime) === \date('Y')) { $contents .= \date('M d H:i', $mtime); } else { $contents .= \date('M d Y', $mtime); } } $contents .= ' '; if ($is_link && null !== $linktarget) { $contents .= $path.' -> '.$linktarget; } elseif (null !== $realpath && \strlen($realpath) < \strlen($path)) { $contents .= $realpath; } else { $contents .= $path; } $label = $typename; if (null !== $size && $is_file) { $size = Utils::getHumanReadableBytes($size); $label .= ' ('.$size['value'].$size['unit'].')'; } parent::__construct($label, $contents, 'splfileinfo'); } public function getHint(): string { return 'splfileinfo'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/ProfileRepresentation.php
system/ThirdParty/Kint/Value/Representation/ProfileRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; class ProfileRepresentation extends AbstractRepresentation { /** @psalm-readonly */ public int $complexity; public ?int $instance_counts = null; public ?int $instance_complexity = null; public function __construct(int $complexity) { parent::__construct('Performance profile', 'profiling', false); $this->complexity = $complexity; } public function getHint(): string { return 'profiling'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/ValueRepresentation.php
system/ThirdParty/Kint/Value/Representation/ValueRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use Kint\Value\AbstractValue; class ValueRepresentation extends AbstractRepresentation { /** @psalm-readonly */ protected AbstractValue $value; public function __construct(string $label, AbstractValue $value, ?string $name = null, bool $implicit_label = false) { parent::__construct($label, $name, $implicit_label); $this->value = $value; } public function getValue(): AbstractValue { return $this->value; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Representation/StringRepresentation.php
system/ThirdParty/Kint/Value/Representation/StringRepresentation.php
<?php declare(strict_types=1); /* * 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\Value\Representation; use InvalidArgumentException; class StringRepresentation extends AbstractRepresentation { /** * @psalm-readonly * * @psalm-var non-empty-string */ protected string $value; /** @psalm-assert non-empty-string $value */ public function __construct(string $label, string $value, ?string $name = null, bool $implicit = false) { if ('' === $value) { throw new InvalidArgumentException("StringRepresentation can't take empty string"); } parent::__construct($label, $name, $implicit); $this->value = $value; } /** @psalm-return non-empty-string */ public function getValue(): string { return $this->value; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/DoubleAccessMemberContext.php
system/ThirdParty/Kint/Value/Context/DoubleAccessMemberContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; abstract class DoubleAccessMemberContext extends ClassDeclaredContext { /** @psalm-var ?self::ACCESS_* */ public ?int $access_set = null; protected function getAccess(): string { switch ($this->access) { case self::ACCESS_PUBLIC: if (self::ACCESS_PRIVATE === $this->access_set) { return 'private(set)'; } if (self::ACCESS_PROTECTED === $this->access_set) { return 'protected(set)'; } return 'public'; case self::ACCESS_PROTECTED: if (self::ACCESS_PRIVATE === $this->access_set) { return 'protected private(set)'; } return 'protected'; case self::ACCESS_PRIVATE: return 'private'; } } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/BaseContext.php
system/ThirdParty/Kint/Value/Context/BaseContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; use InvalidArgumentException; /** * @psalm-import-type ValueName from ContextInterface */ class BaseContext implements ContextInterface { /** @psalm-var ValueName */ public $name; public int $depth = 0; public bool $reference = false; public ?string $access_path = null; /** @psalm-param mixed $name */ public function __construct($name) { if (!\is_string($name) && !\is_int($name)) { throw new InvalidArgumentException('Context names must be string|int'); } $this->name = $name; } public function getName() { return $this->name; } public function getDepth(): int { return $this->depth; } public function getOperator(): ?string { return null; } public function isRef(): bool { return $this->reference; } /** @psalm-param ?class-string $scope */ public function isAccessible(?string $scope): bool { return true; } public function getAccessPath(): ?string { return $this->access_path; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/MethodContext.php
system/ThirdParty/Kint/Value/Context/MethodContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; use Kint\Value\InstanceValue; use ReflectionMethod; class MethodContext extends ClassDeclaredContext { public const MAGIC_NAMES = [ '__construct' => true, '__destruct' => true, '__call' => true, '__callstatic' => true, '__get' => true, '__set' => true, '__isset' => true, '__unset' => true, '__sleep' => true, '__wakeup' => true, '__serialize' => true, '__unserialize' => true, '__tostring' => true, '__invoke' => true, '__set_state' => true, '__clone' => true, '__debuginfo' => true, ]; public bool $final = false; public bool $abstract = false; public bool $static = false; /** * Whether the method was inherited from a parent class or interface. * * It's important to note that we never show static methods as * "inherited" except when abstract via an interface. */ public bool $inherited = false; public function __construct(ReflectionMethod $method) { parent::__construct( $method->getName(), $method->getDeclaringClass()->name, ClassDeclaredContext::ACCESS_PUBLIC ); $this->depth = 1; $this->static = $method->isStatic(); $this->abstract = $method->isAbstract(); $this->final = $method->isFinal(); if ($method->isProtected()) { $this->access = ClassDeclaredContext::ACCESS_PROTECTED; } elseif ($method->isPrivate()) { $this->access = ClassDeclaredContext::ACCESS_PRIVATE; } } public function getOperator(): string { if ($this->static) { return '::'; } return '->'; } public function getModifiers(): string { if ($this->abstract) { $out = 'abstract '; } elseif ($this->final) { $out = 'final '; } else { $out = ''; } $out .= $this->getAccess(); if ($this->static) { $out .= ' static'; } return $out; } public function setAccessPathFromParent(?InstanceValue $parent): void { $name = \strtolower($this->getName()); if ($this->static && !isset(self::MAGIC_NAMES[$name])) { $this->access_path = '\\'.$this->owner_class.'::'.$this->name.'()'; } elseif (null === $parent) { $this->access_path = null; } else { $c = $parent->getContext(); if ('__construct' === $name) { $this->access_path = 'new \\'.$parent->getClassName().'()'; } elseif (null === $c->getAccessPath()) { $this->access_path = null; } elseif ('__invoke' === $name) { $this->access_path = $c->getAccessPath().'()'; } elseif ('__clone' === $name) { $this->access_path = 'clone '.$c->getAccessPath(); } elseif ('__tostring' === $name) { $this->access_path = '(string) '.$c->getAccessPath(); } elseif (isset(self::MAGIC_NAMES[$name])) { $this->access_path = null; } else { $this->access_path = $c->getAccessPath().'->'.$this->name.'()'; } } } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/ClassConstContext.php
system/ThirdParty/Kint/Value/Context/ClassConstContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; class ClassConstContext extends ClassDeclaredContext { public bool $final = false; public function getName(): string { return $this->owner_class.'::'.$this->name; } public function getOperator(): string { return '::'; } public function getModifiers(): string { $final = $this->final ? 'final ' : ''; return $final.$this->getAccess().' const'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/ClassDeclaredContext.php
system/ThirdParty/Kint/Value/Context/ClassDeclaredContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; use __PHP_Incomplete_Class; abstract class ClassDeclaredContext extends ClassOwnedContext { public const ACCESS_PUBLIC = 1; public const ACCESS_PROTECTED = 2; public const ACCESS_PRIVATE = 3; /** @psalm-var self::ACCESS_* */ public int $access; /** * @psalm-param class-string $owner_class * @psalm-param self::ACCESS_* $access */ public function __construct(string $name, string $owner_class, int $access) { parent::__construct($name, $owner_class); $this->access = $access; } abstract public function getModifiers(): string; /** @psalm-param ?class-string $scope */ public function isAccessible(?string $scope): bool { if (__PHP_Incomplete_Class::class === $this->owner_class) { return false; } if (self::ACCESS_PUBLIC === $this->access) { return true; } if (null === $scope) { return false; } if (self::ACCESS_PRIVATE === $this->access) { return $scope === $this->owner_class; } if (\is_a($scope, $this->owner_class, true)) { return true; } if (\is_a($this->owner_class, $scope, true)) { return true; } return false; } protected function getAccess(): string { switch ($this->access) { case self::ACCESS_PUBLIC: return 'public'; case self::ACCESS_PROTECTED: return 'protected'; case self::ACCESS_PRIVATE: return 'private'; } } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/PropertyContext.php
system/ThirdParty/Kint/Value/Context/PropertyContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; class PropertyContext extends DoubleAccessMemberContext { public const HOOK_NONE = 0; public const HOOK_GET = 1 << 0; public const HOOK_GET_REF = 1 << 1; public const HOOK_SET = 1 << 2; public const HOOK_SET_TYPE = 1 << 3; public bool $readonly = false; /** @psalm-var int-mask-of<self::HOOK_*> */ public int $hooks = self::HOOK_NONE; public ?string $hook_set_type = null; public function getModifiers(): string { $out = $this->getAccess(); if ($this->readonly) { $out .= ' readonly'; } return $out; } public function getHooks(): ?string { if (self::HOOK_NONE === $this->hooks) { return null; } $out = '{ '; if ($this->hooks & self::HOOK_GET) { if ($this->hooks & self::HOOK_GET_REF) { $out .= '&'; } $out .= 'get; '; } if ($this->hooks & self::HOOK_SET) { if ($this->hooks & self::HOOK_SET_TYPE && '' !== ($this->hook_set_type ?? '')) { $out .= 'set('.$this->hook_set_type.'); '; } else { $out .= 'set; '; } } $out .= '}'; return $out; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/StaticPropertyContext.php
system/ThirdParty/Kint/Value/Context/StaticPropertyContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; class StaticPropertyContext extends DoubleAccessMemberContext { public bool $final = false; public function getName(): string { return $this->owner_class.'::$'.$this->name; } public function getOperator(): string { return '::'; } public function getModifiers(): string { $final = $this->final ? 'final ' : ''; return $final.$this->getAccess().' static'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/ContextInterface.php
system/ThirdParty/Kint/Value/Context/ContextInterface.php
<?php declare(strict_types=1); /* * 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\Value\Context; /** * Contexts represent the data that has to be found out about a zval _before_ * passing it into the next parse depth. This includes the access path, whether * it's a reference or not, and OOP related stuff like visibility. * * @psalm-type ValueName = string|int */ interface ContextInterface { /** @psalm-return ValueName */ public function getName(); public function getDepth(): int; public function isRef(): bool; /** @psalm-param ?class-string $scope */ public function isAccessible(?string $scope): bool; public function getAccessPath(): ?string; /** @psalm-return ?non-empty-string */ public function getOperator(): ?string; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/ClassOwnedContext.php
system/ThirdParty/Kint/Value/Context/ClassOwnedContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; use __PHP_Incomplete_Class; class ClassOwnedContext extends BaseContext { /** @psalm-var class-string */ public string $owner_class; /** @psalm-param class-string $owner_class */ public function __construct(string $name, string $owner_class) { parent::__construct($name); $this->owner_class = $owner_class; } public function getName(): string { return (string) $this->name; } public function getOperator(): string { return '->'; } /** @psalm-param ?class-string $scope */ public function isAccessible(?string $scope): bool { return __PHP_Incomplete_Class::class !== $this->owner_class; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/Kint/Value/Context/ArrayContext.php
system/ThirdParty/Kint/Value/Context/ArrayContext.php
<?php declare(strict_types=1); /* * 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\Value\Context; class ArrayContext extends BaseContext { public function getOperator(): ?string { return '=>'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/LoggerAwareInterface.php
system/ThirdParty/PSR/Log/LoggerAwareInterface.php
<?php namespace Psr\Log; /** * Describes a logger-aware instance. */ interface LoggerAwareInterface { /** * Sets a logger instance on the object. */ public function setLogger(LoggerInterface $logger): void; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/AbstractLogger.php
system/ThirdParty/PSR/Log/AbstractLogger.php
<?php namespace Psr\Log; /** * This is a simple Logger implementation that other Loggers can inherit from. * * It simply delegates all log-level-specific methods to the `log` method to * reduce boilerplate code that a simple Logger that does the same thing with * messages regardless of the error level has to implement. */ abstract class AbstractLogger implements LoggerInterface { use LoggerTrait; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/LogLevel.php
system/ThirdParty/PSR/Log/LogLevel.php
<?php namespace Psr\Log; /** * Describes log levels. */ class LogLevel { const EMERGENCY = 'emergency'; const ALERT = 'alert'; const CRITICAL = 'critical'; const ERROR = 'error'; const WARNING = 'warning'; const NOTICE = 'notice'; const INFO = 'info'; const DEBUG = 'debug'; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/LoggerAwareTrait.php
system/ThirdParty/PSR/Log/LoggerAwareTrait.php
<?php namespace Psr\Log; /** * Basic Implementation of LoggerAwareInterface. */ trait LoggerAwareTrait { /** * The logger instance. */ protected ?LoggerInterface $logger = null; /** * Sets a logger. */ public function setLogger(LoggerInterface $logger): void { $this->logger = $logger; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/LoggerTrait.php
system/ThirdParty/PSR/Log/LoggerTrait.php
<?php namespace Psr\Log; /** * This is a simple Logger trait that classes unable to extend AbstractLogger * (because they extend another class, etc) can include. * * It simply delegates all log-level-specific methods to the `log` method to * reduce boilerplate code that a simple Logger that does the same thing with * messages regardless of the error level has to implement. */ trait LoggerTrait { /** * System is unusable. */ public function emergency(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::EMERGENCY, $message, $context); } /** * Action must be taken immediately. * * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. */ public function alert(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::ALERT, $message, $context); } /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. */ public function critical(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::CRITICAL, $message, $context); } /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. */ public function error(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::ERROR, $message, $context); } /** * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. */ public function warning(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::WARNING, $message, $context); } /** * Normal but significant events. */ public function notice(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::NOTICE, $message, $context); } /** * Interesting events. * * Example: User logs in, SQL logs. */ public function info(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::INFO, $message, $context); } /** * Detailed debug information. */ public function debug(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::DEBUG, $message, $context); } /** * Logs with an arbitrary level. * * @param mixed $level * * @throws \Psr\Log\InvalidArgumentException */ abstract public function log($level, string|\Stringable $message, array $context = []): void; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/NullLogger.php
system/ThirdParty/PSR/Log/NullLogger.php
<?php namespace Psr\Log; /** * This Logger can be used to avoid conditional log calls. * * Logging should always be optional, and if no logger is provided to your * library creating a NullLogger instance to have something to throw logs at * is a good way to avoid littering your code with `if ($this->logger) { }` * blocks. */ class NullLogger extends AbstractLogger { /** * Logs with an arbitrary level. * * @param mixed[] $context * * @throws \Psr\Log\InvalidArgumentException */ public function log($level, string|\Stringable $message, array $context = []): void { // noop } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/LoggerInterface.php
system/ThirdParty/PSR/Log/LoggerInterface.php
<?php namespace Psr\Log; /** * Describes a logger instance. * * The message MUST be a string or object implementing __toString(). * * The message MAY contain placeholders in the form: {foo} where foo * will be replaced by the context data in key "foo". * * The context array can contain arbitrary data. The only assumption that * can be made by implementors is that if an Exception instance is given * to produce a stack trace, it MUST be in a key named "exception". * * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md * for the full interface specification. */ interface LoggerInterface { /** * System is unusable. * * @param mixed[] $context */ public function emergency(string|\Stringable $message, array $context = []): void; /** * Action must be taken immediately. * * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * * @param mixed[] $context */ public function alert(string|\Stringable $message, array $context = []): void; /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * * @param mixed[] $context */ public function critical(string|\Stringable $message, array $context = []): void; /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * * @param mixed[] $context */ public function error(string|\Stringable $message, array $context = []): void; /** * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * * @param mixed[] $context */ public function warning(string|\Stringable $message, array $context = []): void; /** * Normal but significant events. * * @param mixed[] $context */ public function notice(string|\Stringable $message, array $context = []): void; /** * Interesting events. * * Example: User logs in, SQL logs. * * @param mixed[] $context */ public function info(string|\Stringable $message, array $context = []): void; /** * Detailed debug information. * * @param mixed[] $context */ public function debug(string|\Stringable $message, array $context = []): void; /** * Logs with an arbitrary level. * * @param mixed $level * @param mixed[] $context * * @throws \Psr\Log\InvalidArgumentException */ public function log($level, string|\Stringable $message, array $context = []): void; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/ThirdParty/PSR/Log/InvalidArgumentException.php
system/ThirdParty/PSR/Log/InvalidArgumentException.php
<?php namespace Psr\Log; class InvalidArgumentException extends \InvalidArgumentException { }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/Database.php
system/Database/Database.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\Exceptions\CriticalError; use CodeIgniter\Exceptions\InvalidArgumentException; /** * Database Connection Factory * * Creates and returns an instance of the appropriate Database Connection. */ class Database { /** * Maintains an array of the instances of all connections that have * been created. * * Helps to keep track of all open connections for performance * monitoring, logging, etc. * * @var array */ protected $connections = []; /** * Parses the connection binds and creates a Database Connection instance. * * @return BaseConnection * * @throws InvalidArgumentException */ public function load(array $params = [], string $alias = '') { if ($alias === '') { throw new InvalidArgumentException('You must supply the parameter: alias.'); } if (! empty($params['DSN']) && str_contains($params['DSN'], '://')) { $params = $this->parseDSN($params); } if (empty($params['DBDriver'])) { throw new InvalidArgumentException('You have not selected a database type to connect to.'); } assert($this->checkDbExtension($params['DBDriver'])); $this->connections[$alias] = $this->initDriver($params['DBDriver'], 'Connection', $params); return $this->connections[$alias]; } /** * Creates a Forge instance for the current database type. */ public function loadForge(ConnectionInterface $db): Forge { if (! $db->connID) { $db->initialize(); } return $this->initDriver($db->DBDriver, 'Forge', $db); } /** * Creates an instance of Utils for the current database type. */ public function loadUtils(ConnectionInterface $db): BaseUtils { if (! $db->connID) { $db->initialize(); } return $this->initDriver($db->DBDriver, 'Utils', $db); } /** * Parses universal DSN string * * @throws InvalidArgumentException */ protected function parseDSN(array $params): array { $dsn = parse_url($params['DSN']); if ($dsn === 0 || $dsn === '' || $dsn === '0' || $dsn === [] || $dsn === false || $dsn === null) { throw new InvalidArgumentException('Your DSN connection string is invalid.'); } $dsnParams = [ 'DSN' => '', 'DBDriver' => $dsn['scheme'], 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '', 'port' => isset($dsn['port']) ? rawurldecode((string) $dsn['port']) : '', 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '', 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '', 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : '', ]; if (isset($dsn['query']) && ($dsn['query'] !== '')) { parse_str($dsn['query'], $extra); foreach ($extra as $key => $val) { if (is_string($val) && in_array(strtolower($val), ['true', 'false', 'null'], true)) { $val = $val === 'null' ? null : filter_var($val, FILTER_VALIDATE_BOOLEAN); } $dsnParams[$key] = $val; } } return array_merge($params, $dsnParams); } /** * Creates a database object. * * @param string $driver Driver name. FQCN can be used. * @param string $class 'Connection'|'Forge'|'Utils' * @param array|ConnectionInterface $argument The constructor parameter or DB connection * * @return BaseConnection|BaseUtils|Forge */ protected function initDriver(string $driver, string $class, $argument): object { $classname = (! str_contains($driver, '\\')) ? "CodeIgniter\\Database\\{$driver}\\{$class}" : $driver . '\\' . $class; return new $classname($argument); } /** * Check the PHP database extension is loaded. * * @param string $driver DB driver or FQCN for custom driver */ private function checkDbExtension(string $driver): bool { if (str_contains($driver, '\\')) { // Cannot check a fully qualified classname for a custom driver. return true; } $extensionMap = [ // DBDriver => PHP extension 'MySQLi' => 'mysqli', 'SQLite3' => 'sqlite3', 'Postgre' => 'pgsql', 'SQLSRV' => 'sqlsrv', 'OCI8' => 'oci8', ]; $extension = $extensionMap[$driver] ?? ''; if ($extension === '') { $message = 'Invalid DBDriver name: "' . $driver . '"'; throw new ConfigException($message); } if (extension_loaded($extension)) { return true; } $message = 'The required PHP extension "' . $extension . '" is not loaded.' . ' Install and enable it to use "' . $driver . '" driver.'; throw new CriticalError($message); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/ConnectionInterface.php
system/Database/ConnectionInterface.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; /** * @template TConnection * @template TResult * * @property false|object|resource $connID * @property-read string $DBDriver */ interface ConnectionInterface { /** * Initializes the database connection/settings. * * @return void */ public function initialize(); /** * Connect to the database. * * @return false|TConnection */ public function connect(bool $persistent = false); /** * Create a persistent database connection. * * @return false|TConnection */ public function persistentConnect(); /** * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. * * @return void */ public function reconnect(); /** * Returns the actual connection object. If both a 'read' and 'write' * connection has been specified, you can pass either term in to * get that connection. If you pass either alias in and only a single * connection is present, it must return the sole connection. * * @return false|TConnection */ public function getConnection(?string $alias = null); /** * Select a specific database table to use. * * @return bool */ public function setDatabase(string $databaseName); /** * Returns the name of the current database being used. */ public function getDatabase(): string; /** * Returns the last error encountered by this connection. * Must return this format: ['code' => string|int, 'message' => string] * intval(code) === 0 means "no error". * * @return array<string, int|string> */ public function error(): array; /** * The name of the platform in use (MySQLi, mssql, etc) */ public function getPlatform(): string; /** * Returns a string containing the version of the database being used. */ public function getVersion(): string; /** * Orchestrates a query against the database. Queries must use * Database\Statement objects to store the query and build it. * This method works with the cache. * * Should automatically handle different connections for read/write * queries if needed. * * @param array|string|null $binds * * @return BaseResult<TConnection, TResult>|bool|Query */ public function query(string $sql, $binds = null); /** * Performs a basic query against the database. No binding or caching * is performed, nor are transactions handled. Simply takes a raw * query string and returns the database-specific result id. * * @return false|TResult */ public function simpleQuery(string $sql); /** * Returns an instance of the query builder for this connection. * * @param array|string $tableName Table name. * * @return BaseBuilder Builder. */ public function table($tableName); /** * Returns the last query's statement object. * * @return Query */ public function getLastQuery(); /** * "Smart" Escaping * * Escapes data based on type. * Sets boolean and null types. * * @param array|bool|float|int|object|string|null $str * * @return ($str is array ? array : float|int|string) */ public function escape($str); /** * Allows for custom calls to the database engine that are not * supported through our database layer. * * @param array ...$params * * @return array|bool|float|int|object|resource|string|null */ public function callFunction(string $functionName, ...$params); /** * Determines if the statement is a write-type query or not. * * @param string $sql */ public function isWriteType($sql): bool; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/MigrationRunner.php
system/Database/MigrationRunner.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; use CodeIgniter\CLI\CLI; use CodeIgniter\Events\Events; use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\I18n\Time; use Config\Database; use Config\Migrations as MigrationsConfig; use stdClass; /** * Class MigrationRunner */ class MigrationRunner { /** * Whether or not migrations are allowed to run. * * @var bool */ protected $enabled = false; /** * Name of table to store meta information * * @var string */ protected $table; /** * The Namespace where migrations can be found. * `null` is all namespaces. * * @var string|null */ protected $namespace; /** * The database Group to migrate. * * @var string */ protected $group; /** * The migration name. * * @var string */ protected $name; /** * The pattern used to locate migration file versions. * * @var string */ protected $regex = '/\A(\d{4}[_-]?\d{2}[_-]?\d{2}[_-]?\d{6})_(\w+)\z/'; /** * The main database connection. Used to store * migration information in. * * @var BaseConnection */ protected $db; /** * If true, will continue instead of throwing * exceptions. * * @var bool */ protected $silent = false; /** * used to return messages for CLI. * * @var array */ protected $cliMessages = []; /** * Tracks whether we have already ensured * the table exists or not. * * @var bool */ protected $tableChecked = false; /** * The full path to locate migration files. * * @var string */ protected $path; /** * The database Group filter. * * @var string|null */ protected $groupFilter; /** * Used to skip current migration. * * @var bool */ protected $groupSkip = false; /** * The migration can manage multiple databases. So it should always use the * default DB group so that it creates the `migrations` table in the default * DB group. Therefore, passing $db is for testing purposes only. * * @param array|ConnectionInterface|string|null $db DB group. For testing purposes only. * * @throws ConfigException */ public function __construct(MigrationsConfig $config, $db = null) { $this->enabled = $config->enabled ?? false; $this->table = $config->table ?? 'migrations'; $this->namespace = APP_NAMESPACE; // Even if a DB connection is passed, since it is a test, // it is assumed to use the default group name $this->group = is_string($db) ? $db : config(Database::class)->defaultGroup; $this->db = db_connect($db); } /** * Locate and run all new migrations * * @return bool * * @throws ConfigException * @throws RuntimeException */ public function latest(?string $group = null) { if (! $this->enabled) { throw ConfigException::forDisabledMigrations(); } $this->ensureTable(); if ($group !== null) { $this->groupFilter = $group; $this->setGroup($group); } $migrations = $this->findMigrations(); if ($migrations === []) { return true; } foreach ($this->getHistory((string) $group) as $history) { unset($migrations[$this->getObjectUid($history)]); } $batch = $this->getLastBatch() + 1; foreach ($migrations as $migration) { if ($this->migrate('up', $migration)) { if ($this->groupSkip === true) { $this->groupSkip = false; continue; } $this->addHistory($migration, $batch); } else { $this->regress(-1); $message = lang('Migrations.generalFault'); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } } $data = get_object_vars($this); $data['method'] = 'latest'; Events::trigger('migrate', $data); return true; } /** * Migrate down to a previous batch * * Calls each migration step required to get to the provided batch * * @param int $targetBatch Target batch number, or negative for a relative batch, 0 for all * @param string|null $group Deprecated. The designation has no effect. * * @return bool True on success, FALSE on failure or no migrations are found * * @throws ConfigException * @throws RuntimeException */ public function regress(int $targetBatch = 0, ?string $group = null) { if (! $this->enabled) { throw ConfigException::forDisabledMigrations(); } $this->ensureTable(); $batches = $this->getBatches(); if ($targetBatch < 0) { $targetBatch = $batches[count($batches) - 1 + $targetBatch] ?? 0; } if ($batches === [] && $targetBatch === 0) { return true; } if ($targetBatch !== 0 && ! in_array($targetBatch, $batches, true)) { $message = lang('Migrations.batchNotFound') . $targetBatch; if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } $tmpNamespace = $this->namespace; $this->namespace = null; $allMigrations = $this->findMigrations(); $migrations = []; while ($batch = array_pop($batches)) { if ($batch <= $targetBatch) { break; } foreach ($this->getBatchHistory($batch, 'desc') as $history) { $uid = $this->getObjectUid($history); if (! isset($allMigrations[$uid])) { $message = lang('Migrations.gap') . ' ' . $history->version; if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } $migration = $allMigrations[$uid]; $migration->history = $history; $migrations[] = $migration; } } foreach ($migrations as $migration) { if ($this->migrate('down', $migration)) { $this->removeHistory($migration->history); } else { $message = lang('Migrations.generalFault'); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } } $data = get_object_vars($this); $data['method'] = 'regress'; Events::trigger('migrate', $data); $this->namespace = $tmpNamespace; return true; } /** * Migrate a single file regardless of order or batches. * Method "up" or "down" determined by presence in history. * NOTE: This is not recommended and provided mostly for testing. * * @param string $path Full path to a valid migration file * @param string $path Namespace of the target migration * * @return bool */ public function force(string $path, string $namespace, ?string $group = null) { if (! $this->enabled) { throw ConfigException::forDisabledMigrations(); } $this->ensureTable(); if ($group !== null) { $this->groupFilter = $group; $this->setGroup($group); } $migration = $this->migrationFromFile($path, $namespace); if (empty($migration)) { $message = lang('Migrations.notFound'); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } $method = 'up'; $this->setNamespace($migration->namespace); foreach ($this->getHistory($this->group) as $history) { if ($this->getObjectUid($history) === $migration->uid) { $method = 'down'; $migration->history = $history; break; } } if ($method === 'up') { $batch = $this->getLastBatch() + 1; if ($this->migrate('up', $migration) && $this->groupSkip === false) { $this->addHistory($migration, $batch); return true; } $this->groupSkip = false; } elseif ($this->migrate('down', $migration)) { $this->removeHistory($migration->history); return true; } $message = lang('Migrations.generalFault'); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } /** * Retrieves list of available migration scripts * * @return array List of all located migrations by their UID */ public function findMigrations(): array { $namespaces = $this->namespace !== null ? [$this->namespace] : array_keys(service('autoloader')->getNamespace()); $migrations = []; foreach ($namespaces as $namespace) { if (ENVIRONMENT !== 'testing' && $namespace === 'Tests\Support') { continue; } foreach ($this->findNamespaceMigrations($namespace) as $migration) { $migrations[$migration->uid] = $migration; } } // Sort migrations ascending by their UID (version) ksort($migrations); return $migrations; } /** * Retrieves a list of available migration scripts for one namespace */ public function findNamespaceMigrations(string $namespace): array { $migrations = []; $locator = service('locator', true); if (! empty($this->path)) { helper('filesystem'); $dir = rtrim($this->path, DIRECTORY_SEPARATOR) . '/'; $files = get_filenames($dir, true, false, false); } else { $files = $locator->listNamespaceFiles($namespace, '/Database/Migrations/'); } foreach ($files as $file) { $file = empty($this->path) ? $file : $this->path . str_replace($this->path, '', $file); if ($migration = $this->migrationFromFile($file, $namespace)) { $migrations[] = $migration; } } return $migrations; } /** * Create a migration object from a file path. * * @param string $path Full path to a valid migration file. * * @return false|object Returns the migration object, or false on failure */ protected function migrationFromFile(string $path, string $namespace) { if (! str_ends_with($path, '.php')) { return false; } $filename = basename($path, '.php'); if (preg_match($this->regex, $filename) !== 1) { return false; } $locator = service('locator', true); $migration = new stdClass(); $migration->version = $this->getMigrationNumber($filename); $migration->name = $this->getMigrationName($filename); $migration->path = $path; $migration->class = $locator->getClassname($path); $migration->namespace = $namespace; $migration->uid = $this->getObjectUid($migration); return $migration; } /** * Allows other scripts to modify on the fly as needed. * * @return MigrationRunner */ public function setNamespace(?string $namespace) { $this->namespace = $namespace; return $this; } /** * Allows other scripts to modify on the fly as needed. * * @return MigrationRunner */ public function setGroup(string $group) { $this->group = $group; return $this; } /** * @return MigrationRunner */ public function setName(string $name) { $this->name = $name; return $this; } /** * If $silent == true, then will not throw exceptions and will * attempt to continue gracefully. * * @return MigrationRunner */ public function setSilent(bool $silent) { $this->silent = $silent; return $this; } /** * Extracts the migration number from a filename * * @param string $migration A migration filename w/o path. */ protected function getMigrationNumber(string $migration): string { preg_match($this->regex, $migration, $matches); return $matches !== [] ? $matches[1] : '0'; } /** * Extracts the migration name from a filename * * Note: The migration name should be the classname, but maybe they are * different. * * @param string $migration A migration filename w/o path. */ protected function getMigrationName(string $migration): string { preg_match($this->regex, $migration, $matches); return $matches !== [] ? $matches[2] : ''; } /** * Uses the non-repeatable portions of a migration or history * to create a sortable unique key * * @param object $object migration or $history */ public function getObjectUid($object): string { return preg_replace('/[^0-9]/', '', $object->version) . $object->class; } /** * Retrieves messages formatted for CLI output */ public function getCliMessages(): array { return $this->cliMessages; } /** * Clears any CLI messages. * * @return MigrationRunner */ public function clearCliMessages() { $this->cliMessages = []; return $this; } /** * Truncates the history table. * * @return void */ public function clearHistory() { if ($this->db->tableExists($this->table)) { $this->db->table($this->table)->truncate(); } } /** * Add a history to the table. * * @param object $migration * * @return void */ protected function addHistory($migration, int $batch) { $this->db->table($this->table)->insert([ 'version' => $migration->version, 'class' => $migration->class, 'group' => $this->group, 'namespace' => $migration->namespace, 'time' => Time::now()->getTimestamp(), 'batch' => $batch, ]); if (is_cli()) { $this->cliMessages[] = sprintf( "\t%s(%s) %s_%s", CLI::color(lang('Migrations.added'), 'yellow'), $migration->namespace, $migration->version, $migration->class, ); } } /** * Removes a single history * * @param object $history * * @return void */ protected function removeHistory($history) { $this->db->table($this->table)->where('id', $history->id)->delete(); if (is_cli()) { $this->cliMessages[] = sprintf( "\t%s(%s) %s_%s", CLI::color(lang('Migrations.removed'), 'yellow'), $history->namespace, $history->version, $history->class, ); } } /** * Grabs the full migration history from the database for a group */ public function getHistory(string $group = 'default'): array { $this->ensureTable(); $builder = $this->db->table($this->table); // If group was specified then use it if ($group !== '') { $builder->where('group', $group); } // If a namespace was specified then use it if ($this->namespace !== null) { $builder->where('namespace', $this->namespace); } $query = $builder->orderBy('id', 'ASC')->get(); return ! empty($query) ? $query->getResultObject() : []; } /** * Returns the migration history for a single batch. * * @param string $order */ public function getBatchHistory(int $batch, $order = 'asc'): array { $this->ensureTable(); $query = $this->db->table($this->table) ->where('batch', $batch) ->orderBy('id', $order) ->get(); return ! empty($query) ? $query->getResultObject() : []; } /** * Returns all the batches from the database history in order */ public function getBatches(): array { $this->ensureTable(); $batches = $this->db->table($this->table) ->select('batch') ->distinct() ->orderBy('batch', 'asc') ->get() ->getResultArray(); return array_map(intval(...), array_column($batches, 'batch')); } /** * Returns the value of the last batch in the database. */ public function getLastBatch(): int { $this->ensureTable(); $batch = $this->db->table($this->table) ->selectMax('batch') ->get() ->getResultObject(); $batch = is_array($batch) && $batch !== [] ? end($batch)->batch : 0; return (int) $batch; } /** * Returns the version number of the first migration for a batch. * Mostly just for tests. */ public function getBatchStart(int $batch): string { if ($batch < 0) { $batches = $this->getBatches(); $batch = $batches[count($batches) - 1] ?? 0; } $migration = $this->db->table($this->table) ->where('batch', $batch) ->orderBy('id', 'asc') ->limit(1) ->get() ->getResultObject(); return $migration !== [] ? $migration[0]->version : '0'; } /** * Returns the version number of the last migration for a batch. * Mostly just for tests. */ public function getBatchEnd(int $batch): string { if ($batch < 0) { $batches = $this->getBatches(); $batch = $batches[count($batches) - 1] ?? 0; } $migration = $this->db->table($this->table) ->where('batch', $batch) ->orderBy('id', 'desc') ->limit(1) ->get() ->getResultObject(); return $migration === [] ? '0' : $migration[0]->version; } /** * Ensures that we have created our migrations table * in the database. * * @return void */ public function ensureTable() { if ($this->tableChecked || $this->db->tableExists($this->table)) { return; } $forge = Database::forge($this->db); $forge->addField([ 'id' => [ 'type' => 'BIGINT', 'constraint' => 20, 'unsigned' => true, 'auto_increment' => true, ], 'version' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => false, ], 'class' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => false, ], 'group' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => false, ], 'namespace' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => false, ], 'time' => [ 'type' => 'INT', 'constraint' => 11, 'null' => false, ], 'batch' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => false, ], ]); $forge->addPrimaryKey('id'); $forge->createTable($this->table, true); $this->tableChecked = true; } /** * Handles the actual running of a migration. * * @param string $direction "up" or "down" * @param object $migration The migration to run */ protected function migrate($direction, $migration): bool { include_once $migration->path; $class = $migration->class; $this->setName($migration->name); // Validate the migration file structure if (! class_exists($class, false)) { $message = sprintf(lang('Migrations.classNotFound'), $class); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } /** @var Migration $instance */ $instance = new $class(Database::forge($this->db)); $group = $instance->getDBGroup() ?? $this->group; if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') { // @codeCoverageIgnoreStart $this->groupSkip = true; return true; // @codeCoverageIgnoreEnd } if ($direction === 'up' && $this->groupFilter !== null && $this->groupFilter !== $group) { $this->groupSkip = true; return true; } if (! is_callable([$instance, $direction])) { $message = sprintf(lang('Migrations.missingMethod'), $direction); if ($this->silent) { $this->cliMessages[] = "\t" . CLI::color($message, 'red'); return false; } throw new RuntimeException($message); } $instance->{$direction}(); return true; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/RawSql.php
system/Database/RawSql.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; use Stringable; /** * @see \CodeIgniter\Database\RawSqlTest */ class RawSql implements Stringable { /** * @var string Raw SQL string */ private string $string; public function __construct(string $sqlString) { $this->string = $sqlString; } public function __toString(): string { return $this->string; } /** * Create new instance with new SQL string */ public function with(string $newSqlString): self { $new = clone $this; $new->string = $newSqlString; return $new; } /** * Returns unique id for binding key */ public function getBindingKey(): string { return 'RawSql' . spl_object_id($this); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/Migration.php
system/Database/Migration.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; use Config\Database; /** * Class Migration */ abstract class Migration { /** * The name of the database group to use. * * @var string|null */ protected $DBGroup; /** * Database Connection instance * * @var ConnectionInterface */ protected $db; /** * Database Forge instance. * * @var Forge */ protected $forge; public function __construct(?Forge $forge = null) { if (isset($this->DBGroup)) { $this->forge = Database::forge($this->DBGroup); } elseif ($forge instanceof Forge) { $this->forge = $forge; } else { $this->forge = Database::forge(config(Database::class)->defaultGroup); } $this->db = $this->forge->getConnection(); } /** * Returns the database group name this migration uses. */ public function getDBGroup(): ?string { return $this->DBGroup; } /** * Perform a migration step. * * @return void */ abstract public function up(); /** * Revert a migration step. * * @return void */ abstract public function down(); }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/system/Database/ResultInterface.php
system/Database/ResultInterface.php
<?php declare(strict_types=1); /** * This file is part of CodeIgniter 4 framework. * * (c) CodeIgniter Foundation <admin@codeigniter.com> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ namespace CodeIgniter\Database; use stdClass; /** * @template TConnection * @template TResult */ interface ResultInterface { /** * Retrieve the results of the query. Typically an array of * individual data rows, which can be either an 'array', an * 'object', or a custom class name. * * @param string $type The row type. Either 'array', 'object', or a class name to use */ public function getResult(string $type = 'object'): array; /** * Returns the results as an array of custom objects. * * @param string $className The name of the class to use. * * @return array */ public function getCustomResultObject(string $className); /** * Returns the results as an array of arrays. * * If no results, an empty array is returned. */ public function getResultArray(): array; /** * Returns the results as an array of objects. * * If no results, an empty array is returned. */ public function getResultObject(): array; /** * Wrapper object to return a row as either an array, an object, or * a custom class. * * If the row doesn't exist, returns null. * * @template T of object * * @param int|string $n The index of the results to return, or column name. * @param 'array'|'object'|class-string<T> $type The type of result object. 'array', 'object' or class name. * * @return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))) */ public function getRow($n = 0, string $type = 'object'); /** * Returns a row as a custom class instance. * * If the row doesn't exist, returns null. * * @template T of object * * @param int $n The index of the results to return. * @param class-string<T> $className * * @return T|null */ public function getCustomRowObject(int $n, string $className); /** * Returns a single row from the results as an array. * * If row doesn't exist, returns null. * * @return array|null */ public function getRowArray(int $n = 0); /** * Returns a single row from the results as an object. * * If row doesn't exist, returns null. * * @return object|stdClass|null */ public function getRowObject(int $n = 0); /** * Assigns an item into a particular column slot. * * @param array|string $key * @param array|object|stdClass|null $value * * @return void */ public function setRow($key, $value = null); /** * Returns the "first" row of the current results. * * @return array|object|null */ public function getFirstRow(string $type = 'object'); /** * Returns the "last" row of the current results. * * @return array|object|null */ public function getLastRow(string $type = 'object'); /** * Returns the "next" row of the current results. * * @return array|object|null */ public function getNextRow(string $type = 'object'); /** * Returns the "previous" row of the current results. * * @return array|object|null */ public function getPreviousRow(string $type = 'object'); /** * Returns number of rows in the result set. */ public function getNumRows(): int; /** * Returns an unbuffered row and move the pointer to the next row. * * @return array|object|null */ public function getUnbufferedRow(string $type = 'object'); /** * Gets the number of fields in the result set. */ public function getFieldCount(): int; /** * Generates an array of column names in the result set. */ public function getFieldNames(): array; /** * Generates an array of objects representing field meta-data. */ public function getFieldData(): array; /** * Frees the current result. * * @return void */ public function freeResult(); /** * Moves the internal pointer to the desired offset. This is called * internally before fetching results to make sure the result set * starts at zero. * * @return bool */ public function dataSeek(int $n = 0); }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false