Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfec0475

Browse files
feature#30311 [VarDumper] Implement DsCaster (enumag)
This PR was merged into the 4.3-dev branch.Discussion----------[VarDumper] Implement DsCaster| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets || License | MIT| Doc PR |When dumping the data structures from [Ds extension](http://php.net/manual/en/book.ds.php) Symfony only shows the class name but not the actual data. So in this PR I tried to write a Caster for these data structures.Map can't be simply casted to array because it can contain objects as keys so I dump the pairs instead.Commits-------eab631f [VarDumper] Implement DsCaster
2 parentsf7f31b2 +eab631f commitfec0475

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

‎src/Symfony/Component/VarDumper/CHANGELOG.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
7+
* added`DsCaster` to support dumping the contents of data structures from the Ds extension
8+
49
4.2.0
510
-----
611

@@ -34,4 +39,4 @@ CHANGELOG
3439
2.7.0
3540
-----
3641

37-
* deprecated Cloner\Data::getLimitedClone(). Use withMaxDepth,withMaxItemsPerDepth or withRefHandles instead.
42+
* deprecated`Cloner\Data::getLimitedClone()`. Use`withMaxDepth`,`withMaxItemsPerDepth` or`withRefHandles` instead.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
12+
namespaceSymfony\Component\VarDumper\Caster;
13+
14+
useDs\Deque;
15+
useDs\Map;
16+
useDs\PriorityQueue;
17+
useDs\Queue;
18+
useDs\Set;
19+
useDs\Stack;
20+
useDs\Vector;
21+
useSymfony\Component\VarDumper\Cloner\Stub;
22+
23+
/**
24+
* Casts Ds extension classes to array representation.
25+
*
26+
* @author Jáchym Toušek <enumag@gmail.com>
27+
*/
28+
class DsCaster
29+
{
30+
/**
31+
* @param Set|Deque|Vector|Stack|Queue|PriorityQueue $c
32+
*/
33+
publicstaticfunctioncastDs($c,array$a,Stub$stub,bool$isNested):array
34+
{
35+
$prefix = Caster::PREFIX_VIRTUAL;
36+
$a =$c->toArray();
37+
$a[$prefix.'capacity'] =$c->capacity();
38+
39+
return$a;
40+
}
41+
42+
publicstaticfunctioncastMap(Map$c,array$a,Stub$stub,bool$isNested):array
43+
{
44+
$prefix = Caster::PREFIX_VIRTUAL;
45+
$a =$c->pairs()->toArray();
46+
$a[$prefix.'capacity'] =$c->capacity();
47+
48+
return$a;
49+
}
50+
}

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ abstract class AbstractCloner implements ClonerInterface
125125

126126
'Memcached' => ['Symfony\Component\VarDumper\Caster\MemcachedCaster','castMemcached'],
127127

128+
'Ds\Set' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
129+
'Ds\Vector' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
130+
'Ds\Deque' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
131+
'Ds\Stack' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
132+
'Ds\Queue' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
133+
'Ds\PriorityQueue' => ['Symfony\Component\VarDumper\Caster\DsCaster','castDs'],
134+
'Ds\Map' => ['Symfony\Component\VarDumper\Caster\DsCaster','castMap'],
135+
128136
':curl' => ['Symfony\Component\VarDumper\Caster\ResourceCaster','castCurl'],
129137
':dba' => ['Symfony\Component\VarDumper\Caster\ResourceCaster','castDba'],
130138
':dba persistent' => ['Symfony\Component\VarDumper\Caster\ResourceCaster','castDba'],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp