From c1d61fca25ef7c9f1849454bbc74bd9204251374 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Jan 2011 15:07:17 -0800 Subject: [PATCH 1/3] * Fix: Assignment when testing for equality --- amqp_wire.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amqp_wire.inc b/amqp_wire.inc index bd8dfea..ffc16c9 100644 --- a/amqp_wire.inc +++ b/amqp_wire.inc @@ -217,7 +217,7 @@ class AMQPWriter { $table_data->write('T'); $table_data->write_timestamp($v); - } else if($ftype='F') + } else if($ftype=='F') { $table_data->write('F'); $table_data->write_table($v); From 6cd4f6ae1238e5d0be857437bef92b1a74e3d911 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Jan 2011 15:35:53 -0800 Subject: [PATCH 2/3] Missing $ in variable access Missing $this-> in variable access Duplicate assignment --- amqp_wire.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/amqp_wire.inc b/amqp_wire.inc index ffc16c9..81cd0cc 100644 --- a/amqp_wire.inc +++ b/amqp_wire.inc @@ -38,7 +38,7 @@ class AMQPDecimal public function asBCvalue() { - return bcdiv($n, bcpow(10,$e)); + return bcdiv($this->n, bcpow(10,$this->e)); } } @@ -417,7 +417,7 @@ class AMQPReader $ftype = $table_data->rawread(1); if($ftype == 'S') { $val = $table_data->read_longstr(); - } else if(ftype == 'I') { + } else if($ftype == 'I') { $val = $table_data->read_signed_long(); } else if($ftype == 'D') { @@ -464,11 +464,11 @@ class GenericContent $this->prop_types = $prop_types; else $this->prop_types = GenericContent::$PROPERTIES; + $d = array(); if ($props) $d = array_intersect_key($props, $this->prop_types); - else - $d = array(); + $this->properties = $d; } From 2fcd2aed350580b5e0b55a7c314d982aae7720ec Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Jan 2011 15:48:40 -0800 Subject: [PATCH 3/3] Convert $METHOD_NAME_MAP to a class static --- amqp.inc | 128 +++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 65 deletions(-) diff --git a/amqp.inc b/amqp.inc index 2558f02..e6ee722 100644 --- a/amqp.inc +++ b/amqp.inc @@ -31,10 +31,9 @@ class AMQPException extends Exception $this->amqp_reply_text = $reply_text; $this->amqp_method_sig = $method_sig; - global $METHOD_NAME_MAP; $ms=methodSig($method_sig); - if(array_key_exists($ms, $METHOD_NAME_MAP)) - $mn = $METHOD_NAME_MAP[$ms]; + if(array_key_exists($ms, AMQP::$METHOD_NAME_MAP)) + $mn = AMQP::$METHOD_NAME_MAP[$ms]; else $mn = ""; $this->args = array( @@ -57,61 +56,63 @@ class AMQPChannelException extends AMQPException } -$METHOD_NAME_MAP = array( - "10,10" => "Connection.start", - "10,11" => "Connection.start_ok", - "10,20" => "Connection.secure", - "10,21" => "Connection.secure_ok", - "10,30" => "Connection.tune", - "10,31" => "Connection.tune_ok", - "10,40" => "Connection.open", - "10,41" => "Connection.open_ok", - "10,50" => "Connection.redirect", - "10,60" => "Connection.close", - "10,61" => "Connection.close_ok", - "20,10" => "Channel.open", - "20,11" => "Channel.open_ok", - "20,20" => "Channel.flow", - "20,21" => "Channel.flow_ok", - "20,30" => "Channel.alert", - "20,40" => "Channel.close", - "20,41" => "Channel.close_ok", - "30,10" => "Channel.access_request", - "30,11" => "Channel.access_request_ok", - "40,10" => "Channel.exchange_declare", - "40,11" => "Channel.exchange_declare_ok", - "40,20" => "Channel.exchange_delete", - "40,21" => "Channel.exchange_delete_ok", - "50,10" => "Channel.queue_declare", - "50,11" => "Channel.queue_declare_ok", - "50,20" => "Channel.queue_bind", - "50,21" => "Channel.queue_bind_ok", - "50,30" => "Channel.queue_purge", - "50,31" => "Channel.queue_purge_ok", - "50,40" => "Channel.queue_delete", - "50,41" => "Channel.queue_delete_ok", - "60,10" => "Channel.basic_qos", - "60,11" => "Channel.basic_qos_ok", - "60,20" => "Channel.basic_consume", - "60,21" => "Channel.basic_consume_ok", - "60,30" => "Channel.basic_cancel", - "60,31" => "Channel.basic_cancel_ok", - "60,40" => "Channel.basic_publish", - "60,50" => "Channel.basic_return", - "60,60" => "Channel.basic_deliver", - "60,70" => "Channel.basic_get", - "60,71" => "Channel.basic_get_ok", - "60,72" => "Channel.basic_get_empty", - "60,80" => "Channel.basic_ack", - "60,90" => "Channel.basic_reject", - "60,100" => "Channel.basic_recover", - "90,10" => "Channel.tx_select", - "90,11" => "Channel.tx_select_ok", - "90,20" => "Channel.tx_commit", - "90,21" => "Channel.tx_commit_ok", - "90,30" => "Channel.tx_rollback", - "90,31" => "Channel.tx_rollback_ok" -); +class AMQP { + public static $METHOD_NAME_MAP = array( + "10,10" => "Connection.start", + "10,11" => "Connection.start_ok", + "10,20" => "Connection.secure", + "10,21" => "Connection.secure_ok", + "10,30" => "Connection.tune", + "10,31" => "Connection.tune_ok", + "10,40" => "Connection.open", + "10,41" => "Connection.open_ok", + "10,50" => "Connection.redirect", + "10,60" => "Connection.close", + "10,61" => "Connection.close_ok", + "20,10" => "Channel.open", + "20,11" => "Channel.open_ok", + "20,20" => "Channel.flow", + "20,21" => "Channel.flow_ok", + "20,30" => "Channel.alert", + "20,40" => "Channel.close", + "20,41" => "Channel.close_ok", + "30,10" => "Channel.access_request", + "30,11" => "Channel.access_request_ok", + "40,10" => "Channel.exchange_declare", + "40,11" => "Channel.exchange_declare_ok", + "40,20" => "Channel.exchange_delete", + "40,21" => "Channel.exchange_delete_ok", + "50,10" => "Channel.queue_declare", + "50,11" => "Channel.queue_declare_ok", + "50,20" => "Channel.queue_bind", + "50,21" => "Channel.queue_bind_ok", + "50,30" => "Channel.queue_purge", + "50,31" => "Channel.queue_purge_ok", + "50,40" => "Channel.queue_delete", + "50,41" => "Channel.queue_delete_ok", + "60,10" => "Channel.basic_qos", + "60,11" => "Channel.basic_qos_ok", + "60,20" => "Channel.basic_consume", + "60,21" => "Channel.basic_consume_ok", + "60,30" => "Channel.basic_cancel", + "60,31" => "Channel.basic_cancel_ok", + "60,40" => "Channel.basic_publish", + "60,50" => "Channel.basic_return", + "60,60" => "Channel.basic_deliver", + "60,70" => "Channel.basic_get", + "60,71" => "Channel.basic_get_ok", + "60,72" => "Channel.basic_get_empty", + "60,80" => "Channel.basic_ack", + "60,90" => "Channel.basic_reject", + "60,100" => "Channel.basic_recover", + "90,10" => "Channel.tx_select", + "90,11" => "Channel.tx_select_ok", + "90,20" => "Channel.tx_commit", + "90,21" => "Channel.tx_commit_ok", + "90,30" => "Channel.tx_rollback", + "90,31" => "Channel.tx_rollback_ok" + ); +} class AbstractChannel { @@ -274,7 +275,7 @@ class AbstractChannel { unset($this->method_queue[$qk]); $this->debug_msg("Executing queued method: $method_sig: " . - $METHOD_NAME_MAP[methodSig($method_sig)]); + AMQP::$METHOD_NAME_MAP[methodSig($method_sig)]); return $this->dispatch($queued_method[0], $queued_method[1], @@ -299,8 +300,7 @@ class AbstractChannel $method_sig = "" . $method_sig_array[1] . "," . $method_sig_array[2]; $args = new AMQPReader(substr($payload,4)); - global $METHOD_NAME_MAP; - $this->debug_msg("> $method_sig: " . $METHOD_NAME_MAP[methodSig($method_sig)]); + $this->debug_msg("> $method_sig: " . AMQP::$METHOD_NAME_MAP[methodSig($method_sig)]); if(in_array($method_sig, AbstractChannel::$CONTENT_METHODS)) $content = $this->wait_content(); @@ -315,8 +315,7 @@ class AbstractChannel } // Wasn't what we were looking for? save it for later - global $METHOD_NAME_MAP; - $this->debug_msg("Queueing for later: $method_sig: " . $METHOD_NAME_MAP[methodSig($method_sig)]); + $this->debug_msg("Queueing for later: $method_sig: " . AMQP::$METHOD_NAME_MAP[methodSig($method_sig)]); array_push($this->method_queue,array($method_sig, $args, $content)); } } @@ -592,8 +591,7 @@ class AMQPConnection extends AbstractChannel $pkt = $pkt->getvalue(); $this->write($pkt); - global $METHOD_NAME_MAP; - $this->debug_msg("< " . methodSig($method_sig) . ": " . $METHOD_NAME_MAP[methodSig($method_sig)]); + $this->debug_msg("< " . methodSig($method_sig) . ": " . AMQP::$METHOD_NAME_MAP[methodSig($method_sig)]); } /**