Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\VarDumper\Caster;
|
Chris@0
|
13
|
Chris@0
|
14 use Symfony\Component\VarDumper\Cloner\Stub;
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * Casts common resource types to array representation.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @author Nicolas Grekas <p@tchwork.com>
|
Chris@0
|
20 */
|
Chris@0
|
21 class ResourceCaster
|
Chris@0
|
22 {
|
Chris@0
|
23 public static function castCurl($h, array $a, Stub $stub, $isNested)
|
Chris@0
|
24 {
|
Chris@0
|
25 return curl_getinfo($h);
|
Chris@0
|
26 }
|
Chris@0
|
27
|
Chris@0
|
28 public static function castDba($dba, array $a, Stub $stub, $isNested)
|
Chris@0
|
29 {
|
Chris@0
|
30 $list = dba_list();
|
Chris@0
|
31 $a['file'] = $list[(int) $dba];
|
Chris@0
|
32
|
Chris@0
|
33 return $a;
|
Chris@0
|
34 }
|
Chris@0
|
35
|
Chris@0
|
36 public static function castProcess($process, array $a, Stub $stub, $isNested)
|
Chris@0
|
37 {
|
Chris@0
|
38 return proc_get_status($process);
|
Chris@0
|
39 }
|
Chris@0
|
40
|
Chris@0
|
41 public static function castStream($stream, array $a, Stub $stub, $isNested)
|
Chris@0
|
42 {
|
Chris@0
|
43 $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested);
|
Chris@0
|
44 if (isset($a['uri'])) {
|
Chris@0
|
45 $a['uri'] = new LinkStub($a['uri']);
|
Chris@0
|
46 }
|
Chris@0
|
47
|
Chris@0
|
48 return $a;
|
Chris@0
|
49 }
|
Chris@0
|
50
|
Chris@0
|
51 public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
|
Chris@0
|
52 {
|
Chris@0
|
53 return @stream_context_get_params($stream) ?: $a;
|
Chris@0
|
54 }
|
Chris@0
|
55
|
Chris@0
|
56 public static function castGd($gd, array $a, Stub $stub, $isNested)
|
Chris@0
|
57 {
|
Chris@0
|
58 $a['size'] = imagesx($gd).'x'.imagesy($gd);
|
Chris@0
|
59 $a['trueColor'] = imageistruecolor($gd);
|
Chris@0
|
60
|
Chris@0
|
61 return $a;
|
Chris@0
|
62 }
|
Chris@0
|
63
|
Chris@0
|
64 public static function castMysqlLink($h, array $a, Stub $stub, $isNested)
|
Chris@0
|
65 {
|
Chris@0
|
66 $a['host'] = mysql_get_host_info($h);
|
Chris@0
|
67 $a['protocol'] = mysql_get_proto_info($h);
|
Chris@0
|
68 $a['server'] = mysql_get_server_info($h);
|
Chris@0
|
69
|
Chris@0
|
70 return $a;
|
Chris@0
|
71 }
|
Chris@0
|
72 }
|