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 ad49c8a

Browse filesBrowse files
[VarDumper] Fix dumping mysqli_driver instances
1 parent 7bc53c6 commit ad49c8a
Copy full SHA for ad49c8a

File tree

3 files changed

+75
-0
lines changed
Filter options

3 files changed

+75
-0
lines changed
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
* @author Nicolas Grekas <p@tchwork.com>
18+
*
19+
* @internal
20+
*/
21+
final class MysqliCaster
22+
{
23+
public static function castMysqliDriver(\mysqli_driver $c, array $a, Stub $stub, bool $isNested): array
24+
{
25+
foreach ($a as $k => $v) {
26+
if (isset($c->$k)) {
27+
$a[$k] = $c->$k;
28+
}
29+
}
30+
31+
return $a;
32+
}
33+
}

‎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
@@ -144,6 +144,8 @@ abstract class AbstractCloner implements ClonerInterface
144144
'Ds\Pair' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPair'],
145145
'Symfony\Component\VarDumper\Caster\DsPairStub' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPairStub'],
146146

147+
'mysqli_driver' => ['Symfony\Component\VarDumper\Caster\MysqliCaster', 'castMysqliDriver'],
148+
147149
'CurlHandle' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'],
148150
':curl' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'],
149151

+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\Tests\Caster;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
16+
17+
/**
18+
* @author Nicolas Grekas <p@tchwork.com>
19+
* @requires extension mysqli
20+
* @group integration
21+
*/
22+
class MysqliCasterTest extends TestCase
23+
{
24+
use VarDumperTestTrait;
25+
26+
public function testNotConnected()
27+
{
28+
$driver = new \mysqli_driver();
29+
$driver->report_mode = 3;
30+
31+
$xCast = <<<EODUMP
32+
mysqli_driver {%A
33+
+reconnect: false
34+
+report_mode: 3
35+
}
36+
EODUMP;
37+
38+
$this->assertDumpMatchesFormat($xCast, $driver);
39+
}
40+
}

0 commit comments

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