PHP 8.3.31
Preview: SymfonyCaster.php Size: 3.51 KB
/home/getspomw/royalsquad.us/vendor/symfony/var-dumper/Caster/SymfonyCaster.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\VarDumper\Caster;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarExporter\Internal\LazyObjectState;

/**
 * @final
 */
class SymfonyCaster
{
    private const REQUEST_GETTERS = [
        'pathInfo' => 'getPathInfo',
        'requestUri' => 'getRequestUri',
        'baseUrl' => 'getBaseUrl',
        'basePath' => 'getBasePath',
        'method' => 'getMethod',
        'format' => 'getRequestFormat',
    ];

    public static function castRequest(Request $request, array $a, Stub $stub, bool $isNested): array
    {
        $clone = null;

        foreach (self::REQUEST_GETTERS as $prop => $getter) {
            $key = Caster::PREFIX_PROTECTED.$prop;
            if (\array_key_exists($key, $a) && null === $a[$key]) {
                $clone ??= clone $request;
                $a[Caster::PREFIX_VIRTUAL.$prop] = $clone->{$getter}();
            }
        }

        return $a;
    }

    public static function castHttpClient($client, array $a, Stub $stub, bool $isNested): array
    {
        $multiKey = \sprintf("\0%s\0multi", $client::class);
        if (isset($a[$multiKey])) {
            $a[$multiKey] = new CutStub($a[$multiKey]);
        }

        return $a;
    }

    public static function castHttpClientResponse($response, array $a, Stub $stub, bool $isNested): array
    {
        $stub->cut += \count($a);
        $a = [];

        foreach ($response->getInfo() as $k => $v) {
            $a[Caster::PREFIX_VIRTUAL.$k] = $v;
        }

        return $a;
    }

    public static function castLazyObjectState($state, array $a, Stub $stub, bool $isNested): array
    {
        if (!$isNested) {
            return $a;
        }

        $stub->cut += \count($a) - 1;

        $instance = $a['realInstance'] ?? null;

        $a = ['status' => new ConstStub(match ($a['status']) {
            LazyObjectState::STATUS_INITIALIZED_FULL => 'INITIALIZED_FULL',
            LazyObjectState::STATUS_INITIALIZED_PARTIAL => 'INITIALIZED_PARTIAL',
            LazyObjectState::STATUS_UNINITIALIZED_FULL => 'UNINITIALIZED_FULL',
            LazyObjectState::STATUS_UNINITIALIZED_PARTIAL => 'UNINITIALIZED_PARTIAL',
        }, $a['status'])];

        if ($instance) {
            $a['realInstance'] = $instance;
            --$stub->cut;
        }

        return $a;
    }

    public static function castUuid(Uuid $uuid, array $a, Stub $stub, bool $isNested): array
    {
        $a[Caster::PREFIX_VIRTUAL.'toBase58'] = $uuid->toBase58();
        $a[Caster::PREFIX_VIRTUAL.'toBase32'] = $uuid->toBase32();

        // symfony/uid >= 5.3
        if (method_exists($uuid, 'getDateTime')) {
            $a[Caster::PREFIX_VIRTUAL.'time'] = $uuid->getDateTime()->format('Y-m-d H:i:s.u \U\T\C');
        }

        return $a;
    }

    public static function castUlid(Ulid $ulid, array $a, Stub $stub, bool $isNested): array
    {
        $a[Caster::PREFIX_VIRTUAL.'toBase58'] = $ulid->toBase58();
        $a[Caster::PREFIX_VIRTUAL.'toRfc4122'] = $ulid->toRfc4122();

        // symfony/uid >= 5.3
        if (method_exists($ulid, 'getDateTime')) {
            $a[Caster::PREFIX_VIRTUAL.'time'] = $ulid->getDateTime()->format('Y-m-d H:i:s.v \U\T\C');
        }

        return $a;
    }
}

Directory Contents

Dirs: 0 × Files: 42

Name Size Perms Modified Actions
6.57 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
2.23 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
6.79 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
3.73 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
740 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
702 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
1.89 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
4.80 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
1.65 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
10.65 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
1.55 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
625 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
596 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
13.40 KB lrw-r--r-- 2026-04-26 10:19:19
Edit Download
16.06 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
5.53 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
1.04 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
659 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
749 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
949 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
637 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
8.76 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
3.29 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
2.24 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
691 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
3.49 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
5.38 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
728 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
4.62 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
5.35 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
14.79 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
2.92 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
554 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
7.83 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
2.33 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
3.51 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
759 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
615 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
668 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
548 B lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
3.31 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download
2.49 KB lrw-rw-rw- 2025-09-17 06:53:24
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).