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

Appearance settings

Commit 1008e6c

Browse filesBrowse files
[VarDumper] add caster for MongoCursor objects
1 parent 1a4d7d7 commit 1008e6c
Copy full SHA for 1008e6c

File tree

Expand file treeCollapse file tree

2 files changed

+38
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+38
-0
lines changed
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 Symfony\Component\VarDumper\Cloner\Stub;
15+
16+
/**
17+
* Casts classes from the MongoDb extension to array representation.
18+
*
19+
* @author Nicolas Grekas <p@tchwork.com>
20+
*/
21+
class MongoCaster
22+
{
23+
public static function castCursor(\MongoCursorInterface $cursor, array $a, Stub $stub, $isNested)
24+
{
25+
$prefix = "\0~\0";
26+
27+
if ($info = $cursor->info()) {
28+
foreach ($info as $k => $v) {
29+
$a[$prefix.$k] = $v;
30+
}
31+
}
32+
$a[$prefix.'dead'] = $cursor->dead();
33+
34+
return $a;
35+
}
36+
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ abstract class AbstractCloner implements ClonerInterface
7676
'SplObjectStorage' => 'Symfony\Component\VarDumper\Caster\SplCaster::castObjectStorage',
7777
'SplPriorityQueue' => 'Symfony\Component\VarDumper\Caster\SplCaster::castHeap',
7878

79+
'MongoCursorInterface' => 'Symfony\Component\VarDumper\Caster\MongoCaster::castCursor',
80+
7981
':curl' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castCurl',
8082
':dba' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',
8183
':dba persistent' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.