diff --git a/src/Symfony/Component/VarDumper/Caster/MysqliCaster.php b/src/Symfony/Component/VarDumper/Caster/MysqliCaster.php new file mode 100644 index 0000000000000..bfe6f0822d65a --- /dev/null +++ b/src/Symfony/Component/VarDumper/Caster/MysqliCaster.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas
+ *
+ * @internal
+ */
+final class MysqliCaster
+{
+ public static function castMysqliDriver(\mysqli_driver $c, array $a, Stub $stub, bool $isNested): array
+ {
+ foreach ($a as $k => $v) {
+ if (isset($c->$k)) {
+ $a[$k] = $c->$k;
+ }
+ }
+
+ return $a;
+ }
+}
diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
index eeac88295399e..d2e5039b8daf1 100644
--- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
@@ -144,6 +144,8 @@ abstract class AbstractCloner implements ClonerInterface
'Ds\Pair' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPair'],
'Symfony\Component\VarDumper\Caster\DsPairStub' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPairStub'],
+ 'mysqli_driver' => ['Symfony\Component\VarDumper\Caster\MysqliCaster', 'castMysqliDriver'],
+
'CurlHandle' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'],
':curl' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'],
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php
new file mode 100644
index 0000000000000..e05ae41b1b19f
--- /dev/null
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\VarDumper\Tests\Caster;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
+
+/**
+ * @requires extension mysqli
+ * @group integration
+ */
+class MysqliCasterTest extends TestCase
+{
+ use VarDumperTestTrait;
+
+ public function testNotConnected()
+ {
+ $driver = new \mysqli_driver();
+ $driver->report_mode = 3;
+
+ $xCast = <<