Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Saransaran/php-class-project
  • sibidharan/php-class-project
  • Madhan1024/php-class-project
  • GopiKrishnan/photogram
  • Mhd_khalid/php-class-project
  • At_muthu__/php-class-project
  • jaganbhaskar155/php-class-project
  • hariharanrd/php-class-project
  • jasper715/php-class-project
  • hanuRakesh/photogram-project-main
  • Yuvaraj21/photogram
  • ram_rogers/php-class-project
  • Hihelloboy/php-class-project
  • Nadarajan/php-class-project
  • srisanthosh156/php-class-project
  • Buvaneshwaran.k/php-class-project
  • umarfarooq07/php-class-project
  • Dhanaprakash/php-class-project
  • jashwanth142003/php-class-project
  • Esakkiraja/php-class-project
  • Boomi/php-class-project
  • Kishore2071/php-class-project
  • Ram123raj/php-class-project
  • aswinkumar27/php-class-project
  • dhilipdhilip9655/php-class-project
  • Manikandam143/php-class-project
  • VikramS/php-class-project
  • ArnoldSam/php-class-project
  • gowthamapandi0008/php-class-project
  • d.barath7639/php-class-project
  • shyalandran/php-class-project
  • kiruba_432/php-class-project
  • razakias001/php-class-project
  • kannan.b2745/php-class-project
  • sathish236tsk/php-class-project
  • rii/php-class-project
  • jonathajh4k/php-class-project
  • Neelagandan_G/php-class-project
  • Tholkappiar2003/php-class-project
  • kamaleshselvam75/php-class-project
  • devapriyan/php-class-project
  • sanojahamed/php-class-project
  • rizwankendo/php-class-project
  • senthamilselvan18000/php-class-project
  • rajeshd01/php-class-project
  • Florence/php-class-project
  • vishnu191299/php-class-project
  • Rakeshrakki/php-class-project
  • sanjay057/php-class-project
  • amarsanthoshsanthosh/photogram-project-cp
  • md_ashmar/php-class-project
  • k.nandhishwaran777k/php-class-project
