vite config : ignore /local and /public/** to improve perf

This commit is contained in:
isUnknown 2025-10-02 09:53:59 +02:00
parent 3c9eed7804
commit c11a85e7f8
32 changed files with 1235 additions and 858 deletions

View file

@ -2,46 +2,27 @@
namespace Kirby\Kql;
use Kirby\Toolkit\A;
use ReflectionClass;
use ReflectionMethod;
/**
* Providing help information about
* queried objects, methods, arrays...
*
* @package Kirby KQL
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
class Help
{
/**
* Provides information about passed value
* depending on its type
*/
public static function for($value): array
public static function for($object)
{
if (is_array($value) === true) {
return static::forArray($value);
if (is_array($object) === true) {
return static::forArray($object);
}
if (is_object($value) === true) {
return static::forObject($value);
if (is_object($object) === true) {
return static::forObject($object);
}
return [
'type' => gettype($value),
'value' => $value
'type' => gettype($object),
'value' => $object
];
}
/**
* @internal
*/
public static function forArray(array $array): array
public static function forArray(array $array)
{
return [
'type' => 'array',
@ -49,42 +30,42 @@ class Help
];
}
/**
* Gathers information for method about
* name, parameters, return type etc.
* @internal
*/
public static function forMethod(object $object, string $method): array
public static function forMethod($object, $method)
{
$reflection = new ReflectionMethod($object, $method);
$returns = $reflection->getReturnType()?->getName();
$returns = null;
$params = [];
if ($returnType = $reflection->getReturnType()) {
$returns = $returnType->getName();
}
foreach ($reflection->getParameters() as $param) {
$name = $param->getName();
$required = $param->isOptional() === false;
$type = $param->hasType() ? $param->getType()->getName() : null;
$default = null;
$p = [
'name' => $param->getName(),
'required' => $param->isOptional() === false,
'type' => $param->hasType() ? $param->getType()->getName() : null,
];
if ($param->isDefaultValueAvailable()) {
$default = $param->getDefaultValue();
$p['default'] = $param->getDefaultValue();
}
$call = '';
$call = null;
if ($type !== null) {
$call = $type . ' ';
if ($p['type'] !== null) {
$call = $p['type'] . ' ';
}
$call .= '$' . $name;
$call .= '$' . $p['name'];
if ($required === false && $default !== null) {
$call .= ' = ' . var_export($default, true);
if ($p['required'] === false && isset($p['default']) === true) {
$call .= ' = ' . var_export($p['default'], true);
}
$p['call'] = $call;
$params[$name] = compact('name', 'type', 'required', 'default', 'call');
$params[$p['name']] = $p;
}
$call = '.' . $method;
@ -101,11 +82,7 @@ class Help
];
}
/**
* Gathers informations for each unique method
* @internal
*/
public static function forMethods(object $object, array $methods): array
public static function forMethods($object, $methods)
{
$methods = array_unique($methods);
$reflection = [];
@ -123,30 +100,11 @@ class Help
return $reflection;
}
/**
* Retrieves info for objects either from Interceptor (to
* only list allowed methods) or via reflection
* @internal
*/
public static function forObject(object $object): array
public static function forObject($object)
{
// get interceptor object to only return info on allowed methods
$interceptor = Interceptor::replace($object);
$original = $object;
$object = Interceptor::replace($original);
if ($interceptor instanceof Interceptor) {
return $interceptor->__debugInfo();
}
// for original classes, use reflection
$class = new ReflectionClass($object);
$methods = A::map(
$class->getMethods(),
fn ($method) => static::forMethod($object, $method->getName())
);
return [
'type' => $class->getName(),
'methods' => $methods
];
return $object->__debugInfo();
}
}