Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Caster/ResourceCaster.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); | |
44 if (isset($a['uri'])) { | |
45 $a['uri'] = new LinkStub($a['uri']); | |
46 } | |
47 | |
48 return $a; | |
49 } | |
50 | |
51 public static function castStreamContext($stream, array $a, Stub $stub, $isNested) | |
52 { | |
53 return @stream_context_get_params($stream) ?: $a; | |
54 } | |
55 | |
56 public static function castGd($gd, array $a, Stub $stub, $isNested) | |
57 { | |
58 $a['size'] = imagesx($gd).'x'.imagesy($gd); | |
59 $a['trueColor'] = imageistruecolor($gd); | |
60 | |
61 return $a; | |
62 } | |
63 | |
64 public static function castMysqlLink($h, array $a, Stub $stub, $isNested) | |
65 { | |
66 $a['host'] = mysql_get_host_info($h); | |
67 $a['protocol'] = mysql_get_proto_info($h); | |
68 $a['server'] = mysql_get_server_info($h); | |
69 | |
70 return $a; | |
71 } | |
72 } |