PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / vendor / symfony / var-dumper / Caster / AmqpCaster.php
kubio / vendor / symfony / var-dumper / Caster Last commit date
AmqpCaster.php 1 year ago ArgsStub.php 1 year ago Caster.php 1 year ago ClassStub.php 1 year ago ConstStub.php 4 years ago CutArrayStub.php 4 years ago CutStub.php 4 years ago DOMCaster.php 1 year ago DateCaster.php 1 year ago DoctrineCaster.php 1 year ago DsCaster.php 1 year ago DsPairStub.php 4 years ago EnumStub.php 4 years ago ExceptionCaster.php 1 year ago FiberCaster.php 1 year ago FrameStub.php 4 years ago GmpCaster.php 1 year ago ImagineCaster.php 4 years ago ImgStub.php 1 year ago IntlCaster.php 1 year ago LinkStub.php 1 year ago MemcachedCaster.php 1 year ago MysqliCaster.php 1 year ago PdoCaster.php 1 year ago PgSqlCaster.php 1 year ago ProxyManagerCaster.php 1 year ago RdKafkaCaster.php 1 year ago RedisCaster.php 1 year ago ReflectionCaster.php 1 year ago ResourceCaster.php 1 year ago SplCaster.php 1 year ago StubCaster.php 1 year ago SymfonyCaster.php 1 year ago TraceStub.php 1 year ago UuidCaster.php 4 years ago XmlReaderCaster.php 1 year ago XmlResourceCaster.php 1 year ago
AmqpCaster.php
213 lines
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 Amqp related classes to array representation.
18 *
19 * @author Grégoire Pineau <lyrixx@lyrixx.info>
20 *
21 * @final
22 */
23 class AmqpCaster
24 {
25 private const FLAGS = [
26 \AMQP_DURABLE => 'AMQP_DURABLE',
27 \AMQP_PASSIVE => 'AMQP_PASSIVE',
28 \AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE',
29 \AMQP_AUTODELETE => 'AMQP_AUTODELETE',
30 \AMQP_INTERNAL => 'AMQP_INTERNAL',
31 \AMQP_NOLOCAL => 'AMQP_NOLOCAL',
32 \AMQP_AUTOACK => 'AMQP_AUTOACK',
33 \AMQP_IFEMPTY => 'AMQP_IFEMPTY',
34 \AMQP_IFUNUSED => 'AMQP_IFUNUSED',
35 \AMQP_MANDATORY => 'AMQP_MANDATORY',
36 \AMQP_IMMEDIATE => 'AMQP_IMMEDIATE',
37 \AMQP_MULTIPLE => 'AMQP_MULTIPLE',
38 \AMQP_NOWAIT => 'AMQP_NOWAIT',
39 \AMQP_REQUEUE => 'AMQP_REQUEUE',
40 ];
41
42 private const EXCHANGE_TYPES = [
43 \AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT',
44 \AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT',
45 \AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC',
46 \AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS',
47 ];
48
49 public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested)
50 {
51 $prefix = Caster::PREFIX_VIRTUAL;
52
53 $a += [
54 $prefix.'is_connected' => $c->isConnected(),
55 ];
56
57 // Recent version of the extension already expose private properties
58 if (isset($a["\x00AMQPConnection\x00login"])) {
59 return $a;
60 }
61
62 // BC layer in the amqp lib
63 if (method_exists($c, 'getReadTimeout')) {
64 $timeout = $c->getReadTimeout();
65 } else {
66 $timeout = $c->getTimeout();
67 }
68
69 $a += [
70 $prefix.'is_connected' => $c->isConnected(),
71 $prefix.'login' => $c->getLogin(),
72 $prefix.'password' => $c->getPassword(),
73 $prefix.'host' => $c->getHost(),
74 $prefix.'vhost' => $c->getVhost(),
75 $prefix.'port' => $c->getPort(),
76 $prefix.'read_timeout' => $timeout,
77 ];
78
79 return $a;
80 }
81
82 public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested)
83 {
84 $prefix = Caster::PREFIX_VIRTUAL;
85
86 $a += [
87 $prefix.'is_connected' => $c->isConnected(),
88 $prefix.'channel_id' => $c->getChannelId(),
89 ];
90
91 // Recent version of the extension already expose private properties
92 if (isset($a["\x00AMQPChannel\x00connection"])) {
93 return $a;
94 }
95
96 $a += [
97 $prefix.'connection' => $c->getConnection(),
98 $prefix.'prefetch_size' => $c->getPrefetchSize(),
99 $prefix.'prefetch_count' => $c->getPrefetchCount(),
100 ];
101
102 return $a;
103 }
104
105 public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
106 {
107 $prefix = Caster::PREFIX_VIRTUAL;
108
109 $a += [
110 $prefix.'flags' => self::extractFlags($c->getFlags()),
111 ];
112
113 // Recent version of the extension already expose private properties
114 if (isset($a["\x00AMQPQueue\x00name"])) {
115 return $a;
116 }
117
118 $a += [
119 $prefix.'connection' => $c->getConnection(),
120 $prefix.'channel' => $c->getChannel(),
121 $prefix.'name' => $c->getName(),
122 $prefix.'arguments' => $c->getArguments(),
123 ];
124
125 return $a;
126 }
127
128 public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested)
129 {
130 $prefix = Caster::PREFIX_VIRTUAL;
131
132 $a += [
133 $prefix.'flags' => self::extractFlags($c->getFlags()),
134 ];
135
136 $type = isset(self::EXCHANGE_TYPES[$c->getType()]) ? new ConstStub(self::EXCHANGE_TYPES[$c->getType()], $c->getType()) : $c->getType();
137
138 // Recent version of the extension already expose private properties
139 if (isset($a["\x00AMQPExchange\x00name"])) {
140 $a["\x00AMQPExchange\x00type"] = $type;
141
142 return $a;
143 }
144
145 $a += [
146 $prefix.'connection' => $c->getConnection(),
147 $prefix.'channel' => $c->getChannel(),
148 $prefix.'name' => $c->getName(),
149 $prefix.'type' => $type,
150 $prefix.'arguments' => $c->getArguments(),
151 ];
152
153 return $a;
154 }
155
156 public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
157 {
158 $prefix = Caster::PREFIX_VIRTUAL;
159
160 $deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode());
161
162 // Recent version of the extension already expose private properties
163 if (isset($a["\x00AMQPEnvelope\x00body"])) {
164 $a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode;
165
166 return $a;
167 }
168
169 if (!($filter & Caster::EXCLUDE_VERBOSE)) {
170 $a += [$prefix.'body' => $c->getBody()];
171 }
172
173 $a += [
174 $prefix.'delivery_tag' => $c->getDeliveryTag(),
175 $prefix.'is_redelivery' => $c->isRedelivery(),
176 $prefix.'exchange_name' => $c->getExchangeName(),
177 $prefix.'routing_key' => $c->getRoutingKey(),
178 $prefix.'content_type' => $c->getContentType(),
179 $prefix.'content_encoding' => $c->getContentEncoding(),
180 $prefix.'headers' => $c->getHeaders(),
181 $prefix.'delivery_mode' => $deliveryMode,
182 $prefix.'priority' => $c->getPriority(),
183 $prefix.'correlation_id' => $c->getCorrelationId(),
184 $prefix.'reply_to' => $c->getReplyTo(),
185 $prefix.'expiration' => $c->getExpiration(),
186 $prefix.'message_id' => $c->getMessageId(),
187 $prefix.'timestamp' => $c->getTimeStamp(),
188 $prefix.'type' => $c->getType(),
189 $prefix.'user_id' => $c->getUserId(),
190 $prefix.'app_id' => $c->getAppId(),
191 ];
192
193 return $a;
194 }
195
196 private static function extractFlags(int $flags): ConstStub
197 {
198 $flagsArray = [];
199
200 foreach (self::FLAGS as $value => $name) {
201 if ($flags & $value) {
202 $flagsArray[] = $name;
203 }
204 }
205
206 if (!$flagsArray) {
207 $flagsArray = ['AMQP_NOPARAM'];
208 }
209
210 return new ConstStub(implode('|', $flagsArray), $flags);
211 }
212 }
213