File tree 2 files changed +43
-0
lines changed
Filter options
src/Symfony/Component/VarDumper
2 files changed +43
-0
lines changed
Original file line number Diff line number Diff line change
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
+ * @author Nicolas Grekas <p@tchwork.com>
18
+ */
19
+ final class SocketCaster
20
+ {
21
+ public static function castSocket (\Socket $ h , array $ a , Stub $ stub , bool $ isNested ): array
22
+ {
23
+ if (\PHP_VERSION_ID >= 80300 && socket_atmark ($ h )) {
24
+ $ a [Caster::PREFIX_VIRTUAL .'atmark ' ] = true ;
25
+ }
26
+
27
+ if (!$ lastError = socket_last_error ($ h )) {
28
+ return $ a ;
29
+ }
30
+
31
+ static $ errors ;
32
+
33
+ if (!$ errors ) {
34
+ $ errors = get_defined_constants (true )['sockets ' ] ?? [];
35
+ $ errors = array_flip (array_filter ($ errors , static fn ($ k ) => str_starts_with ($ k , 'SOCKET_E ' ), \ARRAY_FILTER_USE_KEY ));
36
+ }
37
+
38
+ $ a [Caster::PREFIX_VIRTUAL .'last_error ' ] = new ConstStub ($ errors [$ lastError ], socket_strerror ($ lastError ));
39
+
40
+ return $ a ;
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ abstract class AbstractCloner implements ClonerInterface
25
25
'__PHP_Incomplete_Class ' => ['Symfony\Component\VarDumper\Caster\Caster ' , 'castPhpIncompleteClass ' ],
26
26
27
27
'AddressInfo ' => ['Symfony\Component\VarDumper\Caster\AddressInfoCaster ' , 'castAddressInfo ' ],
28
+ 'Socket ' => ['Symfony\Component\VarDumper\Caster\SocketCaster ' , 'castSocket ' ],
28
29
29
30
'Symfony\Component\VarDumper\Caster\CutStub ' => ['Symfony\Component\VarDumper\Caster\StubCaster ' , 'castStub ' ],
30
31
'Symfony\Component\VarDumper\Caster\CutArrayStub ' => ['Symfony\Component\VarDumper\Caster\StubCaster ' , 'castCutArray ' ],
You can’t perform that action at this time.
0 commit comments