Skip to content

Commit 59f0cff

Browse files
committed
renamed proto -> protocol
1 parent 2adbded commit 59f0cff

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

PhpAmqpLib/Channel/AbstractChannel.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
class AbstractChannel
1919
{
20-
const PROTO_080 = '0.8';
21-
const PROTO_091 = '0.9.1';
20+
const PROTOCOL_080 = '0.8';
21+
const PROTOCOL_091 = '0.9.1';
2222

2323
public static $PROTOCOL_CONSTANTS_CLASS;
2424

@@ -85,15 +85,15 @@ public function __construct(AbstractConnection $connection, $channel_id)
8585

8686
$this->protocolVersion = self::getProtocolVersion();
8787
switch ($this->protocolVersion) {
88-
case self::PROTO_091:
88+
case self::PROTOCOL_091:
8989
self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\Wire\Constants091';
9090
$c = self::$PROTOCOL_CONSTANTS_CLASS;
9191
$this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
9292
$this->protocolWriter = new Protocol091();
9393
$this->waitHelper = new Wait091();
9494
$this->methodMap = new MethodMap091();
9595
break;
96-
case self::PROTO_080:
96+
case self::PROTOCOL_080:
9797
self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\Wire\Constants080';
9898
$c = self::$PROTOCOL_CONSTANTS_CLASS;
9999
$this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
@@ -113,13 +113,13 @@ public function __construct(AbstractConnection $connection, $channel_id)
113113
*/
114114
public static function getProtocolVersion()
115115
{
116-
$proto = defined('AMQP_PROTOCOL') ? AMQP_PROTOCOL : self::PROTO_091;
116+
$protocol = defined('AMQP_PROTOCOL') ? AMQP_PROTOCOL : self::PROTOCOL_091;
117117
//adding check here to catch unknown protocol ASAP, as this method may be called from the outside
118-
if (!in_array($proto, array(self::PROTO_080, self::PROTO_091), TRUE)) {
119-
throw new AMQPOutOfRangeException(sprintf('Protocol version %s not implemented.', $proto));
118+
if (!in_array($protocol, array(self::PROTOCOL_080, self::PROTOCOL_091), TRUE)) {
119+
throw new AMQPOutOfRangeException(sprintf('Protocol version %s not implemented.', $protocol));
120120
}
121121

122-
return $proto;
122+
return $protocol;
123123
}
124124

125125
/**

PhpAmqpLib/Wire/AMQPAbstractCollection.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ abstract class AMQPAbstractCollection implements \Iterator
1212
{
1313

1414
//protocol defines available field types and their corresponding symbols
15-
const PROTO_080 = AbstractChannel::PROTO_080;
16-
const PROTO_091 = AbstractChannel::PROTO_091;
17-
const PROTO_RBT = 'rabbit'; //pseudo proto
15+
const PROTOCOL_080 = AbstractChannel::PROTOCOL_080;
16+
const PROTOCOL_091 = AbstractChannel::PROTOCOL_091;
17+
const PROTOCOL_RBT = 'rabbit'; //pseudo proto
1818

1919
//Abstract data types
2020
const T_INT_SHORTSHORT = 1;
@@ -41,7 +41,7 @@ abstract class AMQPAbstractCollection implements \Iterator
4141
/**
4242
* @var string
4343
*/
44-
private static $_proto = null;
44+
private static $_protocol = null;
4545

4646
/*
4747
* Field types messy mess http://www.rabbitmq.com/amqp-0-9-1-errata.html#section_3
@@ -220,7 +220,7 @@ protected function encodeValue($val)
220220
} elseif (is_array($val)) {
221221
//AMQP specs says "Field names MUST start with a letter, '$' or '#'"
222222
//so beware, some servers may raise an exception with 503 code in cases when indexed array is encoded as table
223-
if (self::isProto(self::PROTO_080)) {
223+
if (self::isProtocol(self::PROTOCOL_080)) {
224224
//080 doesn't support arrays, forcing table
225225
$val = array(self::T_TABLE, new AMQPTable($val));
226226
} elseif (empty($val) || (array_keys($val) === range(0, count($val) - 1))) {
@@ -285,7 +285,7 @@ protected function encodeInt($val)
285285
{
286286
if (($val >= -2147483648) && ($val <= 2147483647)) {
287287
$ev = array(self::T_INT_LONG, $val);
288-
} elseif (self::isProto(self::PROTO_080)) {
288+
} elseif (self::isProtocol(self::PROTOCOL_080)) {
289289
//080 doesn't support longlong
290290
$ev = $this->encodeString((string) $val);
291291
} else {
@@ -312,53 +312,53 @@ protected function encodeBool($val)
312312
{
313313
$val = (bool) $val;
314314

315-
return self::isProto(self::PROTO_080) ? array(self::T_INT_LONG, (int) $val) : array(self::T_BOOL, $val);
315+
return self::isProtocol(self::PROTOCOL_080) ? array(self::T_INT_LONG, (int) $val) : array(self::T_BOOL, $val);
316316
}
317317

318318
/**
319319
* @return array
320320
*/
321321
protected function encodeVoid()
322322
{
323-
return self::isProto(self::PROTO_080) ? $this->encodeString('') : array(self::T_VOID, null);
323+
return self::isProtocol(self::PROTOCOL_080) ? $this->encodeString('') : array(self::T_VOID, null);
324324
}
325325

326326
/**
327327
* @return string
328328
*/
329-
final public static function getProto()
329+
final public static function getProtocol()
330330
{
331-
if (self::$_proto === null) {
332-
self::$_proto = defined('AMQP_STRICT_FLD_TYPES') && AMQP_STRICT_FLD_TYPES ?
331+
if (self::$_protocol === null) {
332+
self::$_protocol = defined('AMQP_STRICT_FLD_TYPES') && AMQP_STRICT_FLD_TYPES ?
333333
AbstractChannel::getProtocolVersion() :
334-
self::PROTO_RBT;
334+
self::PROTOCOL_RBT;
335335
}
336336

337-
return self::$_proto;
337+
return self::$_protocol;
338338
}
339339

340340
/**
341341
* @param string $proto
342342
* @return bool
343343
*/
344-
final public static function isProto($proto)
344+
final public static function isProtocol($proto)
345345
{
346-
return self::getProto() == $proto;
346+
return self::getProtocol() == $proto;
347347
}
348348

349349
/**
350350
* @return array [dataTypeConstant => dataTypeSymbol]
351351
*/
352352
final public static function getSupportedDataTypes()
353353
{
354-
switch ($proto = self::getProto()) {
355-
case self::PROTO_080:
354+
switch ($proto = self::getProtocol()) {
355+
case self::PROTOCOL_080:
356356
$types = self::$_types_080;
357357
break;
358-
case self::PROTO_091:
358+
case self::PROTOCOL_091:
359359
$types = self::$_types_091;
360360
break;
361-
case self::PROTO_RBT:
361+
case self::PROTOCOL_RBT:
362362
$types = self::$_types_rabbit;
363363
break;
364364
default:
@@ -378,7 +378,7 @@ final public static function checkDataTypeIsSupported($type, $return = true)
378378
try {
379379
$supported = self::getSupportedDataTypes();
380380
if (!isset($supported[$type])) {
381-
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t support data of type [%s]', self::getProto(), $type));
381+
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t support data of type [%s]', self::getProtocol(), $type));
382382
}
383383
return true;
384384

@@ -399,7 +399,7 @@ final public static function getSymbolForDataType($type)
399399
{
400400
$types = self::getSupportedDataTypes();
401401
if (!isset($types[$type])) {
402-
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t support data of type [%s]', self::getProto(), $type));
402+
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t support data of type [%s]', self::getProtocol(), $type));
403403
}
404404

405405
return $types[$type];
@@ -413,7 +413,7 @@ final public static function getDataTypeForSymbol($symbol)
413413
{
414414
$symbols = array_flip(self::getSupportedDataTypes());
415415
if (!isset($symbols[$symbol])) {
416-
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t define data of type [%s]', self::getProto(), $symbol));
416+
throw new Exception\AMQPOutOfRangeException(sprintf('AMQP-%s doesn\'t define data of type [%s]', self::getProtocol(), $symbol));
417417
}
418418

419419
return $symbols[$symbol];

tests/Unit/Wire/AMQPCollectionTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AMQPCollectionTest extends \PHPUnit_Framework_TestCase
99

1010
public function testEncode080()
1111
{
12-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_080);
12+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_080);
1313
$a = new Wire\AMQPArray(array(1, (int) -2147483648, (int) 2147483647, -2147483649, 2147483648, true, false, array('foo' => 'bar'), array('foo'), array()));
1414

1515
$this->assertEquals(
@@ -38,7 +38,7 @@ public function testEncode080()
3838

3939
public function testEncode091()
4040
{
41-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
41+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
4242
$a = new Wire\AMQPArray(array(1, (int) -2147483648, (int) 2147483647, -2147483649, 2147483648, true, false, array('foo' => 'bar'), array('foo'), array()));
4343

4444
$is64 = PHP_INT_SIZE == 8;
@@ -68,7 +68,7 @@ public function testEncode091()
6868

6969
public function testEncodeRabbit()
7070
{
71-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_RBT);
71+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_RBT);
7272
$a = new Wire\AMQPArray(array(1, (int) -2147483648, (int) 2147483647, -2147483649, 2147483648, true, false, array('foo' => 'bar'), array('foo'), array()));
7373

7474
$is64 = PHP_INT_SIZE == 8;
@@ -107,7 +107,7 @@ public function testEncodeUnknownDatatype()
107107

108108
public function testPushUnsupportedDataType080()
109109
{
110-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_080);
110+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_080);
111111

112112
$a = new Wire\AMQPArray();
113113
$this->setExpectedException('PhpAmqpLib\\Exception\\AMQPOutOfRangeException');
@@ -119,7 +119,7 @@ public function testPushUnsupportedDataType080()
119119

120120
public function testPushUnsupportedDataType091()
121121
{
122-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
122+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
123123

124124
$a = new Wire\AMQPArray();
125125
$this->setExpectedException('PhpAmqpLib\\Exception\\AMQPOutOfRangeException');
@@ -131,7 +131,7 @@ public function testPushUnsupportedDataType091()
131131

132132
public function testPushUnsupportedDataTypeRabbit()
133133
{
134-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_RBT);
134+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_RBT);
135135

136136
$a = new Wire\AMQPArray();
137137
$this->setExpectedException('PhpAmqpLib\\Exception\\AMQPOutOfRangeException');
@@ -164,7 +164,7 @@ public function testPushWithType()
164164

165165
public function testConflictingFieldSymbols()
166166
{
167-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
167+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
168168

169169
$a = new Wire\AMQPArray();
170170
$a->push(576, Wire\AMQPArray::T_INT_SHORT);
@@ -179,7 +179,7 @@ public function testConflictingFieldSymbols()
179179
);
180180

181181

182-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_RBT);
182+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_RBT);
183183

184184
$a = new Wire\AMQPArray();
185185
$a->push(576, Wire\AMQPArray::T_INT_SHORT);
@@ -261,7 +261,7 @@ public function testPushFloatWithDecimalType()
261261

262262
public function testArrayRoundTrip080()
263263
{
264-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_080);
264+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_080);
265265

266266
$a = new Wire\AMQPArray($this->getTestDataSrc());
267267
$this->assertEquals(array_values($this->getTestDataCmp080()), $a->getNativeData());
@@ -271,7 +271,7 @@ public function testArrayRoundTrip080()
271271

272272
public function testArrayRoundTrip091()
273273
{
274-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
274+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
275275

276276
$a = new Wire\AMQPArray($this->getTestDataSrc());
277277
$this->assertEquals(array_values($this->getTestDataCmp()), $a->getNativeData());
@@ -281,7 +281,7 @@ public function testArrayRoundTrip091()
281281

282282
public function testArrayRoundTripRabbit()
283283
{
284-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_RBT);
284+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_RBT);
285285

286286
$a = new Wire\AMQPArray($this->getTestDataSrc());
287287
$this->assertEquals(array_values($this->getTestDataCmp()), $a->getNativeData());
@@ -291,7 +291,7 @@ public function testArrayRoundTripRabbit()
291291

292292
public function testTableRoundTrip080()
293293
{
294-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_080);
294+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_080);
295295

296296
$a = new Wire\AMQPTable($this->getTestDataSrc());
297297
$this->assertEquals($this->getTestDataCmp080(), $a->getNativeData());
@@ -301,7 +301,7 @@ public function testTableRoundTrip080()
301301

302302
public function testTableRoundTrip091()
303303
{
304-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
304+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
305305

306306
$a = new Wire\AMQPTable($this->getTestDataSrc());
307307
$this->assertEquals($this->getTestDataCmp(), $a->getNativeData());
@@ -311,7 +311,7 @@ public function testTableRoundTrip091()
311311

312312
public function testTableRoundTripRabbit()
313313
{
314-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_RBT);
314+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_RBT);
315315

316316
$a = new Wire\AMQPTable($this->getTestDataSrc());
317317
$this->assertEquals($this->getTestDataCmp(), $a->getNativeData());
@@ -402,7 +402,7 @@ public function testIterator()
402402
'e' => array(Wire\AMQPAbstractCollection::getDataTypeForSymbol('t'), false)
403403
);
404404

405-
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTO_091);
405+
$this->setProtoVersion(Wire\AMQPAbstractCollection::PROTOCOL_091);
406406
$a = new Wire\AMQPTable($d);
407407

408408
foreach ($a as $key => $val) {
@@ -417,7 +417,7 @@ public function testIterator()
417417

418418
protected function setProtoVersion($proto)
419419
{
420-
$r = new \ReflectionProperty('\\PhpAmqpLib\\Wire\\AMQPAbstractCollection', '_proto');
420+
$r = new \ReflectionProperty('\\PhpAmqpLib\\Wire\\AMQPAbstractCollection', '_protocol');
421421
$r->setAccessible(true);
422422
$r->setValue(null, $proto);
423423
}

tests/Unit/Wire/AMQPWriterTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ class AMQPWriterTest extends \PHPUnit_Framework_TestCase
1818

1919
public function setUp()
2020
{
21-
$this->setProtoVersion(AMQPArray::PROTO_091);
21+
$this->setProtoVersion(AMQPArray::PROTOCOL_091);
2222
$this->_writer = new AMQPWriter();
2323
}
2424

2525

2626

2727
public function tearDown()
2828
{
29-
$this->setProtoVersion(AMQPArray::PROTO_RBT);
29+
$this->setProtoVersion(AMQPArray::PROTOCOL_RBT);
3030
$this->_writer = null;
3131
}
3232

3333

3434

3535
protected function setProtoVersion($proto)
3636
{
37-
$r = new \ReflectionProperty('\\PhpAmqpLib\\Wire\\AMQPAbstractCollection', '_proto');
37+
$r = new \ReflectionProperty('\\PhpAmqpLib\\Wire\\AMQPAbstractCollection', '_protocol');
3838
$r->setAccessible(true);
3939
$r->setValue(null, $proto);
4040
}

0 commit comments

Comments
 (0)