diff --git a/composer.json b/composer.json index 38e161b..baea689 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "phpstan/phpstan": "^1.10.0", "friendsofphp/php-cs-fixer": "^3.21", "phpat/phpat": "^0.10.14", - "spaze/phpstan-disallowed-calls": "^3.1" + "spaze/phpstan-disallowed-calls": "^3.1", + "symfony/var-dumper": "^7.0" }, "autoload": { "psr-4": { diff --git a/src/functions.php b/src/functions.php index 391248d..4c9084a 100644 --- a/src/functions.php +++ b/src/functions.php @@ -6,8 +6,11 @@ use ReflectionType; use Reflector; + use Stringable; + use Symfony\Component\VarDumper\VarDumper; use Tempest\Container\GenericContainer; use Tempest\Events\EventBus; + use Tempest\Log\Logger; use Tempest\Mapper\ObjectFactory; use Tempest\Support\Reflection\Attributes; use Tempest\Support\Reflection\TypeName; @@ -64,4 +67,28 @@ function type(Reflector|ReflectionType $reflector): string { return (new TypeName())->resolve($reflector); } + + function lw(mixed ...$input): void + { + /** @var Logger $logger */ + $logger = get(Logger::class); + + foreach ($input as $key => $item) { + if ($item instanceof Stringable) { + $message = (string)$item; + } else { + $message = var_export($item, true); + } + + $logger->debug("[{$key}] {$message}"); + } + + VarDumper::dump(...$input); + } + + function ld(mixed ...$input): void + { + lw(...$input); + die(); + } }