[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/var-dumper/Caster/ -> DsCaster.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <[email protected]>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\VarDumper\Caster;
  13  
  14  use Ds\Collection;
  15  use Ds\Map;
  16  use Ds\Pair;
  17  use Symfony\Component\VarDumper\Cloner\Stub;
  18  
  19  /**
  20   * Casts Ds extension classes to array representation.
  21   *
  22   * @author Jáchym Toušek <[email protected]>
  23   *
  24   * @final
  25   */
  26  class DsCaster
  27  {
  28      public static function castCollection(Collection $c, array $a, Stub $stub, bool $isNested): array
  29      {
  30          $a[Caster::PREFIX_VIRTUAL.'count'] = $c->count();
  31          $a[Caster::PREFIX_VIRTUAL.'capacity'] = $c->capacity();
  32  
  33          if (!$c instanceof Map) {
  34              $a += $c->toArray();
  35          }
  36  
  37          return $a;
  38      }
  39  
  40      public static function castMap(Map $c, array $a, Stub $stub, bool $isNested): array
  41      {
  42          foreach ($c as $k => $v) {
  43              $a[] = new DsPairStub($k, $v);
  44          }
  45  
  46          return $a;
  47      }
  48  
  49      public static function castPair(Pair $c, array $a, Stub $stub, bool $isNested): array
  50      {
  51          foreach ($c->toArray() as $k => $v) {
  52              $a[Caster::PREFIX_VIRTUAL.$k] = $v;
  53          }
  54  
  55          return $a;
  56      }
  57  
  58      public static function castPairStub(DsPairStub $c, array $a, Stub $stub, bool $isNested): array
  59      {
  60          if ($isNested) {
  61              $stub->class = Pair::class;
  62              $stub->value = null;
  63              $stub->handle = 0;
  64  
  65              $a = $c->value;
  66          }
  67  
  68          return $a;
  69      }
  70  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer