File tree 3 files changed +64
-1
lines changed
Filter options
src/Symfony/Component/VarDumper
3 files changed +64
-1
lines changed
Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
4
+ 4.3.0
5
+ -----
6
+
7
+ * added ` DsCaster ` to support dumping of data structures from the Ds extension
8
+
4
9
4.2.0
5
10
-----
6
11
@@ -34,4 +39,4 @@ CHANGELOG
34
39
2.7.0
35
40
-----
36
41
37
- * deprecated Cloner\Data::getLimitedClone(). Use withMaxDepth, withMaxItemsPerDepth or withRefHandles instead.
42
+ * deprecated ` Cloner\Data::getLimitedClone() ` . Use ` withMaxDepth ` , ` withMaxItemsPerDepth ` or ` withRefHandles ` instead.
Original file line number Diff line number Diff line change
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
+ namespace Symfony \Component \VarDumper \Caster ;
13
+
14
+ use Ds \Deque ;
15
+ use Ds \Map ;
16
+ use Ds \PriorityQueue ;
17
+ use Ds \Queue ;
18
+ use Ds \Set ;
19
+ use Ds \Stack ;
20
+ use Ds \Vector ;
21
+ use Symfony \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
+ public static function castDs ($ c , array $ a , Stub $ stub , $ 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
+ public static function castMap (Map $ c , array $ a , Stub $ stub , $ 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
+ }
Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ abstract class AbstractCloner implements ClonerInterface
125
125
126
126
'Memcached ' => ['Symfony\Component\VarDumper\Caster\MemcachedCaster ' , 'castMemcached ' ],
127
127
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
+
128
136
':curl ' => ['Symfony\Component\VarDumper\Caster\ResourceCaster ' , 'castCurl ' ],
129
137
':dba ' => ['Symfony\Component\VarDumper\Caster\ResourceCaster ' , 'castDba ' ],
130
138
':dba persistent ' => ['Symfony\Component\VarDumper\Caster\ResourceCaster ' , 'castDba ' ],
You can’t perform that action at this time.
0 commit comments