52 results
Show changes
Showing
with 4240 additions and 0 deletions
<?php
namespace PhpAmqpLib\Exception;
class AMQPProtocolChannelException extends AMQPProtocolException
{
}
<?php
namespace PhpAmqpLib\Exception;
class AMQPProtocolException extends \Exception implements AMQPExceptionInterface
{
/** @var int */
public $amqp_reply_code;
/** @var string */
public $amqp_reply_text;
/** @var int[] */
public $amqp_method_sig;
/** @var array */
public $args;
/**
* @param int $reply_code
* @param string $reply_text
* @param int[] $method_sig
*/
public function __construct($reply_code, $reply_text, $method_sig)
{
parent::__construct($reply_text, $reply_code);
$this->amqp_reply_code = $reply_code; // redundant, but kept for BC
$this->amqp_reply_text = $reply_text; // redundant, but kept for BC
$this->amqp_method_sig = $method_sig;
$this->args = array($reply_code, $reply_text, $method_sig);
}
}
<?php
namespace PhpAmqpLib\Exception;
class AMQPRuntimeException extends \RuntimeException implements AMQPExceptionInterface
{
}
<?php
namespace PhpAmqpLib\Exception;
class AMQPSocketException extends AMQPRuntimeException
{
}
<?php
namespace PhpAmqpLib\Exception;
class AMQPTimeoutException extends \RuntimeException implements AMQPExceptionInterface
{
/**
* @var int|float|null
*/
private $timeout;
public function __construct($message = '', $timeout = 0, $code = 0, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);
$this->timeout = $timeout;
}
/**
* @param int|float|null $timeout
* @param int $code
* @return self
*/
public static function writeTimeout($timeout, $code = 0)
{
return new self('Error sending data. Connection timed out.', $timeout, $code);
}
/**
* @return int|float|null
*/
public function getTimeout()
{
return $this->timeout;
}
}
<?php
namespace PhpAmqpLib\Exchange;
final class AMQPExchangeType
{
const DIRECT = 'direct';
const FANOUT = 'fanout';
const TOPIC = 'topic';
const HEADERS = 'headers';
}
<?php
namespace PhpAmqpLib\Helper;
use InvalidArgumentException;
class Assert
{
/**
* @param mixed $argument
* @throws \InvalidArgumentException
*/
public static function isCallable($argument)
{
if (!is_callable($argument)) {
throw new InvalidArgumentException(sprintf(
'Given argument "%s" should be callable. %s type was given.',
$argument,
gettype($argument)
));
}
}
}
<?php
namespace PhpAmqpLib\Helper;
if (class_exists('phpseclib\Math\BigInteger')) {
class BigInteger extends \phpseclib\Math\BigInteger
{
}
} elseif (class_exists('phpseclib3\Math\BigInteger')) {
class BigInteger extends \phpseclib3\Math\BigInteger
{
}
} else {
throw new \RuntimeException('Cannot find supported phpseclib/phpseclib library');
}
<?php
namespace PhpAmqpLib\Helper;
use PhpAmqpLib\Wire\Constants;
class DebugHelper
{
/**
* @var bool
*/
protected $debug;
/**
* @var resource
*/
protected $debug_output;
/**
* @var Constants
*/
protected $constants;
/**
* @param Constants $constants
*/
public function __construct(Constants $constants)
{
$this->debug = defined('AMQP_DEBUG') ? AMQP_DEBUG : false;
if (defined('AMQP_DEBUG_OUTPUT')) {
$this->debug_output = AMQP_DEBUG_OUTPUT;
} else {
$this->debug_output = fopen('php://output', 'wb');
}
$this->constants = $constants;
}
/**
* @param string $msg
*/
public function debug_msg($msg)
{
if ($this->debug) {
$this->print_msg($msg);
}
}
/**
* @param array|null $allowed_methods
*/
public function debug_allowed_methods($allowed_methods)
{
if ($this->debug) {
if ($allowed_methods) {
$msg = 'waiting for ' . implode(', ', $allowed_methods);
} else {
$msg = 'waiting for any method';
}
$this->debug_msg($msg);
}
}
/**
* @param string|array $method_sig
*/
public function debug_method_signature1($method_sig)
{
$this->debug_method_signature('< %s:', $method_sig);
}
/**
* @param string $msg
* @param string|array $method_sig
*/
public function debug_method_signature($msg, $method_sig)
{
if ($this->debug) {
$constants = $this->constants;
$methods = $constants::$GLOBAL_METHOD_NAMES;
$key = MiscHelper::methodSig($method_sig);
$this->debug_msg(sprintf($msg . ': %s', $key, $methods[$key]));
}
}
/**
* @param string $data
*/
public function debug_hexdump($data)
{
if ($this->debug) {
$this->debug_msg(
sprintf(
'< [hex]: %s%s',
PHP_EOL,
MiscHelper::hexdump($data, $htmloutput = false, $uppercase = true, $return = true)
)
);
}
}
/**
* @param int $version_major
* @param int $version_minor
* @param array $server_properties
* @param array $mechanisms
* @param array $locales
*/
public function debug_connection_start($version_major, $version_minor, $server_properties, $mechanisms, $locales)
{
if ($this->debug) {
$this->debug_msg(
sprintf(
'Start from server, version: %d.%d, properties: %s, mechanisms: %s, locales: %s',
$version_major,
$version_minor,
MiscHelper::dump_table($server_properties),
implode(', ', $mechanisms),
implode(', ', $locales)
)
);
}
}
/**
* @param string $s
*/
protected function print_msg($s)
{
fwrite($this->debug_output, $s . PHP_EOL);
}
}
<?php
namespace PhpAmqpLib\Helper;
class MiscHelper
{
/**
* @param string|array $a
* @return string
*/
public static function methodSig($a)
{
if (is_string($a)) {
return $a;
}
return sprintf('%d,%d', $a[0], $a[1]);
}
/**
* Gets a number (either int or float) and returns an array containing its integer part as first element and its
* decimal part mutliplied by 10^6. Useful for some PHP stream functions that need seconds and microseconds as
* different arguments
*
* @param int|float $number
* @return int[]
*/
public static function splitSecondsMicroseconds($number)
{
return array((int)floor($number), (int)(fmod($number, 1) * 1000000));
}
/**
* View any string as a hexdump.
*
* This is most commonly used to view binary data from streams
* or sockets while debugging, but can be used to view any string
* with non-viewable characters.
*
* @version 1.3.2
* @author Aidan Lister <aidan@php.net>
* @author Peter Waller <iridum@php.net>
* @link http://aidanlister.com/repos/v/function.hexdump.php
*
* @param string $data The string to be dumped
* @param bool $htmloutput Set to false for non-HTML output
* @param bool $uppercase Set to true for uppercase hex
* @param bool $return Set to true to return the dump
* @return string|null
*/
public static function hexdump($data, $htmloutput = true, $uppercase = false, $return = false)
{
// Init
$hexi = '';
$ascii = '';
$dump = $htmloutput ? '<pre>' : '';
$offset = 0;
$len = mb_strlen($data, 'ASCII');
// Upper or lower case hexidecimal
$hexFormat = $uppercase ? 'X' : 'x';
// Iterate string
for ($i = $j = 0; $i < $len; $i++) {
// Convert to hexidecimal
// We must use concatenation here because the $hexFormat value
// is needed for sprintf() to parse the format
$hexi .= sprintf('%02' . $hexFormat . ' ', ord($data[$i]));
// Replace non-viewable bytes with '.'
if (ord($data[$i]) >= 32) {
$ascii .= $htmloutput ? htmlentities($data[$i]) : $data[$i];
} else {
$ascii .= '.';
}
// Add extra column spacing
if ($j === 7) {
$hexi .= ' ';
$ascii .= ' ';
}
// Add row
if (++$j === 16 || $i === $len - 1) {
// Join the hexi / ascii output
// We must use concatenation here because the $hexFormat value
// is needed for sprintf() to parse the format
$dump .= sprintf('%04' . $hexFormat . ' %-49s %s', $offset, $hexi, $ascii);
// Reset vars
$hexi = $ascii = '';
$offset += 16;
$j = 0;
// Add newline
if ($i !== $len - 1) {
$dump .= PHP_EOL;
}
}
}
// Finish dump
$dump .= $htmloutput ? '</pre>' : '';
$dump .= PHP_EOL;
if ($return) {
return $dump;
}
echo $dump;
return null;
}
/**
* @param array $table
* @return string
*/
public static function dump_table($table)
{
$tokens = array();
foreach ($table as $name => $value) {
switch ($value[0]) {
case 'D':
$val = $value[1]->n . 'E' . $value[1]->e;
break;
case 'F':
$val = '(' . self::dump_table($value[1]) . ')';
break;
case 'T':
$val = date('Y-m-d H:i:s', $value[1]);
break;
default:
$val = $value[1];
}
$tokens[] = $name . '=' . $val;
}
return implode(', ', $tokens);
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
class MethodMap080
{
/**
* @var array
*/
protected $method_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' => 'access_request',
'30,11' => 'access_request_ok',
'40,10' => 'exchange_declare',
'40,11' => 'exchange_declare_ok',
'40,20' => 'exchange_delete',
'40,21' => 'exchange_delete_ok',
'50,10' => 'queue_declare',
'50,11' => 'queue_declare_ok',
'50,20' => 'queue_bind',
'50,21' => 'queue_bind_ok',
'50,30' => 'queue_purge',
'50,31' => 'queue_purge_ok',
'50,40' => 'queue_delete',
'50,41' => 'queue_delete_ok',
'50,50' => 'queue_unbind',
'50,51' => 'queue_unbind_ok',
'60,10' => 'basic_qos',
'60,11' => 'basic_qos_ok',
'60,20' => 'basic_consume',
'60,21' => 'basic_consume_ok',
'60,30' => 'basic_cancel',
'60,31' => 'basic_cancel_ok',
'60,40' => 'basic_publish',
'60,50' => 'basic_return',
'60,60' => 'basic_deliver',
'60,70' => 'basic_get',
'60,71' => 'basic_get_ok',
'60,72' => 'basic_get_empty',
'60,80' => 'basic_ack',
'60,90' => 'basic_reject',
'60,100' => 'basic_recover_async',
'60,110' => 'basic_recover',
'60,111' => 'basic_recover_ok',
'70,10' => 'file_qos',
'70,11' => 'file_qos_ok',
'70,20' => 'file_consume',
'70,21' => 'file_consume_ok',
'70,30' => 'file_cancel',
'70,31' => 'file_cancel_ok',
'70,40' => 'file_open',
'70,41' => 'file_open_ok',
'70,50' => 'file_stage',
'70,60' => 'file_publish',
'70,70' => 'file_return',
'70,80' => 'file_deliver',
'70,90' => 'file_ack',
'70,100' => 'file_reject',
'80,10' => 'stream_qos',
'80,11' => 'stream_qos_ok',
'80,20' => 'stream_consume',
'80,21' => 'stream_consume_ok',
'80,30' => 'stream_cancel',
'80,31' => 'stream_cancel_ok',
'80,40' => 'stream_publish',
'80,50' => 'stream_return',
'80,60' => 'stream_deliver',
'90,10' => 'tx_select',
'90,11' => 'tx_select_ok',
'90,20' => 'tx_commit',
'90,21' => 'tx_commit_ok',
'90,30' => 'tx_rollback',
'90,31' => 'tx_rollback_ok',
'100,10' => 'dtx_select',
'100,11' => 'dtx_select_ok',
'100,20' => 'dtx_start',
'100,21' => 'dtx_start_ok',
'110,10' => 'tunnel_request',
'120,10' => 'test_integer',
'120,11' => 'test_integer_ok',
'120,20' => 'test_string',
'120,21' => 'test_string_ok',
'120,30' => 'test_table',
'120,31' => 'test_table_ok',
'120,40' => 'test_content',
'120,41' => 'test_content_ok',
);
/**
* @var string $method_sig
* @return string
*/
public function get_method($method_sig)
{
return $this->method_map[$method_sig];
}
/**
* @var string $method_sig
* @return bool
*/
public function valid_method($method_sig)
{
return array_key_exists($method_sig, $this->method_map);
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
class MethodMap091
{
/**
* @var array
*/
protected $method_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_close',
'10,51' => 'connection_close_ok',
'10,60' => 'connection_blocked',
'10,61' => 'connection_unblocked',
'20,10' => 'channel_open',
'20,11' => 'channel_open_ok',
'20,20' => 'channel_flow',
'20,21' => 'channel_flow_ok',
'20,40' => 'channel_close',
'20,41' => 'channel_close_ok',
'30,10' => 'access_request',
'30,11' => 'access_request_ok',
'40,10' => 'exchange_declare',
'40,11' => 'exchange_declare_ok',
'40,20' => 'exchange_delete',
'40,21' => 'exchange_delete_ok',
'40,30' => 'exchange_bind',
'40,31' => 'exchange_bind_ok',
'40,40' => 'exchange_unbind',
'40,51' => 'exchange_unbind_ok',
'50,10' => 'queue_declare',
'50,11' => 'queue_declare_ok',
'50,20' => 'queue_bind',
'50,21' => 'queue_bind_ok',
'50,30' => 'queue_purge',
'50,31' => 'queue_purge_ok',
'50,40' => 'queue_delete',
'50,41' => 'queue_delete_ok',
'50,50' => 'queue_unbind',
'50,51' => 'queue_unbind_ok',
'60,10' => 'basic_qos',
'60,11' => 'basic_qos_ok',
'60,20' => 'basic_consume',
'60,21' => 'basic_consume_ok',
'60,30' => 'basic_cancel_from_server',
'60,31' => 'basic_cancel_ok',
'60,40' => 'basic_publish',
'60,50' => 'basic_return',
'60,60' => 'basic_deliver',
'60,70' => 'basic_get',
'60,71' => 'basic_get_ok',
'60,72' => 'basic_get_empty',
'60,80' => 'basic_ack_from_server',
'60,90' => 'basic_reject',
'60,100' => 'basic_recover_async',
'60,110' => 'basic_recover',
'60,111' => 'basic_recover_ok',
'60,120' => 'basic_nack_from_server',
'90,10' => 'tx_select',
'90,11' => 'tx_select_ok',
'90,20' => 'tx_commit',
'90,21' => 'tx_commit_ok',
'90,30' => 'tx_rollback',
'90,31' => 'tx_rollback_ok',
'85,10' => 'confirm_select',
'85,11' => 'confirm_select_ok',
);
/**
* @var string $method_sig
* @return string
*/
public function get_method($method_sig)
{
return $this->method_map[$method_sig];
}
/**
* @var string $method_sig
* @return bool
*/
public function valid_method($method_sig)
{
return array_key_exists($method_sig, $this->method_map);
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
use PhpAmqpLib\Wire\AMQPWriter;
use PhpAmqpLib\Wire\AMQPReader;
class Protocol080
{
/**
* @param int $version_major
* @param int $version_minor
* @param mixed $server_properties
* @param string $mechanisms
* @param string $locales
* @return array
*/
public function connectionStart(
$version_major = 0,
$version_minor = 8,
$server_properties = [],
$mechanisms = 'PLAIN',
$locales = 'en_US'
) {
$writer = new AMQPWriter();
$writer->write_octet($version_major);
$writer->write_octet($version_minor);
$writer->write_table(empty($server_properties) ? array() : $server_properties);
$writer->write_longstr($mechanisms);
$writer->write_longstr($locales);
return array(10, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionStartOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_table();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_longstr();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $challenge
* @return array
*/
public function connectionSecure($challenge)
{
$writer = new AMQPWriter();
$writer->write_longstr($challenge);
return array(10, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionSecureOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longstr();
return $response;
}
/**
* @param int $channel_max
* @param int $frame_max
* @param int $heartbeat
* @return array
*/
public function connectionTune($channel_max = 0, $frame_max = 0, $heartbeat = 0)
{
$writer = new AMQPWriter();
$writer->write_short($channel_max);
$writer->write_long($frame_max);
$writer->write_short($heartbeat);
return array(10, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionTuneOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_short();
$response[] = $reader->read_long();
$response[] = $reader->read_short();
return $response;
}
/**
* @param string $virtual_host
* @param string $capabilities
* @param bool $insist
* @return array
*/
public function connectionOpen($virtual_host = '/', $capabilities = '', $insist = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($virtual_host);
$writer->write_shortstr($capabilities);
$writer->write_bits(array($insist));
return array(10, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionOpenOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $host
* @param string $known_hosts
* @return array
*/
public function connectionRedirect($host, $known_hosts = '')
{
$writer = new AMQPWriter();
$writer->write_shortstr($host);
$writer->write_shortstr($known_hosts);
return array(10, 50, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param int $class_id
* @param int $method_id
* @return array
*/
public function connectionClose($reply_code, $reply_text, $class_id, $method_id)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_short($class_id);
$writer->write_short($method_id);
return array(10, 60, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionCloseOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $out_of_band
* @return array
*/
public function channelOpen($out_of_band = '')
{
$writer = new AMQPWriter();
$writer->write_shortstr($out_of_band);
return array(20, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelOpenOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param bool $active
* @return array
*/
public function channelFlow($active)
{
$writer = new AMQPWriter();
$writer->write_bits(array($active));
return array(20, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelFlowOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_bit();
return $response;
}
/**
* @param int $reply_code
* @param string $reply_text
* @param \PhpAmqpLib\Wire\AMQPTable|array $details
* @return array
*/
public function channelAlert($reply_code, $reply_text = '', $details = array())
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_table(empty($details) ? array() : $details);
return array(20, 30, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param int $class_id
* @param int $method_id
* @return array
*/
public function channelClose($reply_code, $reply_text, $class_id, $method_id)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_short($class_id);
$writer->write_short($method_id);
return array(20, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelCloseOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $realm
* @param bool $exclusive
* @param bool $passive
* @param bool $active
* @param bool $write
* @param bool $read
* @return array
*/
public function accessRequest(
$realm = '/data',
$exclusive = false,
$passive = true,
$active = true,
$write = true,
$read = true
) {
$writer = new AMQPWriter();
$writer->write_shortstr($realm);
$writer->write_bits(array($exclusive, $passive, $active, $write, $read));
return array(30, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function accessRequestOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_short();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param string $type
* @param bool $passive
* @param bool $durable
* @param bool $auto_delete
* @param bool $internal
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function exchangeDeclare(
$ticket = 1,
$exchange = '',
$type = 'direct',
$passive = false,
$durable = false,
$auto_delete = false,
$internal = false,
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($type);
$writer->write_bits(array($passive, $durable, $auto_delete, $internal, $nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(40, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeDeclareOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param bool $if_unused
* @param bool $nowait
* @return array
*/
public function exchangeDelete($ticket = 1, $exchange = '', $if_unused = false, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_bits(array($if_unused, $nowait));
return array(40, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeDeleteOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $passive
* @param bool $durable
* @param bool $exclusive
* @param bool $auto_delete
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueDeclare(
$ticket = 1,
$queue = '',
$passive = false,
$durable = false,
$exclusive = false,
$auto_delete = false,
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($passive, $durable, $exclusive, $auto_delete, $nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueDeclareOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_long();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $exchange
* @param string $routing_key
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueBind(
$ticket = 1,
$queue = '',
$exchange = '',
$routing_key = '',
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueBindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $nowait
* @return array
*/
public function queuePurge($ticket = 1, $queue = '', $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($nowait));
return array(50, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queuePurgeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $if_unused
* @param bool $if_empty
* @param bool $nowait
* @return array
*/
public function queueDelete($ticket = 1, $queue = '', $if_unused = false, $if_empty = false, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($if_unused, $if_empty, $nowait));
return array(50, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueDeleteOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $exchange
* @param string $routing_key
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueUnbind($ticket = 1, $queue = '', $exchange = '', $routing_key = '', $arguments = array())
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 50, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueUnbindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $prefetch_size
* @param int $prefetch_count
* @param bool $global
* @return array
*/
public function basicQos($prefetch_size = 0, $prefetch_count = 0, $global = false)
{
$writer = new AMQPWriter();
$writer->write_long($prefetch_size);
$writer->write_short($prefetch_count);
$writer->write_bits(array($global));
return array(60, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicQosOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $consumer_tag
* @param bool $no_local
* @param bool $no_ack
* @param bool $exclusive
* @param bool $nowait
* @return array
*/
public function basicConsume(
$ticket = 1,
$queue = '',
$consumer_tag = '',
$no_local = false,
$no_ack = false,
$exclusive = false,
$nowait = false
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($no_local, $no_ack, $exclusive, $nowait));
return array(60, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicConsumeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $consumer_tag
* @param bool $nowait
* @return array
*/
public function basicCancel($consumer_tag, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($nowait));
return array(60, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicCancelOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param string $routing_key
* @param bool $mandatory
* @param bool $immediate
* @return array
*/
public function basicPublish($ticket = 1, $exchange = '', $routing_key = '', $mandatory = false, $immediate = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($mandatory, $immediate));
return array(60, 40, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function basicReturn($reply_code, $reply_text, $exchange, $routing_key)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(60, 50, $writer);
}
/**
* @param string $consumer_tag
* @param int $delivery_tag
* @param bool $redelivered
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function basicDeliver($consumer_tag, $delivery_tag, $redelivered, $exchange, $routing_key)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($redelivered));
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(60, 60, $writer);
}
/**
* @param int $ticket
* @param string $queue
* @param bool $no_ack
* @return array
*/
public function basicGet($ticket = 1, $queue = '', $no_ack = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($no_ack));
return array(60, 70, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicGetOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longlong();
$response[] = $reader->read_bit();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_long();
return $response;
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicGetEmpty(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $delivery_tag
* @param bool $multiple
* @return array
*/
public function basicAck($delivery_tag = 0, $multiple = false)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($multiple));
return array(60, 80, $writer);
}
/**
* @param int $delivery_tag
* @param bool $requeue
* @return array
*/
public function basicReject($delivery_tag, $requeue = true)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($requeue));
return array(60, 90, $writer);
}
/**
* @param bool $requeue
* @return array
*/
public function basicRecoverAsync($requeue = false)
{
$writer = new AMQPWriter();
$writer->write_bits(array($requeue));
return array(60, 100, $writer);
}
/**
* @param bool $requeue
* @return array
*/
public function basicRecover($requeue = false)
{
$writer = new AMQPWriter();
$writer->write_bits(array($requeue));
return array(60, 110, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicRecoverOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $prefetch_size
* @param int $prefetch_count
* @param bool $global
* @return array
*/
public function fileQos($prefetch_size = 0, $prefetch_count = 0, $global = false)
{
$writer = new AMQPWriter();
$writer->write_long($prefetch_size);
$writer->write_short($prefetch_count);
$writer->write_bits(array($global));
return array(70, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function fileQosOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $consumer_tag
* @param bool $no_local
* @param bool $no_ack
* @param bool $exclusive
* @param bool $nowait
* @return array
*/
public function fileConsume(
$ticket = 1,
$queue = '',
$consumer_tag = '',
$no_local = false,
$no_ack = false,
$exclusive = false,
$nowait = false
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($no_local, $no_ack, $exclusive, $nowait));
return array(70, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function fileConsumeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $consumer_tag
* @param bool $nowait
* @return array
*/
public function fileCancel($consumer_tag, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($nowait));
return array(70, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function fileCancelOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $identifier
* @param int $content_size
* @return array
*/
public function fileOpen($identifier, $content_size)
{
$writer = new AMQPWriter();
$writer->write_shortstr($identifier);
$writer->write_longlong($content_size);
return array(70, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function fileOpenOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longlong();
return $response;
}
/**
* @return array
*/
public function fileStage()
{
$writer = new AMQPWriter();
return array(70, 50, $writer);
}
/**
* @param int $ticket
* @param string $exchange
* @param string $routing_key
* @param bool $mandatory
* @param bool $immediate
* @param string $identifier
* @return array
*/
public function filePublish(
$ticket = 1,
$exchange = '',
$routing_key = '',
$mandatory = false,
$immediate = false,
$identifier = ''
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($mandatory, $immediate));
$writer->write_shortstr($identifier);
return array(70, 60, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function fileReturn($reply_code = 200, $reply_text = '', $exchange = '', $routing_key = '')
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(70, 70, $writer);
}
/**
* @param string $consumer_tag
* @param int $delivery_tag
* @param bool $redelivered
* @param string $exchange
* @param string $routing_key
* @param string $identifier
* @return array
*/
public function fileDeliver(
$consumer_tag,
$delivery_tag,
$redelivered,
$exchange,
$routing_key,
$identifier
) {
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($redelivered));
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_shortstr($identifier);
return array(70, 80, $writer);
}
/**
* @param int $delivery_tag
* @param bool $multiple
* @return array
*/
public function fileAck($delivery_tag = 0, $multiple = false)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($multiple));
return array(70, 90, $writer);
}
/**
* @param int $delivery_tag
* @param bool $requeue
* @return array
*/
public function fileReject($delivery_tag, $requeue = true)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($requeue));
return array(70, 100, $writer);
}
/**
* @param int $prefetch_size
* @param int $prefetch_count
* @param int $consume_rate
* @param bool $global
* @return array
*/
public function streamQos($prefetch_size = 0, $prefetch_count = 0, $consume_rate = 0, $global = false)
{
$writer = new AMQPWriter();
$writer->write_long($prefetch_size);
$writer->write_short($prefetch_count);
$writer->write_long($consume_rate);
$writer->write_bits(array($global));
return array(80, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function streamQosOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $consumer_tag
* @param bool $no_local
* @param bool $exclusive
* @param bool $nowait
* @return array
*/
public function streamConsume(
$ticket = 1,
$queue = '',
$consumer_tag = '',
$no_local = false,
$exclusive = false,
$nowait = false
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($no_local, $exclusive, $nowait));
return array(80, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function streamConsumeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $consumer_tag
* @param bool $nowait
* @return array
*/
public function streamCancel($consumer_tag, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($nowait));
return array(80, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function streamCancelOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param string $routing_key
* @param bool $mandatory
* @param bool $immediate
* @return array
*/
public function streamPublish(
$ticket = 1,
$exchange = '',
$routing_key = '',
$mandatory = false,
$immediate = false
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($mandatory, $immediate));
return array(80, 40, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function streamReturn($reply_code = 200, $reply_text = '', $exchange = '', $routing_key = '')
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(80, 50, $writer);
}
/**
* @param string $consumer_tag
* @param int $delivery_tag
* @param string $exchange
* @param string $queue
* @return array
*/
public function streamDeliver($consumer_tag, $delivery_tag, $exchange, $queue)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_longlong($delivery_tag);
$writer->write_shortstr($exchange);
$writer->write_shortstr($queue);
return array(80, 60, $writer);
}
/**
* @return array
*/
public function txSelect()
{
$writer = new AMQPWriter();
return array(90, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txSelectOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @return array
*/
public function txCommit()
{
$writer = new AMQPWriter();
return array(90, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txCommitOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @return array
*/
public function txRollback()
{
$writer = new AMQPWriter();
return array(90, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txRollbackOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @return array
*/
public function dtxSelect()
{
$writer = new AMQPWriter();
return array(100, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function dtxSelectOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $dtx_identifier
* @return array
*/
public function dtxStart($dtx_identifier)
{
$writer = new AMQPWriter();
$writer->write_shortstr($dtx_identifier);
return array(100, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function dtxStartOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param \PhpAmqpLib\Wire\AMQPTable|array $meta_data
* @return array
*/
public function tunnelRequest($meta_data)
{
$writer = new AMQPWriter();
$writer->write_table(empty($meta_data) ? array() : $meta_data);
return array(110, 10, $writer);
}
/**
* @param int $integer_1
* @param int $integer_2
* @param int $integer_3
* @param int $integer_4
* @param int $operation
* @return array
*/
public function testInteger($integer_1, $integer_2, $integer_3, $integer_4, $operation)
{
$writer = new AMQPWriter();
$writer->write_octet($integer_1);
$writer->write_short($integer_2);
$writer->write_long($integer_3);
$writer->write_longlong($integer_4);
$writer->write_octet($operation);
return array(120, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function testIntegerOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longlong();
return $response;
}
/**
* @param string $string_1
* @param string $string_2
* @param int $operation
* @return array
*/
public function testString($string_1, $string_2, $operation)
{
$writer = new AMQPWriter();
$writer->write_shortstr($string_1);
$writer->write_longstr($string_2);
$writer->write_octet($operation);
return array(120, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function testStringOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longstr();
return $response;
}
/**
* @param \PhpAmqpLib\Wire\AMQPTable|array $table
* @param int $integer_op
* @param int $string_op
* @return array
*/
public function testTable($table, $integer_op, $string_op)
{
$writer = new AMQPWriter();
$writer->write_table(empty($table) ? array() : $table);
$writer->write_octet($integer_op);
$writer->write_octet($string_op);
return array(120, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function testTableOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longlong();
$response[] = $reader->read_longstr();
return $response;
}
/**
* @return array
*/
public function testContent()
{
$writer = new AMQPWriter();
return array(120, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function testContentOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_long();
return $response;
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
use PhpAmqpLib\Wire\AMQPWriter;
use PhpAmqpLib\Wire\AMQPReader;
class Protocol091
{
/**
* @param int $version_major
* @param int $version_minor
* @param mixed $server_properties
* @param string $mechanisms
* @param string $locales
* @return array
*/
public function connectionStart(
$version_major = 0,
$version_minor = 9,
$server_properties = [],
$mechanisms = 'PLAIN',
$locales = 'en_US'
) {
$writer = new AMQPWriter();
$writer->write_octet($version_major);
$writer->write_octet($version_minor);
$writer->write_table(empty($server_properties) ? array() : $server_properties);
$writer->write_longstr($mechanisms);
$writer->write_longstr($locales);
return array(10, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionStartOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_table();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_longstr();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $challenge
* @return array
*/
public function connectionSecure($challenge)
{
$writer = new AMQPWriter();
$writer->write_longstr($challenge);
return array(10, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionSecureOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longstr();
return $response;
}
/**
* @param int $channel_max
* @param int $frame_max
* @param int $heartbeat
* @return array
*/
public function connectionTune($channel_max = 0, $frame_max = 0, $heartbeat = 0)
{
$writer = new AMQPWriter();
$writer->write_short($channel_max);
$writer->write_long($frame_max);
$writer->write_short($heartbeat);
return array(10, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionTuneOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_short();
$response[] = $reader->read_long();
$response[] = $reader->read_short();
return $response;
}
/**
* @param string $virtual_host
* @param string $capabilities
* @param bool $insist
* @return array
*/
public function connectionOpen($virtual_host = '/', $capabilities = '', $insist = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($virtual_host);
$writer->write_shortstr($capabilities);
$writer->write_bits(array($insist));
return array(10, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionOpenOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $reply_code
* @param string $reply_text
* @param int $class_id
* @param int $method_id
* @return array
*/
public function connectionClose($reply_code, $reply_text, $class_id, $method_id)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_short($class_id);
$writer->write_short($method_id);
return array(10, 50, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionCloseOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $reason
* @return array
*/
public function connectionBlocked($reason = '')
{
$writer = new AMQPWriter();
$writer->write_shortstr($reason);
return array(10, 60, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function connectionUnblocked(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $out_of_band
* @return array
*/
public function channelOpen($out_of_band = '')
{
$writer = new AMQPWriter();
$writer->write_shortstr($out_of_band);
return array(20, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelOpenOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longstr();
return $response;
}
/**
* @param bool $active
* @return array
*/
public function channelFlow($active)
{
$writer = new AMQPWriter();
$writer->write_bits(array($active));
return array(20, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelFlowOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_bit();
return $response;
}
/**
* @param int $reply_code
* @param string $reply_text
* @param int $class_id
* @param int $method_id
* @return array
*/
public function channelClose($reply_code, $reply_text, $class_id, $method_id)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_short($class_id);
$writer->write_short($method_id);
return array(20, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function channelCloseOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param string $realm
* @param bool $exclusive
* @param bool $passive
* @param bool $active
* @param bool $write
* @param bool $read
* @return array
*/
public function accessRequest(
$realm = '/data',
$exclusive = false,
$passive = true,
$active = true,
$write = true,
$read = true
) {
$writer = new AMQPWriter();
$writer->write_shortstr($realm);
$writer->write_bits(array($exclusive, $passive, $active, $write, $read));
return array(30, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function accessRequestOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_short();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param string $type
* @param bool $passive
* @param bool $durable
* @param bool $auto_delete
* @param bool $internal
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function exchangeDeclare(
$ticket = 0,
$exchange = '',
$type = 'direct',
$passive = false,
$durable = false,
$auto_delete = false,
$internal = false,
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($type);
$writer->write_bits(array($passive, $durable, $auto_delete, $internal, $nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(40, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeDeclareOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param bool $if_unused
* @param bool $nowait
* @return array
*/
public function exchangeDelete($ticket = 0, $exchange = '', $if_unused = false, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_bits(array($if_unused, $nowait));
return array(40, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeDeleteOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $destination
* @param string $source
* @param string $routing_key
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function exchangeBind(
$ticket = 0,
$destination = '',
$source = '',
$routing_key = '',
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($destination);
$writer->write_shortstr($source);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(40, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeBindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $destination
* @param string $source
* @param string $routing_key
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function exchangeUnbind(
$ticket = 0,
$destination = '',
$source = '',
$routing_key = '',
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($destination);
$writer->write_shortstr($source);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(40, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function exchangeUnbindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $passive
* @param bool $durable
* @param bool $exclusive
* @param bool $auto_delete
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueDeclare(
$ticket = 0,
$queue = '',
$passive = false,
$durable = false,
$exclusive = false,
$auto_delete = false,
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($passive, $durable, $exclusive, $auto_delete, $nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueDeclareOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_long();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $exchange
* @param string $routing_key
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueBind(
$ticket = 0,
$queue = '',
$exchange = '',
$routing_key = '',
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueBindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $nowait
* @return array
*/
public function queuePurge($ticket = 0, $queue = '', $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($nowait));
return array(50, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queuePurgeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param bool $if_unused
* @param bool $if_empty
* @param bool $nowait
* @return array
*/
public function queueDelete($ticket = 0, $queue = '', $if_unused = false, $if_empty = false, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($if_unused, $if_empty, $nowait));
return array(50, 40, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueDeleteOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_long();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $exchange
* @param string $routing_key
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function queueUnbind($ticket = 0, $queue = '', $exchange = '', $routing_key = '', $arguments = array())
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(50, 50, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function queueUnbindOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $prefetch_size
* @param int $prefetch_count
* @param bool $global
* @return array
*/
public function basicQos($prefetch_size = 0, $prefetch_count = 0, $global = false)
{
$writer = new AMQPWriter();
$writer->write_long($prefetch_size);
$writer->write_short($prefetch_count);
$writer->write_bits(array($global));
return array(60, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicQosOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $ticket
* @param string $queue
* @param string $consumer_tag
* @param bool $no_local
* @param bool $no_ack
* @param bool $exclusive
* @param bool $nowait
* @param \PhpAmqpLib\Wire\AMQPTable|array $arguments
* @return array
*/
public function basicConsume(
$ticket = 0,
$queue = '',
$consumer_tag = '',
$no_local = false,
$no_ack = false,
$exclusive = false,
$nowait = false,
$arguments = array()
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($no_local, $no_ack, $exclusive, $nowait));
$writer->write_table(empty($arguments) ? array() : $arguments);
return array(60, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicConsumeOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param string $consumer_tag
* @param bool $nowait
* @return array
*/
public function basicCancel($consumer_tag, $nowait = false)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_bits(array($nowait));
return array(60, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicCancelOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $ticket
* @param string $exchange
* @param string $routing_key
* @param bool $mandatory
* @param bool $immediate
* @return array
*/
public function basicPublish(
$ticket = 0,
$exchange = '',
$routing_key = '',
$mandatory = false,
$immediate = false
) {
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
$writer->write_bits(array($mandatory, $immediate));
return array(60, 40, $writer);
}
/**
* @param int $reply_code
* @param string $reply_text
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function basicReturn($reply_code, $reply_text, $exchange, $routing_key)
{
$writer = new AMQPWriter();
$writer->write_short($reply_code);
$writer->write_shortstr($reply_text);
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(60, 50, $writer);
}
/**
* @param string $consumer_tag
* @param int $delivery_tag
* @param bool $redelivered
* @param string $exchange
* @param string $routing_key
* @return array
*/
public function basicDeliver($consumer_tag, $delivery_tag, $redelivered, $exchange, $routing_key)
{
$writer = new AMQPWriter();
$writer->write_shortstr($consumer_tag);
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($redelivered));
$writer->write_shortstr($exchange);
$writer->write_shortstr($routing_key);
return array(60, 60, $writer);
}
/**
* @param int $ticket
* @param string $queue
* @param bool $no_ack
* @return array
*/
public function basicGet($ticket = 0, $queue = '', $no_ack = false)
{
$writer = new AMQPWriter();
$writer->write_short($ticket);
$writer->write_shortstr($queue);
$writer->write_bits(array($no_ack));
return array(60, 70, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicGetOk(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_longlong();
$response[] = $reader->read_bit();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_shortstr();
$response[] = $reader->read_long();
return $response;
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicGetEmpty(AMQPReader $reader)
{
$response = array();
$response[] = $reader->read_shortstr();
return $response;
}
/**
* @param int $delivery_tag
* @param bool $multiple
* @return array
*/
public function basicAck($delivery_tag = 0, $multiple = false)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($multiple));
return array(60, 80, $writer);
}
/**
* @param int $delivery_tag
* @param bool $requeue
* @return array
*/
public function basicReject($delivery_tag, $requeue = true)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($requeue));
return array(60, 90, $writer);
}
/**
* @param bool $requeue
* @return array
*/
public function basicRecoverAsync($requeue = false)
{
$writer = new AMQPWriter();
$writer->write_bits(array($requeue));
return array(60, 100, $writer);
}
/**
* @param bool $requeue
* @return array
*/
public function basicRecover($requeue = false)
{
$writer = new AMQPWriter();
$writer->write_bits(array($requeue));
return array(60, 110, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function basicRecoverOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param int $delivery_tag
* @param bool $multiple
* @param bool $requeue
* @return array
*/
public function basicNack($delivery_tag = 0, $multiple = false, $requeue = true)
{
$writer = new AMQPWriter();
$writer->write_longlong($delivery_tag);
$writer->write_bits(array($multiple, $requeue));
return array(60, 120, $writer);
}
/**
* @return array
*/
public function txSelect()
{
$writer = new AMQPWriter();
return array(90, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txSelectOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @return array
*/
public function txCommit()
{
$writer = new AMQPWriter();
return array(90, 20, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txCommitOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @return array
*/
public function txRollback()
{
$writer = new AMQPWriter();
return array(90, 30, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function txRollbackOk(AMQPReader $reader)
{
$response = array();
return $response;
}
/**
* @param bool $nowait
* @return array
*/
public function confirmSelect($nowait = false)
{
$writer = new AMQPWriter();
$writer->write_bits(array($nowait));
return array(85, 10, $writer);
}
/**
* @param AMQPReader $reader
* @return array
*/
public static function confirmSelectOk(AMQPReader $reader)
{
$response = array();
return $response;
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
class Wait080
{
/**
* @var array
*/
protected $wait = array(
'connection.start' => '10,10',
'connection.start_ok' => '10,11',
'connection.secure' => '10,20',
'connection.secure_ok' => '10,21',
'connection.tune' => '10,30',
'connection.tune_ok' => '10,31',
'connection.open' => '10,40',
'connection.open_ok' => '10,41',
'connection.redirect' => '10,50',
'connection.close' => '10,60',
'connection.close_ok' => '10,61',
'channel.open' => '20,10',
'channel.open_ok' => '20,11',
'channel.flow' => '20,20',
'channel.flow_ok' => '20,21',
'channel.alert' => '20,30',
'channel.close' => '20,40',
'channel.close_ok' => '20,41',
'access.request' => '30,10',
'access.request_ok' => '30,11',
'exchange.declare' => '40,10',
'exchange.declare_ok' => '40,11',
'exchange.delete' => '40,20',
'exchange.delete_ok' => '40,21',
'queue.declare' => '50,10',
'queue.declare_ok' => '50,11',
'queue.bind' => '50,20',
'queue.bind_ok' => '50,21',
'queue.purge' => '50,30',
'queue.purge_ok' => '50,31',
'queue.delete' => '50,40',
'queue.delete_ok' => '50,41',
'queue.unbind' => '50,50',
'queue.unbind_ok' => '50,51',
'basic.qos' => '60,10',
'basic.qos_ok' => '60,11',
'basic.consume' => '60,20',
'basic.consume_ok' => '60,21',
'basic.cancel' => '60,30',
'basic.cancel_ok' => '60,31',
'basic.publish' => '60,40',
'basic.return' => '60,50',
'basic.deliver' => '60,60',
'basic.get' => '60,70',
'basic.get_ok' => '60,71',
'basic.get_empty' => '60,72',
'basic.ack' => '60,80',
'basic.reject' => '60,90',
'basic.recover_async' => '60,100',
'basic.recover' => '60,110',
'basic.recover_ok' => '60,111',
'file.qos' => '70,10',
'file.qos_ok' => '70,11',
'file.consume' => '70,20',
'file.consume_ok' => '70,21',
'file.cancel' => '70,30',
'file.cancel_ok' => '70,31',
'file.open' => '70,40',
'file.open_ok' => '70,41',
'file.stage' => '70,50',
'file.publish' => '70,60',
'file.return' => '70,70',
'file.deliver' => '70,80',
'file.ack' => '70,90',
'file.reject' => '70,100',
'stream.qos' => '80,10',
'stream.qos_ok' => '80,11',
'stream.consume' => '80,20',
'stream.consume_ok' => '80,21',
'stream.cancel' => '80,30',
'stream.cancel_ok' => '80,31',
'stream.publish' => '80,40',
'stream.return' => '80,50',
'stream.deliver' => '80,60',
'tx.select' => '90,10',
'tx.select_ok' => '90,11',
'tx.commit' => '90,20',
'tx.commit_ok' => '90,21',
'tx.rollback' => '90,30',
'tx.rollback_ok' => '90,31',
'dtx.select' => '100,10',
'dtx.select_ok' => '100,11',
'dtx.start' => '100,20',
'dtx.start_ok' => '100,21',
'tunnel.request' => '110,10',
'test.integer' => '120,10',
'test.integer_ok' => '120,11',
'test.string' => '120,20',
'test.string_ok' => '120,21',
'test.table' => '120,30',
'test.table_ok' => '120,31',
'test.content' => '120,40',
'test.content_ok' => '120,41',
);
/**
* @var string $method
* @return string
*/
public function get_wait($method)
{
return $this->wait[$method];
}
}
<?php
/* This file was autogenerated by spec/parser.php - Do not modify */
namespace PhpAmqpLib\Helper\Protocol;
class Wait091
{
/**
* @var array
*/
protected $wait = array(
'connection.start' => '10,10',
'connection.start_ok' => '10,11',
'connection.secure' => '10,20',
'connection.secure_ok' => '10,21',
'connection.tune' => '10,30',
'connection.tune_ok' => '10,31',
'connection.open' => '10,40',
'connection.open_ok' => '10,41',
'connection.close' => '10,50',
'connection.close_ok' => '10,51',
'connection.blocked' => '10,60',
'connection.unblocked' => '10,61',
'channel.open' => '20,10',
'channel.open_ok' => '20,11',
'channel.flow' => '20,20',
'channel.flow_ok' => '20,21',
'channel.close' => '20,40',
'channel.close_ok' => '20,41',
'access.request' => '30,10',
'access.request_ok' => '30,11',
'exchange.declare' => '40,10',
'exchange.declare_ok' => '40,11',
'exchange.delete' => '40,20',
'exchange.delete_ok' => '40,21',
'exchange.bind' => '40,30',
'exchange.bind_ok' => '40,31',
'exchange.unbind' => '40,40',
'exchange.unbind_ok' => '40,51',
'queue.declare' => '50,10',
'queue.declare_ok' => '50,11',
'queue.bind' => '50,20',
'queue.bind_ok' => '50,21',
'queue.purge' => '50,30',
'queue.purge_ok' => '50,31',
'queue.delete' => '50,40',
'queue.delete_ok' => '50,41',
'queue.unbind' => '50,50',
'queue.unbind_ok' => '50,51',
'basic.qos' => '60,10',
'basic.qos_ok' => '60,11',
'basic.consume' => '60,20',
'basic.consume_ok' => '60,21',
'basic.cancel' => '60,30',
'basic.cancel_ok' => '60,31',
'basic.publish' => '60,40',
'basic.return' => '60,50',
'basic.deliver' => '60,60',
'basic.get' => '60,70',
'basic.get_ok' => '60,71',
'basic.get_empty' => '60,72',
'basic.ack' => '60,80',
'basic.reject' => '60,90',
'basic.recover_async' => '60,100',
'basic.recover' => '60,110',
'basic.recover_ok' => '60,111',
'basic.nack' => '60,120',
'tx.select' => '90,10',
'tx.select_ok' => '90,11',
'tx.commit' => '90,20',
'tx.commit_ok' => '90,21',
'tx.rollback' => '90,30',
'tx.rollback_ok' => '90,31',
'confirm.select' => '85,10',
'confirm.select_ok' => '85,11',
);
/**
* @var string $method
* @return string
*/
public function get_wait($method)
{
return $this->wait[$method];
}
}
<?php
namespace PhpAmqpLib\Helper;
/**
* @property-read int $SOCKET_EPIPE
* @property-read int $SOCKET_ENETDOWN
* @property-read int $SOCKET_ENETUNREACH
* @property-read int $SOCKET_ENETRESET
* @property-read int $SOCKET_ECONNABORTED
* @property-read int $SOCKET_ECONNRESET
* @property-read int $SOCKET_ECONNREFUSED
* @property-read int $SOCKET_ETIMEDOUT
* @property-read int $SOCKET_EWOULDBLOCK
* @property-read int $SOCKET_EINTR
* @property-read int $SOCKET_EAGAIN
*/
final class SocketConstants
{
/**
* @var int[]
*/
private $constants;
/** @var self */
private static $instance;
public function __construct()
{
$constants = get_defined_constants(true);
if (isset($constants['sockets'])) {
$this->constants = $constants['sockets'];
} else {
trigger_error('Sockets extension is not enabled', E_USER_WARNING);
$this->constants = array();
}
}
/**
* @param string $name
* @return int
*/
public function __get($name)
{
return isset($this->constants[$name]) ? $this->constants[$name] : 0;
}
/**
* @param string $name
* @param int $value
* @internal
*/
public function __set($name, $value)
{
}
/**
* @param string $name
* @return bool
*/
public function __isset($name)
{
return isset($this->constants[$name]);
}
/**
* @return self
*/
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
}
<?php
namespace PhpAmqpLib\Message;
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Exception\AMQPEmptyDeliveryTagException;
use PhpAmqpLib\Wire\AMQPReader;
use PhpAmqpLib\Wire\AMQPWriter;
/**
* A Message for use with the Channnel.basic_* methods.
*/
class AMQPMessage
{
const DELIVERY_MODE_NON_PERSISTENT = 1;
const DELIVERY_MODE_PERSISTENT = 2;
/** @var string */
public $body;
/** @var int */
public $body_size;
/** @var bool */
public $is_truncated = false;
/** @var string */
public $content_encoding;
/** @var int */
private $deliveryTag;
/** @var string|null */
private $consumerTag;
/** @var bool|null */
private $redelivered;
/** @var string|null */
private $exchange;
/** @var string|null */
private $routingKey;
/** @var int|null */
private $messageCount;
/** @var AMQPChannel|null */
private $channel;
/** @var bool */
private $responded = false;
/**
* @var array
* @internal
* @deprecated
*/
public $delivery_info = array();
/** @var array Properties content */
protected $properties = array();
/** @var null|string Compiled properties */
protected $serialized_properties;
/** @var array */
protected static $propertyDefinitions = array(
'content_type' => 'shortstr',
'content_encoding' => 'shortstr',
'application_headers' => 'table_object',
'delivery_mode' => 'octet',
'priority' => 'octet',
'correlation_id' => 'shortstr',
'reply_to' => 'shortstr',
'expiration' => 'shortstr',
'message_id' => 'shortstr',
'timestamp' => 'timestamp',
'type' => 'shortstr',
'user_id' => 'shortstr',
'app_id' => 'shortstr',
'cluster_id' => 'shortstr',
);
/**
* @param string $body
* @param array $properties
*/
public function __construct($body = '', $properties = array())
{
$this->setBody($body);
if (!empty($properties) && is_array($properties)) {
$this->properties = array_intersect_key($properties, self::$propertyDefinitions);
}
}
/**
* Acknowledge one or more messages.
*
* @param bool $multiple If true, the delivery tag is treated as "up to and including",
* so that multiple messages can be acknowledged with a single method.
* @since 2.12.0
* @link https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.ack
*/
public function ack($multiple = false)
{
$this->assertUnacked();
$this->channel->basic_ack($this->deliveryTag, $multiple);
$this->onResponse();
}
/**
* Reject one or more incoming messages.
*
* @param bool $requeue If true, the server will attempt to requeue the message. If requeue is false or the requeue
* attempt fails the messages are discarded or dead-lettered.
* @param bool $multiple If true, the delivery tag is treated as "up to and including",
* so that multiple messages can be rejected with a single method.
* @since 2.12.0
* @link https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.nack
*/
public function nack($requeue = false, $multiple = false)
{
$this->assertUnacked();
$this->channel->basic_nack($this->deliveryTag, $multiple, $requeue);
$this->onResponse();
}
/**
* Reject an incoming message.
*
* @param bool $requeue If requeue is true, the server will attempt to requeue the message.
* If requeue is false or the requeue attempt fails the messages are discarded or dead-lettered.
* @since 2.12.0
* @link https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.reject
*/
public function reject($requeue = true)
{
$this->assertUnacked();
$this->channel->basic_reject($this->deliveryTag, $requeue);
$this->onResponse();
}
/**
* @throws \LogicException When response to broker was already sent.
*/
protected function assertUnacked()
{
if (!$this->channel || $this->responded) {
throw new \LogicException('Message is not published or response was already sent');
}
}
protected function onResponse()
{
$this->responded = true;
}
/**
* @return AMQPChannel|null
* @since 2.12.0
*/
public function getChannel()
{
return $this->channel;
}
/**
* @param AMQPChannel $channel
* @return $this
* @throws \RuntimeException
* @since 2.12.0
*/
public function setChannel($channel)
{
if ($this->channel) {
throw new \RuntimeException('A message is already assigned to channel');
}
$this->channel = $channel;
$this->delivery_info['channel'] = $channel;
return $this;
}
/**
* @param int $deliveryTag
* @param bool $redelivered
* @param string $exchange
* @param string $routingKey
* @return $this
* @since 2.12.0
*/
public function setDeliveryInfo($deliveryTag, $redelivered, $exchange, $routingKey)
{
$this->deliveryTag = $this->delivery_info['delivery_tag'] = $deliveryTag;
$this->redelivered = $this->delivery_info['redelivered'] = $redelivered;
$this->exchange = $this->delivery_info['exchange'] = $exchange;
$this->routingKey = $this->delivery_info['routing_key'] = $routingKey;
return $this;
}
/**
* @return bool|null
* @since 2.12.0
*/
public function isRedelivered()
{
return $this->redelivered;
}
/**
* @return string|null
* @since 2.12.0
*/
public function getExchange()
{
return $this->exchange;
}
/**
* @return string|null
* @since 2.12.0
*/
public function getRoutingKey()
{
return $this->routingKey;
}
/**
* @return string|null
* @since 2.12.0
*/
public function getConsumerTag()
{
return $this->consumerTag;
}
/**
* @param string $consumerTag
* @return $this
* @since 2.12.0
*/
public function setConsumerTag($consumerTag)
{
$this->consumerTag = $consumerTag;
$this->delivery_info['consumer_tag'] = $consumerTag;
return $this;
}
/**
* @return int|null
* @since 2.12.0
*/
public function getMessageCount()
{
return $this->messageCount;
}
/**
* @param int $messageCount
* @return $this
* @since 2.12.0
*/
public function setMessageCount($messageCount)
{
$this->messageCount = (int)$messageCount;
$this->delivery_info['message_count'] = $this->messageCount;
return $this;
}
/**
* @return string
*/
public function getBody()
{
return $this->body;
}
/**
* Sets the message payload
*
* @param string $body
* @return $this
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* @return string
*/
public function getContentEncoding()
{
return $this->content_encoding;
}
/**
* @return int
*/
public function getBodySize()
{
return $this->body_size;
}
/**
* @param int $body_size Message body size in byte(s)
* @return AMQPMessage
*/
public function setBodySize($body_size)
{
$this->body_size = (int)$body_size;
return $this;
}
/**
* @return boolean
*/
public function isTruncated()
{
return $this->is_truncated;
}
/**
* @param bool $is_truncated
* @return AMQPMessage
*/
public function setIsTruncated($is_truncated)
{
$this->is_truncated = (bool)$is_truncated;
return $this;
}
/**
* @param int|string $deliveryTag
* @return $this
* @since 2.12.0
*/
public function setDeliveryTag($deliveryTag)
{
if (!empty($this->deliveryTag)) {
throw new \LogicException('Delivery tag cannot be changed');
}
$this->deliveryTag = $deliveryTag;
$this->delivery_info['delivery_tag'] = $deliveryTag;
return $this;
}
/**
* @return int
*
* @throws AMQPEmptyDeliveryTagException
*/
public function getDeliveryTag()
{
if (empty($this->deliveryTag)) {
throw new AMQPEmptyDeliveryTagException('This message was not delivered yet');
}
return $this->deliveryTag;
}
/**
* Check whether a property exists in the 'properties' dictionary
* or if present - in the 'delivery_info' dictionary.
*
* @param string $name
* @return bool
*/
public function has($name)
{
return isset($this->properties[$name]) || isset($this->delivery_info[$name]);
}
/**
* Look for additional properties in the 'properties' dictionary,
* and if present - the 'delivery_info' dictionary.
*
* @param string $name
* @return mixed|AMQPChannel
* @throws \OutOfBoundsException
*/
public function get($name)
{
if (isset($this->properties[$name])) {
return $this->properties[$name];
}
if (isset($this->delivery_info[$name])) {
return $this->delivery_info[$name];
}
throw new \OutOfBoundsException(sprintf(
'No "%s" property',
$name
));
}
/**
* Returns the properties content
*
* @return array
*/
public function get_properties()
{
return $this->properties;
}
/**
* Sets a property value
*
* @param string $name The property name (one of the property definition)
* @param mixed $value The property value
* @throws \OutOfBoundsException
*/
public function set($name, $value)
{
if (!array_key_exists($name, self::$propertyDefinitions)) {
throw new \OutOfBoundsException(sprintf(
'No "%s" property',
$name
));
}
if (isset($this->properties[$name]) && $this->properties[$name] === $value) {
// same value, nothing to do
return;
}
$this->properties[$name] = $value;
$this->serialized_properties = null;
}
/**
* Given the raw bytes containing the property-flags and
* property-list from a content-frame-header, parse and insert
* into a dictionary stored in this object as an attribute named
* 'properties'.
*
* @param AMQPReader $reader
* NOTE: do not mutate $reader
* @return $this
*/
public function load_properties(AMQPReader $reader)
{
// Read 16-bit shorts until we get one with a low bit set to zero
$flags = array();
while (true) {
$flag_bits = $reader->read_short();
$flags[] = $flag_bits;
if (($flag_bits & 1) === 0) {
break;
}
}
$shift = 0;
$data = array();
foreach (self::$propertyDefinitions as $key => $proptype) {
if ($shift === 0) {
if (!$flags) {
break;
}
$flag_bits = array_shift($flags);
$shift = 15;
}
if ($flag_bits & (1 << $shift)) {
$data[$key] = $reader->{'read_' . $proptype}();
}
$shift -= 1;
}
$this->properties = $data;
return $this;
}
/**
* Serializes the 'properties' attribute (a dictionary) into the
* raw bytes making up a set of property flags and a property
* list, suitable for putting into a content frame header.
*
* @return string
* @todo Inject the AMQPWriter to make the method easier to test
*/
public function serialize_properties()
{
if (!empty($this->serialized_properties)) {
return $this->serialized_properties;
}
$shift = 15;
$flag_bits = 0;
$flags = array();
$raw_bytes = new AMQPWriter();
foreach (self::$propertyDefinitions as $key => $prototype) {
$val = isset($this->properties[$key]) ? $this->properties[$key] : null;
// Very important: PHP type eval is weak, use the === to test the
// value content. Zero or false value should not be removed
if ($val === null) {
$shift -= 1;
continue;
}
if ($shift === 0) {
$flags[] = $flag_bits;
$flag_bits = 0;
$shift = 15;
}
$flag_bits |= (1 << $shift);
if ($prototype !== 'bit') {
$raw_bytes->{'write_' . $prototype}($val);
}
$shift -= 1;
}
$flags[] = $flag_bits;
$result = new AMQPWriter();
foreach ($flags as $flag_bits) {
$result->write_short($flag_bits);
}
$result->write($raw_bytes->getvalue());
$this->serialized_properties = $result->getvalue();
return $this->serialized_properties;
}
}
<?php
namespace PhpAmqpLib;
final class Package
{
public const NAME = 'AMQPLib';
public const VERSION = '3.5.1';
}
<?php
namespace PhpAmqpLib\Wire;
use PhpAmqpLib\Channel\AbstractChannel;
use PhpAmqpLib\Exception;
use PhpAmqpLib\Wire;
/**
* Iterator implemented for transparent integration with AMQPWriter::write_[array|table]()
*/
abstract class AMQPAbstractCollection implements \Iterator, \ArrayAccess
{
//protocol defines available field types and their corresponding symbols
const PROTOCOL_RBT = 'rabbit'; //pseudo proto
//Abstract data types
const T_INT_SHORTSHORT = 1;
const T_INT_SHORTSHORT_U = 2;
const T_INT_SHORT = 3;
const T_INT_SHORT_U = 4;
const T_INT_LONG = 5;
const T_INT_LONG_U = 6;
const T_INT_LONGLONG = 7;
const T_INT_LONGLONG_U = 8;
const T_DECIMAL = 9;
const T_TIMESTAMP = 10;
const T_VOID = 11;
const T_BOOL = 12;
const T_STRING_SHORT = 13;
const T_STRING_LONG = 14;
const T_ARRAY = 15;
const T_TABLE = 16;
const T_BYTES = 17;
const T_FLOAT = 18;
const T_DOUBLE = 19;
/**
* @var string
*/
private static $protocol;
/*
* Field types messy mess http://www.rabbitmq.com/amqp-0-9-1-errata.html#section_3
* Default behaviour is to use rabbitMQ compatible field-set
* Define AMQP_STRICT_FLD_TYPES=true to use strict AMQP instead
* @var array<int, string>
*/
private static $types_080 = array(
self::T_INT_LONG => 'I',
self::T_DECIMAL => 'D',
self::T_TIMESTAMP => 'T',
self::T_STRING_LONG => 'S',
self::T_TABLE => 'F'
);
/**
* @var array<int, string>
*/
private static $types_091 = array(
self::T_INT_SHORTSHORT => 'b',
self::T_INT_SHORTSHORT_U => 'B',
self::T_INT_SHORT => 'U',
self::T_INT_SHORT_U => 'u',
self::T_INT_LONG => 'I',
self::T_INT_LONG_U => 'i',
self::T_INT_LONGLONG => 'L',
self::T_INT_LONGLONG_U => 'l',
self::T_FLOAT => 'f',
self::T_DOUBLE => 'd',
self::T_DECIMAL => 'D',
self::T_TIMESTAMP => 'T',
self::T_VOID => 'V',
self::T_BOOL => 't',
self::T_STRING_SHORT => 's',
self::T_STRING_LONG => 'S',
self::T_ARRAY => 'A',
self::T_TABLE => 'F',
self::T_BYTES => 'x',
);
/**
* @var array<int, string>
*/
private static $types_rabbit = array(
self::T_INT_SHORTSHORT => 'b',
self::T_INT_SHORTSHORT_U => 'B',
self::T_INT_SHORT => 's',
self::T_INT_SHORT_U => 'u',
self::T_INT_LONG => 'I',
self::T_INT_LONG_U => 'i',
self::T_INT_LONGLONG => 'l',
self::T_FLOAT => 'f',
self::T_DOUBLE => 'd',
self::T_DECIMAL => 'D',
self::T_TIMESTAMP => 'T',
self::T_VOID => 'V',
self::T_BOOL => 't',
self::T_STRING_LONG => 'S',
self::T_ARRAY => 'A',
self::T_TABLE => 'F',
self::T_BYTES => 'x',
);
/**
* @var array
*/
protected $data = array();
public function __construct(array $data = null)
{
if (!empty($data)) {
$this->data = $this->encodeCollection($data);
}
}
/**
* @return int
*/
abstract public function getType();
/**
* @param mixed $val
* @param int|null $type
* @param string $key
*/
final protected function setValue($val, $type = null, $key = null)
{
if ($val instanceof self) {
if ($type && ($type !== $val->getType())) {
throw new Exception\AMQPInvalidArgumentException(
sprintf(
'Attempted to add instance of %s representing type [%s] as mismatching type [%s]',
get_class($val),
$val->getType(),
$type
)
);
}
$type = $val->getType();
} elseif ($type) { //ensuring data integrity and that all members are properly validated
switch ($type) {
case self::T_ARRAY:
throw new Exception\AMQPInvalidArgumentException('Arrays must be passed as AMQPArray instance');
case self::T_TABLE:
throw new Exception\AMQPInvalidArgumentException('Tables must be passed as AMQPTable instance');
case self::T_DECIMAL:
if (!($val instanceof AMQPDecimal)) {
throw new Exception\AMQPInvalidArgumentException(
'Decimal values must be instance of AMQPDecimal'
);
}
break;
}
}
if ($type) {
self::checkDataTypeIsSupported($type, false);
$val = array($type, $val);
} else {
$val = $this->encodeValue($val);
}
if ($key === null) {
$this->data[] = $val;
} else {
$this->data[$key] = $val;
}
}
/**
* @return array
*/
final public function getNativeData()
{
return $this->decodeCollection($this->data);
}
/**
* @param array $val
* @return array
*/
final protected function encodeCollection(array $val)
{
foreach ($val as $k => $v) {
$val[$k] = $this->encodeValue($v);
}
return $val;
}
/**
* @param array $val
* @return array
*/
final protected function decodeCollection(array $val)
{
foreach ($val as $k => $v) {
$val[$k] = $this->decodeValue($v[1], $v[0]);
}
return $val;
}
public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
/**
* @param mixed $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
$value = isset($this->data[$offset]) ? $this->data[$offset] : null;
return is_array($value) ? $value[1] : $value;
}
public function offsetSet($offset, $value): void
{
$this->setValue($value, null, $offset);
}
public function offsetUnset($offset): void
{
unset($this->data[$offset]);
}
/**
* @param mixed $val
* @return mixed
* @throws Exception\AMQPOutOfBoundsException
*/
protected function encodeValue($val)
{
if (is_string($val)) {
$val = $this->encodeString($val);
} elseif (is_float($val)) {
$val = $this->encodeFloat($val);
} elseif (is_int($val)) {
$val = $this->encodeInt($val);
} elseif (is_bool($val)) {
$val = $this->encodeBool($val);
} elseif (is_null($val)) {
$val = $this->encodeVoid();
} elseif ($val instanceof \DateTimeInterface) {
$val = array(self::T_TIMESTAMP, $val->getTimestamp());
} elseif ($val instanceof AMQPDecimal) {
$val = array(self::T_DECIMAL, $val);
} elseif ($val instanceof self) {
//avoid silent type correction of strictly typed values
self::checkDataTypeIsSupported($val->getType(), false);
$val = array($val->getType(), $val);
} elseif (is_array($val)) {
//AMQP specs says "Field names MUST start with a letter, '$' or '#'"
//so beware, some servers may raise an exception with 503 code in cases when indexed
// array is encoded as table
if (self::isProtocol(Wire\Constants080::VERSION)) {
//080 doesn't support arrays, forcing table
$val = array(self::T_TABLE, new AMQPTable($val));
} elseif (empty($val) || (array_keys($val) === range(0, count($val) - 1))) {
$val = array(self::T_ARRAY, new AMQPArray($val));
} else {
$val = array(self::T_TABLE, new AMQPTable($val));
}
} else {
throw new Exception\AMQPOutOfBoundsException(
sprintf('Encountered value of unsupported type: %s', gettype($val))
);
}
return $val;
}
/**
* @param mixed $val
* @param int $type
* @return array|bool|\DateTime|null
*/
protected function decodeValue($val, $type)
{
if ($val instanceof self) {
//covering arrays and tables
$val = $val->getNativeData();
} else {
switch ($type) {
case self::T_BOOL:
$val = (bool) $val;
break;
case self::T_TIMESTAMP:
$val = \DateTime::createFromFormat('U', $val);
break;
case self::T_VOID:
$val = null;
break;
case self::T_ARRAY:
case self::T_TABLE:
throw new Exception\AMQPLogicException(
sprintf(
'%s %s',
'Encountered an array/table struct which is not an instance of AMQPCollection.',
'This is considered a bug and should be fixed, please report'
)
);
}
}
return $val;
}
/**
* @param string $val
* @return array
*/
protected function encodeString($val)
{
return array(self::T_STRING_LONG, $val);
}
/**
* @param int $val
* @return array
*/
protected function encodeInt($val)
{
if (($val >= -2147483648) && ($val <= 2147483647)) {
$ev = array(self::T_INT_LONG, $val);
} elseif (self::isProtocol(Wire\Constants080::VERSION)) {
//080 doesn't support longlong
$ev = $this->encodeString((string) $val);
} else {
$ev = array(self::T_INT_LONGLONG, $val);
}
return $ev;
}
/**
* @param float $val
* @return array
*/
protected function encodeFloat($val)
{
return $this->encodeString((string) $val);
}
/**
* @param bool $val
* @return array
*/
protected function encodeBool($val)
{
$val = (bool) $val;
return self::isProtocol(Wire\Constants080::VERSION)
? array(self::T_INT_LONG, (int) $val)
: array(self::T_BOOL, $val);
}
/**
* @return array
*/
protected function encodeVoid()
{
return self::isProtocol(Wire\Constants080::VERSION) ? $this->encodeString('') : array(self::T_VOID, null);
}
/**
* @return string
*/
final public static function getProtocol()
{
if (self::$protocol === null) {
self::$protocol = defined('AMQP_STRICT_FLD_TYPES') && AMQP_STRICT_FLD_TYPES ?
AbstractChannel::getProtocolVersion() :
self::PROTOCOL_RBT;
}
return self::$protocol;
}
/**
* @param string $proto
* @return bool
*/
final public static function isProtocol($proto)
{
return self::getProtocol() === $proto;
}
/**
* @return array [dataTypeConstant => dataTypeSymbol]
*/
final public static function getSupportedDataTypes()
{
switch ($proto = self::getProtocol()) {
case Wire\Constants080::VERSION:
$types = self::$types_080;
break;
case Wire\Constants091::VERSION:
$types = self::$types_091;
break;
case self::PROTOCOL_RBT:
$types = self::$types_rabbit;
break;
default:
throw new Exception\AMQPOutOfRangeException(sprintf('Unknown protocol: %s', $proto));
}
return $types;
}
/**
* @param string $type
* @param bool $return Whether to return or raise AMQPOutOfRangeException
* @return boolean
*/
final public static function checkDataTypeIsSupported($type, $return = true)
{
try {
$supported = self::getSupportedDataTypes();
if (!isset($supported[$type])) {
throw new Exception\AMQPOutOfRangeException(sprintf(
'AMQP-%s doesn\'t support data of type [%s]',
self::getProtocol(),
$type
));
}
return true;
} catch (Exception\AMQPOutOfRangeException $ex) {
if (!$return) {
throw $ex;
}
return false;
}
}
/**
* @param int $type
* @return string
*/
final public static function getSymbolForDataType($type)
{
$types = self::getSupportedDataTypes();
if (!isset($types[$type])) {
throw new Exception\AMQPOutOfRangeException(sprintf(
'AMQP-%s doesn\'t support data of type [%s]',
self::getProtocol(),
$type
));
}
return $types[$type];
}
/**
* @param string $symbol
* @return integer
*/
final public static function getDataTypeForSymbol($symbol)
{
$symbols = array_flip(self::getSupportedDataTypes());
if (!isset($symbols[$symbol])) {
throw new Exception\AMQPOutOfRangeException(sprintf(
'AMQP-%s doesn\'t define data of type [%s]',
self::getProtocol(),
$symbol
));
}
return $symbols[$symbol];
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->data);
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
{
return key($this->data);
}
public function next(): void
{
next($this->data);
}
public function rewind(): void
{
reset($this->data);
}
public function valid(): bool
{
return key($this->data) !== null;
}
}