diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..28af77e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +*.php text eol=lf +/docs export-ignore +/tests export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.scrutinizer.yml export-ignore +.travis.yml export-ignore +README export-ignore +README.md export-ignore +CREDITS export-ignore +RELEASE-* export-ignore +extrasetup.php export-ignore +package.xml export-ignore +packagexmlsetup.php export-ignore +scanoptions.php export-ignore diff --git a/docs/sami.php b/docs/sami.php index 0bef04d..ab4df9d 100644 --- a/docs/sami.php +++ b/docs/sami.php @@ -1,6 +1,20 @@ + * @copyright 2011 Vasil Rangelov + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version GIT: $Id$ + * @link http://pear2.php.net/PEAR2_Net_Transmitter + */ + use Sami\Sami; -use Sami\Version\GitVersionCollection; use Symfony\Component\Finder\Finder; return new Sami( diff --git a/extrasetup.php b/extrasetup.php index f958de3..aabeafe 100644 --- a/extrasetup.php +++ b/extrasetup.php @@ -1,7 +1,7 @@ @@ -22,9 +22,9 @@ /** * A filter collection. - * + * * Represents a collection of stream filters. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -35,21 +35,25 @@ class FilterCollection implements \SeekableIterator, \Countable { /** - * @var array The filter collection itself. + * The filter collection itself. + * + * @var array */ protected $filters = array(); - + /** - * @var int A pointer, as required by SeekableIterator. + * A pointer, as required by SeekableIterator. + * + * @var int */ protected $position = 0; - + /** * Appends a filter to the collection - * + * * @param string $name The name of the filter. * @param array $params An array of parameters for the filter. - * + * * @return $this The collection itself. */ public function append($name, array $params = array()) @@ -57,19 +61,19 @@ public function append($name, array $params = array()) $this->filters[] = array((string) $name, $params); return $this; } - + /** * Inserts the filter before a position. - * + * * Inserts the specified filter before a filter at a specified position. The * new filter takes the specified position, while previous filters are moved * forward by one. - * + * * @param int $position The position before which the filter will be * inserted. * @param string $name The name of the filter. * @param array $params An array of parameters for the filter. - * + * * @return $this The collection itself. */ public function insertBefore($position, $name, array $params = array()) @@ -92,12 +96,12 @@ public function insertBefore($position, $name, array $params = array()) ); return $this; } - + /** * Removes a filter at a specified position. - * + * * @param int $position The position from which to remove a filter. - * + * * @return $this The collection itself. */ public function removeAt($position) @@ -106,10 +110,10 @@ public function removeAt($position) $this->filters = array_values($this->filters); return $this; } - + /** * Clears the collection - * + * * @return $this The collection itself. */ public function clear() @@ -120,7 +124,7 @@ public function clear() /** * Gets the number of filters in the collection. - * + * * @return int The number of filters in the collection. */ public function count() @@ -130,7 +134,7 @@ public function count() /** * Resets the pointer to 0. - * + * * @return bool TRUE if the collection is not empty, FALSE otherwise. */ public function rewind() @@ -140,9 +144,9 @@ public function rewind() /** * Moves the pointer to a specified position. - * + * * @param int $position The position to move to. - * + * * @return bool TRUE if the specified position is valid, FALSE otherwise. */ public function seek($position) @@ -150,10 +154,10 @@ public function seek($position) $this->position = $position; return $this->valid(); } - + /** * Gets the current position. - * + * * @return int The current position. */ public function getCurrentPosition() @@ -163,7 +167,7 @@ public function getCurrentPosition() /** * Moves the pointer forward by 1. - * + * * @return bool TRUE if the new position is valid, FALSE otherwise. */ public function next() @@ -174,7 +178,7 @@ public function next() /** * Gets the filter name at the current pointer position. - * + * * @return string|false The name of the filter at the current position. */ public function key() @@ -184,7 +188,7 @@ public function key() /** * Gets the filter parameters at the current pointer position. - * + * * @return array|false An array of parameters for the filter at the current * position, or FALSE if the position is not valid. */ @@ -195,7 +199,7 @@ public function current() /** * Moves the pointer backwards by 1. - * + * * @return bool TRUE if the new position is valid, FALSE otherwise. */ public function prev() @@ -206,7 +210,7 @@ public function prev() /** * Moves the pointer to the last valid position. - * + * * @return bool TRUE if the collection is not empty, FALSE otherwise. */ public function end() @@ -217,7 +221,7 @@ public function end() /** * Checks if the pointer is still pointing to an existing offset. - * + * * @return bool TRUE if the pointer is valid, FALSE otherwise. */ public function valid() diff --git a/src/PEAR2/Net/Transmitter/NetworkStream.php b/src/PEAR2/Net/Transmitter/NetworkStream.php index a3e6e59..cbea10b 100644 --- a/src/PEAR2/Net/Transmitter/NetworkStream.php +++ b/src/PEAR2/Net/Transmitter/NetworkStream.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -22,10 +22,10 @@ /** * A network transmitter. - * + * * This is a convenience wrapper for network streams. Used to ensure data * integrity. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -60,22 +60,27 @@ abstract class NetworkStream extends Stream * negotiated between 1.0 and 1.2). */ const CRYPTO_TLS = 'TLS'; - + /** - * @var string The type of stream. Can be either "_CLIENT" or "_SERVER". - * Used to complement the encryption type. Must be set by child classes - * for {@link setCrypto()} to work properly. + * The type of stream. Can be either "_CLIENT" or "_SERVER". + * + * Used to complement the encryption type. Must be set by child classes + * for {@link setCrypto()} to work properly. + * + * @var string */ protected $streamType = ''; /** - * @var string The current cryptography setting. + * The current cryptography setting. + * + * @var string */ protected $crypto = ''; /** * Wraps around the specified stream. - * + * * @param resource $stream The stream to wrap around. */ public function __construct($stream) @@ -85,7 +90,7 @@ public function __construct($stream) /** * Gets the current cryptography setting. - * + * * @return string One of this class' CRYPTO_* constants. */ public function getCrypto() @@ -95,10 +100,10 @@ public function getCrypto() /** * Sets the current connection's cryptography setting. - * + * * @param string $type The encryption type to set. Must be one of this * class' CRYPTO_* constants. - * + * * @return boolean TRUE on success, FALSE on failure. */ public function setCrypto($type) @@ -121,7 +126,7 @@ public function setCrypto($type) /** * Checks whether the stream is available for operations. - * + * * @return bool TRUE if the stream is available, FALSE otherwise. */ public function isAvailable() @@ -135,14 +140,14 @@ public function isAvailable() } return false; } - + /** * Sets the size of a stream's buffer. - * + * * @param int $size The desired size of the buffer, in bytes. * @param int $direction The buffer of which direction to set. Valid * values are the DIRECTION_* constants. - * + * * @return bool TRUE on success, FALSE on failure. */ public function setBuffer($size, $direction = self::DIRECTION_ALL) @@ -155,15 +160,15 @@ public function setBuffer($size, $direction = self::DIRECTION_ALL) } return $result; } - + /** * Shutdown a full-duplex connection - * + * * Shutdowns (partially or not) a full-duplex connection. - * + * * @param int $direction The direction for which to disable further * communications. - * + * * @return bool TRUE on success, FALSE on failure. */ public function shutdown($direction = self::DIRECTION_ALL) diff --git a/src/PEAR2/Net/Transmitter/SocketException.php b/src/PEAR2/Net/Transmitter/SocketException.php index a7e134b..299b30f 100644 --- a/src/PEAR2/Net/Transmitter/SocketException.php +++ b/src/PEAR2/Net/Transmitter/SocketException.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -27,7 +27,7 @@ /** * Exception thrown when something goes wrong with the connection. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -38,18 +38,22 @@ class SocketException extends StreamException { /** - * @var int The system level error code. + * The system level error code. + * + * @var int */ protected $errorNo; /** - * @var string The system level error message. + * The system level error message. + * + * @var string */ protected $errorStr; /** * Creates a new socket exception. - * + * * @param string $message The Exception message to throw. * @param int $code The Exception code. * @param E|null $previous Previous exception thrown, @@ -80,7 +84,7 @@ public function __construct( /** * Gets the system level error code on the socket. - * + * * @return int The system level error number. */ public function getSocketErrorNumber() @@ -93,7 +97,7 @@ public function getSocketErrorNumber() /** * Gets the system level error message on the socket. - * + * * @return string The system level error message. */ public function getSocketErrorMessage() @@ -103,7 +107,7 @@ public function getSocketErrorMessage() /** * Returns a string representation of the exception. - * + * * @return string The exception as a string. */ public function __toString() diff --git a/src/PEAR2/Net/Transmitter/Stream.php b/src/PEAR2/Net/Transmitter/Stream.php index 81ca58f..8be5c39 100644 --- a/src/PEAR2/Net/Transmitter/Stream.php +++ b/src/PEAR2/Net/Transmitter/Stream.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -24,11 +24,11 @@ /** * A stream transmitter. - * + * * This is a convenience wrapper for stream functionality. Used to ensure data * integrity. Designed for TCP sockets, but it has intentionally been made to * accept any stream. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -55,32 +55,44 @@ class Stream const DIRECTION_ALL = 3; /** - * @var resource The stream to wrap around. + * The stream to wrap around. + * + * @var resource */ protected $stream; /** - * @var bool Whether to automatically close the stream on - * object destruction if it's not a persistent one. Setting this to - * FALSE may be useful if you're only using this class "part time", - * while setting it to TRUE might be useful if you're doing some - * "on offs". + * Whether to automatically close the stream on object destruction if + * it's not a persistent one. + * + * Setting this to FALSE may be useful if you're only using this class + * "part time", while setting it to TRUE might be useful if you're doing + * some "one offs". + * + * @var bool */ protected $autoClose = false; /** - * @var bool A flag that tells whether or not the stream is persistent. + * A flag that tells whether or not the stream is persistent. + * + * @var bool */ protected $persist; /** - * @var bool Whether the wrapped stream is in blocking mode or not. + * Whether the wrapped stream is in blocking mode or not. + * + * @var bool */ protected $isBlocking = true; - + /** - * @var array An associative array with the chunk size of each direction. - * Key is the direction, value is the size in bytes as integer. + * An associative array with the chunk size of each direction. + * + * Key is the direction, value is the size in bytes as integer. + * + * @var array */ protected $chunkSize = array( self::DIRECTION_SEND => 0xFFFFF, self::DIRECTION_RECEIVE => 0xFFFFF @@ -88,14 +100,14 @@ class Stream /** * Wraps around the specified stream. - * + * * @param resource $stream The stream to wrap around. * @param bool $autoClose Whether to automatically close the stream on * object destruction if it's not a persistent one. Setting this to * FALSE may be useful if you're only using this class "part time", * while setting it to TRUE might be useful if you're doing some * "on offs". - * + * * @see static::isFresh() */ public function __construct($stream, $autoClose = false) @@ -115,12 +127,14 @@ public function __construct($stream, $autoClose = false) /** * PHP error handler for connection errors. - * + * * @param string $level Level of PHP error raised. Ignored. * @param string $message Message raised by PHP. - * + * * @return void + * * @throws SocketException That's how the error is handled. + * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function handleError($level, $message) @@ -130,9 +144,9 @@ protected function handleError($level, $message) /** * Checks if a given variable is a stream resource. - * + * * @param mixed $var The variable to check. - * + * * @return bool TRUE on success, FALSE on failure. */ public static function isStream($var) @@ -143,11 +157,11 @@ public static function isStream($var) /** * Checks whether the wrapped stream is fresh. - * + * * Checks whether the wrapped stream is fresh. A stream is considered fresh * if there hasn't been any activity on it. Particularly useful for * detecting reused persistent connections. - * + * * @return bool TRUE if the socket is fresh, FALSE otherwise. */ public function isFresh() @@ -157,8 +171,8 @@ public function isFresh() /** * Checks whether the wrapped stream is a persistent one. - * - * @return bool TRUE if the stream is a persistent one, FALSE otherwise. + * + * @return bool TRUE if the stream is a persistent one, FALSE otherwise. */ public function isPersistent() { @@ -167,8 +181,8 @@ public function isPersistent() /** * Checks whether the wrapped stream is a blocking one. - * - * @return bool TRUE if the stream is a blocking one, FALSE otherwise. + * + * @return bool TRUE if the stream is a blocking one, FALSE otherwise. */ public function isBlocking() { @@ -177,9 +191,9 @@ public function isBlocking() /** * Sets blocking mode. - * + * * @param bool $block Sets whether the stream is in blocking mode. - * + * * @return bool TRUE on success, FALSE on failure. */ public function setIsBlocking($block) @@ -191,28 +205,28 @@ public function setIsBlocking($block) } return false; } - + /** * Sets the timeout for the stream. - * + * * @param int $seconds Timeout in seconds. * @param int $microseconds Timeout in microseconds to be added to the * seconds. - * + * * @return bool TRUE on success, FALSE on failure. */ public function setTimeout($seconds, $microseconds = 0) { return stream_set_timeout($this->stream, $seconds, $microseconds); } - + /** * Sets the size of a stream's buffer. - * + * * @param int $size The desired size of the buffer, in bytes. * @param int $direction The buffer of which direction to set. Valid * values are the DIRECTION_* constants. - * + * * @return bool TRUE on success, FALSE on failure. */ public function setBuffer($size, $direction = self::DIRECTION_ALL) @@ -228,18 +242,18 @@ public function setBuffer($size, $direction = self::DIRECTION_ALL) } return false; } - + /** * Sets the size of the chunk. - * + * * To ensure data integrity, as well as to allow for lower memory * consumption, data is sent/received in chunks. This function * allows you to set the size of each chunk. The default is 0xFFFFF. - * + * * @param int $size The desired size of the chunk, in bytes. * @param int $direction The chunk of which direction to set. Valid * values are the DIRECTION_* constants. - * + * * @return bool TRUE on success, FALSE on failure. */ public function setChunk($size, $direction = self::DIRECTION_ALL) @@ -260,13 +274,13 @@ public function setChunk($size, $direction = self::DIRECTION_ALL) } return false; } - + /** * Gets the size of the chunk. - * + * * @param int $direction The chunk of which direction to get. Valid * values are the DIRECTION_* constants. - * + * * @return int|array|false The chunk size in bytes, * or an array of chunk sizes with the directions as keys. * FALSE on invalid direction. @@ -285,18 +299,18 @@ public function getChunk($direction = self::DIRECTION_ALL) /** * Sends a string or stream over the wrapped stream. - * + * * Sends a string or stream over the wrapped stream. If a seekable stream is * provided, it will be seeked back to the same position it was passed as, * regardless of the $offset parameter. - * + * * @param string|resource $contents The string or stream to send. * @param int $offset The offset from which to start sending. * If a stream is provided, and this is set to NULL, sending will start * from the current stream position. * @param int $length The maximum length to send. If omitted, * the string/stream will be sent to its end. - * + * * @return int The number of bytes sent. */ public function send($contents, $offset = null, $length = null) @@ -375,13 +389,13 @@ public function send($contents, $offset = null, $length = null) /** * Reads from the wrapped stream to receive. - * + * * Reads from the wrapped stream to receive content as a string. - * + * * @param int $length The number of bytes to receive. * @param string $what Descriptive string about what is being received * (used in exception messages). - * + * * @return string The received content. */ public function receive($length, $what = 'data') @@ -412,16 +426,16 @@ public function receive($length, $what = 'data') /** * Reads from the wrapped stream to receive. - * + * * Reads from the wrapped stream to receive content as a stream. - * + * * @param int $length The number of bytes to receive. * @param FilterCollection $filters A collection of filters to apply to the * stream while receiving. Note that the filters will not be present on * the stream after receiving is done. * @param string $what Descriptive string about what is being * received (used in exception messages). - * + * * @return resource The received content. */ public function receiveStream( @@ -441,7 +455,7 @@ public function receiveStream( ); } } - + $chunkSize = $this->chunkSize[self::DIRECTION_RECEIVE]; while ($length > 0) { while ($this->isAvailable()) { @@ -477,10 +491,10 @@ public function receiveStream( /** * Checks whether the stream is available for operations. - * + * * For network streams, this means whether the other end has closed the * connection. - * + * * @return bool TRUE if the stream is available, FALSE otherwise. */ public function isAvailable() @@ -490,13 +504,14 @@ public function isAvailable() /** * Checks whether there is data to be read from the wrapped stream. - * + * * @param int|null $sTimeout If there isn't data awaiting currently, * wait for it this many seconds for data to arrive. If NULL is * specified, wait indefinitely for that. * @param int $usTimeout Microseconds to add to the waiting time. - * + * * @return bool TRUE if there is data to be read, FALSE otherwise. + * * @SuppressWarnings(PHPMD.ShortVariable) */ public function isDataAwaiting($sTimeout = 0, $usTimeout = 0) @@ -522,7 +537,7 @@ public function isDataAwaiting($sTimeout = 0, $usTimeout = 0) /** * Checks whether the wrapped stream can be written to without a block. - * + * * @param int|null $sTimeout If the stream isn't currently accepting data, * wait for it this many seconds to start accepting data. If NULL is * specified, wait indefinitely for that. @@ -530,6 +545,7 @@ public function isDataAwaiting($sTimeout = 0, $usTimeout = 0) * * @return bool TRUE if the wrapped stream would not block on a write, * FALSE otherwise. + * * @SuppressWarnings(PHPMD.ShortVariable) */ public function isAcceptingData($sTimeout = 0, $usTimeout = 0) @@ -567,7 +583,7 @@ public function __destruct() /** * Closes the opened stream, even if it is a persistent one. - * + * * @return bool TRUE on success, FALSE on failure. */ public function close() @@ -577,10 +593,10 @@ public function close() /** * Creates a new exception. - * + * * Creates a new exception. Used by the rest of the functions in this class. * Override in derived classes for custom exception handling. - * + * * @param string $message The exception message. * @param int $code The exception code. * @param E|null $previous Previous exception thrown, @@ -591,7 +607,7 @@ public function close() * successfully before the failure. * On failure when receiving, this is a string/stream holding * the contents received successfully before the failure. - * + * * @return StreamException The exception to then be thrown. */ protected function createException( diff --git a/src/PEAR2/Net/Transmitter/StreamException.php b/src/PEAR2/Net/Transmitter/StreamException.php index f11d1d2..e787b1f 100644 --- a/src/PEAR2/Net/Transmitter/StreamException.php +++ b/src/PEAR2/Net/Transmitter/StreamException.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -32,7 +32,7 @@ /** * Exception thrown when something goes wrong with the connection. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -42,18 +42,21 @@ class StreamException extends RuntimeException implements Exception { /** - * @var int|string|resource|null The fragment up until the point of failure. - * On failure with sending, this is the number of bytes sent - * successfully before the failure. - * On failure when receiving, this is a string/stream holding - * the contents received successfully before the failure. - * NULL if the failure occurred before the operation started. + * The fragment up until the point of failure. + * + * On failure with sending, this is the number of bytes sent successfully + * before the failure. + * On failure when receiving, this is a string/stream holding the contents + * received successfully before the failure. + * NULL if the failure occurred before the operation started. + * + * @var int|string|resource|null */ protected $fragment = null; /** * Creates a new stream exception. - * + * * @param string $message The Exception message to throw. * @param int $code The Exception code. * @param E|null $previous Previous exception thrown, @@ -78,7 +81,7 @@ public function __construct( /** * Gets the stream fragment. - * + * * @return int|string|resource|null The fragment up until the * point of failure. * On failure with sending, this is the number of bytes sent @@ -97,7 +100,7 @@ public function getFragment() /** * Returns a string representation of the exception. - * + * * @return string The exception as a string. */ public function __toString() diff --git a/src/PEAR2/Net/Transmitter/TcpClient.php b/src/PEAR2/Net/Transmitter/TcpClient.php index d2691b5..2c08b5f 100644 --- a/src/PEAR2/Net/Transmitter/TcpClient.php +++ b/src/PEAR2/Net/Transmitter/TcpClient.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -33,10 +33,10 @@ /** * A socket transmitter. - * + * * This is a convenience wrapper for socket functionality. Used to ensure data * integrity. - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -47,29 +47,40 @@ class TcpClient extends NetworkStream { /** - * @var int The error code of the last error on the socket. + * The error code of the last error on the socket. + * + * @var int */ protected $errorNo = 0; /** - * @var string The error message of the last error on the socket. + * The error message of the last error on the socket. + * + * @var string */ protected $errorStr = null; - + /** - * @var SHM Persistent connection handler. Remains NULL for non-persistent - * connections. + * Persistent connection handler. + * + * Remains NULL for non-persistent connections. + * + * @var SHM */ protected $shmHandler = null; - + /** - * @var array An array with all connections from this PHP request (as keys) - * and their lock state (as a value). + * An array with all connections from this PHP request (as keys) + * and their lock state (as a value). + * + * @var array */ protected static $lockState = array(); /** - * @var array Mappings from a protocol name to an URI scheme. + * Mappings from a protocol name to an URI scheme. + * + * @var array */ protected static $cryptoScheme = array( parent::CRYPTO_OFF => 'tcp', @@ -78,15 +89,17 @@ class TcpClient extends NetworkStream parent::CRYPTO_SSL => 'ssl', parent::CRYPTO_TLS => 'tls' ); - + /** - * @var string The URI of this connection. + * The URI of this connection. + * + * @var string */ protected $uri; /** * Creates a new connection with the specified options. - * + * * @param string $host Hostname (IP or domain) of the server. * @param int $port The port on the server. * @param bool $persist Whether or not the connection should be a @@ -184,9 +197,9 @@ public function __construct( /** * Creates a new exception. - * + * * Creates a new exception. Used by the rest of the functions in this class. - * + * * @param string $message The exception message. * @param int $code The exception code. * @param E|null $previous Previous exception thrown, @@ -197,7 +210,7 @@ public function __construct( * successfully before the failure. * On failure when receiving, this is a string/stream holding * the contents received successfully before the failure. - * + * * @return SocketException The exception to then be thrown. */ protected function createException( @@ -215,16 +228,16 @@ protected function createException( $this->errorStr ); } - + /** * Locks transmission. - * + * * Locks transmission in one or more directions. Useful when dealing with * persistent connections. Note that every send/receive call implicitly * calls this function and then restores it to the previous state. You only * need to call this function if you need to do an uninterrupted sequence of * such calls. - * + * * @param int $direction The direction(s) to have locked. Acceptable values * are the DIRECTION_* constants. If a lock for a direction can't be * obtained immediately, the function will block until one is acquired. @@ -235,7 +248,7 @@ protected function createException( * @param bool $replace Whether to replace all locks with the specified * ones. Setting this to FALSE will make the function only obtain the * locks which are not already obtained. - * + * * @return int|false The previous state or FALSE if the connection is not * persistent or arguments are invalid. */ @@ -261,7 +274,7 @@ public function lock($direction = self::DIRECTION_ALL, $replace = false) throw new LockException('Unable to release sending lock.'); } } - + try { if ($direction & self::DIRECTION_RECEIVE) { if (($old & self::DIRECTION_RECEIVE) @@ -338,13 +351,13 @@ public function send($contents, $offset = null, $length = null) /** * Receives data from the server. - * + * * Receives data from the server as a string. - * + * * @param int $length The number of bytes to receive. * @param string $what Descriptive string about what is being received * (used in exception messages). - * + * * @return string The received content. */ public function receive($length, $what = 'data') @@ -369,16 +382,16 @@ public function receive($length, $what = 'data') /** * Receives data from the server. - * + * * Receives data from the server as a stream. - * + * * @param int $length The number of bytes to receive. * @param FilterCollection $filters A collection of filters to apply to the * stream while receiving. Note that the filters will not be present on * the stream after receiving is done. * @param string $what Descriptive string about what is being * received (used in exception messages). - * + * * @return resource The received content. */ public function receiveStream( diff --git a/src/PEAR2/Net/Transmitter/TcpServerConnection.php b/src/PEAR2/Net/Transmitter/TcpServerConnection.php index 7df7eee..419478c 100644 --- a/src/PEAR2/Net/Transmitter/TcpServerConnection.php +++ b/src/PEAR2/Net/Transmitter/TcpServerConnection.php @@ -2,11 +2,11 @@ /** * ~~summary~~ - * + * * ~~description~~ - * + * * PHP version 5 - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -24,12 +24,12 @@ /** * A transmitter for connections to a socket server. - * + * * This is a convenience wrapper for functionality of socket server connections. * Used to ensure data integrity. Server handling is not part of the class in * order to allow its usage as part of various server implementations (e.g. fork * and/or sequential). - * + * * @category Net * @package PEAR2_Net_Transmitter * @author Vasil Rangelov @@ -40,18 +40,22 @@ class TcpServerConnection extends NetworkStream { /** - * @var string The IP address of the connected client. + * The IP address of the connected client. + * + * @var string */ protected $peerIP; /** - * @var int The port of the connected client. + * The port of the connected client. + * + * @var int */ protected $peerPort; /** * Creates a new connection with the specified options. - * + * * @param resource $server A socket server, created with * {@link stream_socket_server()}. * @param float|null $timeout The timeout for the connection. Leaving this @@ -95,20 +99,20 @@ public function __construct($server, $timeout = null) ); } } - + /** * Gets the IP address of the connected client. - * + * * @return string The IP address of the connected client. */ public function getPeerIP() { return $this->peerIP; } - + /** * Gets the port of the connected client. - * + * * @return int The port of the connected client. */ public function getPeerPort() @@ -118,16 +122,16 @@ public function getPeerPort() /** * Creates a new exception. - * + * * Creates a new exception. Used by the rest of the functions in this class. - * + * * @param string $message The exception message. * @param int $code The exception code. * @param E|null $previous Previous exception thrown, or NULL if there * is none. * @param string|null $fragment The fragment up until the point of failure. * NULL if the failure occurred before the operation started. - * + * * @return SocketException The exception to then be thrown. */ protected function createException(