4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\VarDumper\Caster;
14 use Symfony\Component\VarDumper\Cloner\Stub;
17 * Casts common resource types to array representation.
19 * @author Nicolas Grekas <p@tchwork.com>
23 public static function castCurl($h, array $a, Stub $stub, $isNested)
25 return curl_getinfo($h);
28 public static function castDba($dba, array $a, Stub $stub, $isNested)
31 $a['file'] = $list[(int) $dba];
36 public static function castProcess($process, array $a, Stub $stub, $isNested)
38 return proc_get_status($process);
41 public static function castStream($stream, array $a, Stub $stub, $isNested)
43 $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested);
44 if (isset($a['uri'])) {
45 $a['uri'] = new LinkStub($a['uri']);
51 public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
53 return @stream_context_get_params($stream) ?: $a;
56 public static function castGd($gd, array $a, Stub $stub, $isNested)
58 $a['size'] = imagesx($gd).'x'.imagesy($gd);
59 $a['trueColor'] = imageistruecolor($gd);
64 public static function castMysqlLink($h, array $a, Stub $stub, $isNested)
66 $a['host'] = mysql_get_host_info($h);
67 $a['protocol'] = mysql_get_proto_info($h);
68 $a['server'] = mysql_get_server_info($h);