Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment during equality check #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
128 changes: 63 additions & 65 deletions amqp.inc
Expand Up @@ -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(
Expand All @@ -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
{
Expand Down Expand Up @@ -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],
Expand All @@ -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();
Expand All @@ -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));
}
}
Expand Down Expand Up @@ -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)]);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions amqp_wire.inc
Expand Up @@ -38,7 +38,7 @@ class AMQPDecimal

public function asBCvalue()
{
return bcdiv($n, bcpow(10,$e));
return bcdiv($this->n, bcpow(10,$this->e));
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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')
{
Expand Down Expand Up @@ -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;
}

Expand Down