Version 1
[yaffs-website] / vendor / symfony / var-dumper / Caster / ResourceCaster.php
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 common resource types to array representation.
18  *
19  * @author Nicolas Grekas <p@tchwork.com>
20  */
21 class ResourceCaster
22 {
23     public static function castCurl($h, array $a, Stub $stub, $isNested)
24     {
25         return curl_getinfo($h);
26     }
27
28     public static function castDba($dba, array $a, Stub $stub, $isNested)
29     {
30         $list = dba_list();
31         $a['file'] = $list[(int) $dba];
32
33         return $a;
34     }
35
36     public static function castProcess($process, array $a, Stub $stub, $isNested)
37     {
38         return proc_get_status($process);
39     }
40
41     public static function castStream($stream, array $a, Stub $stub, $isNested)
42     {
43         return stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested);
44     }
45
46     public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
47     {
48         return stream_context_get_params($stream);
49     }
50
51     public static function castGd($gd, array $a, Stub $stub, $isNested)
52     {
53         $a['size'] = imagesx($gd).'x'.imagesy($gd);
54         $a['trueColor'] = imageistruecolor($gd);
55
56         return $a;
57     }
58
59     public static function castMysqlLink($h, array $a, Stub $stub, $isNested)
60     {
61         $a['host'] = mysql_get_host_info($h);
62         $a['protocol'] = mysql_get_proto_info($h);
63         $a['server'] = mysql_get_server_info($h);
64
65         return $a;
66     }
67 }