AmqpCaster.php
2 years ago
ArgsStub.php
1 year ago
Caster.php
1 year ago
ClassStub.php
1 year ago
ConstStub.php
2 years ago
CutArrayStub.php
2 years ago
CutStub.php
1 year ago
DOMCaster.php
1 year ago
DateCaster.php
2 years ago
DoctrineCaster.php
2 years ago
DsCaster.php
2 years ago
DsPairStub.php
2 years ago
EnumStub.php
1 year ago
ExceptionCaster.php
1 year ago
FiberCaster.php
2 years ago
FrameStub.php
1 year ago
GmpCaster.php
2 years ago
ImagineCaster.php
2 years ago
ImgStub.php
2 years ago
IntlCaster.php
2 years ago
LinkStub.php
1 year ago
MemcachedCaster.php
2 years ago
MysqliCaster.php
2 years ago
PdoCaster.php
2 years ago
PgSqlCaster.php
1 year ago
ProxyManagerCaster.php
2 years ago
RdKafkaCaster.php
1 year ago
RedisCaster.php
2 years ago
ReflectionCaster.php
1 year ago
ResourceCaster.php
1 year ago
SplCaster.php
1 year ago
StubCaster.php
2 years ago
SymfonyCaster.php
2 years ago
TraceStub.php
1 year ago
UuidCaster.php
2 years ago
XmlReaderCaster.php
1 year ago
XmlResourceCaster.php
2 years ago
StubCaster.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace Matomo\Dependencies\Symfony\Component\VarDumper\Caster; |
| 12 | |
| 13 | use Matomo\Dependencies\Symfony\Component\VarDumper\Cloner\Stub; |
| 14 | /** |
| 15 | * Casts a caster's Stub. |
| 16 | * |
| 17 | * @author Nicolas Grekas <p@tchwork.com> |
| 18 | * |
| 19 | * @final |
| 20 | */ |
| 21 | class StubCaster |
| 22 | { |
| 23 | public static function castStub(Stub $c, array $a, Stub $stub, bool $isNested) |
| 24 | { |
| 25 | if ($isNested) { |
| 26 | $stub->type = $c->type; |
| 27 | $stub->class = $c->class; |
| 28 | $stub->value = $c->value; |
| 29 | $stub->handle = $c->handle; |
| 30 | $stub->cut = $c->cut; |
| 31 | $stub->attr = $c->attr; |
| 32 | if (Stub::TYPE_REF === $c->type && !$c->class && \is_string($c->value) && !preg_match('//u', $c->value)) { |
| 33 | $stub->type = Stub::TYPE_STRING; |
| 34 | $stub->class = Stub::STRING_BINARY; |
| 35 | } |
| 36 | $a = []; |
| 37 | } |
| 38 | return $a; |
| 39 | } |
| 40 | public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, bool $isNested) |
| 41 | { |
| 42 | return $isNested ? $c->preservedSubset : $a; |
| 43 | } |
| 44 | public static function cutInternals($obj, array $a, Stub $stub, bool $isNested) |
| 45 | { |
| 46 | if ($isNested) { |
| 47 | $stub->cut += \count($a); |
| 48 | return []; |
| 49 | } |
| 50 | return $a; |
| 51 | } |
| 52 | public static function castEnum(EnumStub $c, array $a, Stub $stub, bool $isNested) |
| 53 | { |
| 54 | if ($isNested) { |
| 55 | $stub->class = $c->dumpKeys ? '' : null; |
| 56 | $stub->handle = 0; |
| 57 | $stub->value = null; |
| 58 | $stub->cut = $c->cut; |
| 59 | $stub->attr = $c->attr; |
| 60 | $a = []; |
| 61 | if ($c->value) { |
| 62 | foreach (array_keys($c->value) as $k) { |
| 63 | $keys[] = !isset($k[0]) || "\x00" !== $k[0] ? Caster::PREFIX_VIRTUAL . $k : $k; |
| 64 | } |
| 65 | // Preserve references with array_combine() |
| 66 | $a = array_combine($keys, $c->value); |
| 67 | } |
| 68 | } |
| 69 | return $a; |
| 70 | } |
| 71 | } |
| 72 |