OCD API documentation updates

This commit is contained in:
Chris Boden 2013-01-05 16:10:21 -05:00
parent ba8289c7d9
commit f905e3ad1f
12 changed files with 70 additions and 57 deletions

View File

@ -49,8 +49,8 @@ class Validator {
} }
/** /**
* @param string The value to check the encoding * @param string $str The value to check the encoding
* @param string The type of encoding to check against * @param string $against The type of encoding to check against
* @return bool * @return bool
*/ */
public function checkEncoding($str, $against) { public function checkEncoding($str, $against) {

View File

@ -4,8 +4,8 @@ namespace Ratchet\WebSocket\Encoding;
interface ValidatorInterface { interface ValidatorInterface {
/** /**
* Verify a string matches the encoding type * Verify a string matches the encoding type
* @param string The string to check * @param string $str The string to check
* @param string The encoding type to check against * @param string $encoding The encoding type to check against
* @return bool * @return bool
*/ */
function checkEncoding($str, $encoding); function checkEncoding($str, $encoding);

View File

@ -20,10 +20,10 @@ class HttpRequestParser implements MessageInterface {
public $maxSize = 4096; public $maxSize = 4096;
/** /**
* @param Ratchet\ConnectionInterface * @param \Ratchet\ConnectionInterface $context
* @param string Data stream to buffer * @param string $data Data stream to buffer
* @return Guzzle\Http\Message\RequestInterface|null * @return \Guzzle\Http\Message\RequestInterface|null
* @throws OverflowException If the message buffer has become too large * @throws \OverflowException If the message buffer has become too large
*/ */
public function onMessage(ConnectionInterface $context, $data) { public function onMessage(ConnectionInterface $context, $data) {
if (!isset($context->httpBuffer)) { if (!isset($context->httpBuffer)) {
@ -47,7 +47,7 @@ class HttpRequestParser implements MessageInterface {
/** /**
* Determine if the message has been buffered as per the HTTP specification * Determine if the message has been buffered as per the HTTP specification
* @param string * @param string $message
* @return boolean * @return boolean
*/ */
public function isEom($message) { public function isEom($message) {

View File

@ -34,8 +34,8 @@ class Hixie76 implements VersionInterface {
} }
/** /**
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface $request
* @return Guzzle\Http\Message\Response * @return \Guzzle\Http\Message\Response
*/ */
public function handshake(RequestInterface $request) { public function handshake(RequestInterface $request) {
$body = $this->sign($request->getHeader('Sec-WebSocket-Key1', true), $request->getHeader('Sec-WebSocket-Key2', true), (string)$request->getBody()); $body = $this->sign($request->getHeader('Sec-WebSocket-Key1', true), $request->getHeader('Sec-WebSocket-Key2', true), (string)$request->getBody());

View File

@ -3,7 +3,7 @@ namespace Ratchet\WebSocket\Version;
interface MessageInterface extends DataInterface { interface MessageInterface extends DataInterface {
/** /**
* @param FragmentInterface * @param FrameInterface $fragment
* @return MessageInterface * @return MessageInterface
*/ */
function addFrame(FrameInterface $fragment); function addFrame(FrameInterface $fragment);

View File

@ -31,7 +31,7 @@ class RFC6455 implements VersionInterface {
private $closeCodes = array(); private $closeCodes = array();
/** /**
* @var Ratchet\WebSocket\Encoding\ValidatorInterface * @var \Ratchet\WebSocket\Encoding\ValidatorInterface
*/ */
protected $validator; protected $validator;
@ -78,8 +78,9 @@ class RFC6455 implements VersionInterface {
} }
/** /**
* @param Ratchet\ConnectionInterface * @param \Ratchet\ConnectionInterface $conn
* @return Ratchet\WebSocket\Version\RFC6455\Connection * @param \Ratchet\MessageInterface $coalescedCallback
* @return \Ratchet\WebSocket\Version\RFC6455\Connection
*/ */
public function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback) { public function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback) {
$upgraded = new Connection($conn); $upgraded = new Connection($conn);
@ -94,8 +95,8 @@ class RFC6455 implements VersionInterface {
} }
/** /**
* @param Ratchet\WebSocket\Version\RFC6455\Connection * @param \Ratchet\WebSocket\Version\RFC6455\Connection $from
* @param string * @param string $data
*/ */
public function onMessage(ConnectionInterface $from, $data) { public function onMessage(ConnectionInterface $from, $data) {
$overflow = ''; $overflow = '';
@ -214,6 +215,9 @@ class RFC6455 implements VersionInterface {
} }
/** /**
* @param string|null $payload
* @param bool|null $final
* @param int|null $opcode
* @return RFC6455\Frame * @return RFC6455\Frame
*/ */
public function newFrame($payload = null, $final = null, $opcode = null) { public function newFrame($payload = null, $final = null, $opcode = null) {
@ -222,7 +226,7 @@ class RFC6455 implements VersionInterface {
/** /**
* Used when doing the handshake to encode the key, verifying client/server are speaking the same language * Used when doing the handshake to encode the key, verifying client/server are speaking the same language
* @param string * @param string $key
* @return string * @return string
* @internal * @internal
*/ */

View File

@ -62,6 +62,12 @@ class Frame implements FrameInterface {
*/ */
protected $secondByte = -1; protected $secondByte = -1;
/**
* @param string|null $payload
* @param bool $final
* @param int $opcode
*/
public function __construct($payload = null, $final = true, $opcode = 1) { public function __construct($payload = null, $final = true, $opcode = 1) {
if (null === $payload) { if (null === $payload) {
return; return;
@ -136,7 +142,7 @@ class Frame implements FrameInterface {
/** /**
* @return boolean * @return boolean
* @throws UnderflowException * @throws \UnderflowException
*/ */
public function getRsv1() { public function getRsv1() {
if (-1 === $this->firstByte) { if (-1 === $this->firstByte) {
@ -148,7 +154,7 @@ class Frame implements FrameInterface {
/** /**
* @return boolean * @return boolean
* @throws UnderflowException * @throws \UnderflowException
*/ */
public function getRsv2() { public function getRsv2() {
if (-1 === $this->firstByte) { if (-1 === $this->firstByte) {
@ -160,7 +166,7 @@ class Frame implements FrameInterface {
/** /**
* @return boolean * @return boolean
* @throws UnderflowException * @throws \UnderflowException
*/ */
public function getRsv3() { public function getRsv3() {
if (-1 === $this->firstByte) { if (-1 === $this->firstByte) {
@ -215,8 +221,9 @@ class Frame implements FrameInterface {
/** /**
* Apply a mask to the payload * Apply a mask to the payload
* @param string|null If NULL is passed a masking key will be generated * @param string|null If NULL is passed a masking key will be generated
* @throws InvalidArgumentException If there is an issue with the given masking key * @throws \OutOfBoundsException
* @throws UnderflowException If the frame is not coalesced * @throws \InvalidArgumentException If there is an issue with the given masking key
* @return Frame
*/ */
public function maskPayload($maskingKey = null) { public function maskPayload($maskingKey = null) {
if (null === $maskingKey) { if (null === $maskingKey) {
@ -246,7 +253,7 @@ class Frame implements FrameInterface {
/** /**
* Remove a mask from the payload * Remove a mask from the payload
* @throws UnderFlowException If the frame is not coalesced * @throws \UnderFlowException If the frame is not coalesced
* @return Frame * @return Frame
*/ */
public function unMaskPayload() { public function unMaskPayload() {
@ -273,10 +280,10 @@ class Frame implements FrameInterface {
/** /**
* Apply a mask to a string or the payload of the instance * Apply a mask to a string or the payload of the instance
* @param string The 4 character masking key to be applied * @param string $maskingKey The 4 character masking key to be applied
* @param string|null A string to mask or null to use the payload * @param string|null $payload A string to mask or null to use the payload
* @throws UnderflowException If using the payload but enough hasn't been buffered * @throws \UnderflowException If using the payload but enough hasn't been buffered
* @return string The masked string * @return string The masked string
*/ */
public function applyMask($maskingKey, $payload = null) { public function applyMask($maskingKey, $payload = null) {
if (null === $payload) { if (null === $payload) {
@ -309,7 +316,7 @@ class Frame implements FrameInterface {
/** /**
* Gets the decimal value of bits 9 (10th) through 15 inclusive * Gets the decimal value of bits 9 (10th) through 15 inclusive
* @return int * @return int
* @throws UnderflowException If the buffer doesn't have enough data to determine this * @throws \UnderflowException If the buffer doesn't have enough data to determine this
*/ */
protected function getFirstPayloadVal() { protected function getFirstPayloadVal() {
if (-1 === $this->secondByte) { if (-1 === $this->secondByte) {
@ -321,7 +328,7 @@ class Frame implements FrameInterface {
/** /**
* @return int (7|23|71) Number of bits defined for the payload length in the fame * @return int (7|23|71) Number of bits defined for the payload length in the fame
* @throws UnderflowException * @throws \UnderflowException
*/ */
protected function getNumPayloadBits() { protected function getNumPayloadBits() {
if (-1 === $this->secondByte) { if (-1 === $this->secondByte) {

View File

@ -10,7 +10,7 @@ use Guzzle\Http\Message\RequestInterface;
class HandshakeVerifier { class HandshakeVerifier {
/** /**
* Given an array of the headers this method will run through all verification methods * Given an array of the headers this method will run through all verification methods
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface $request
* @return bool TRUE if all headers are valid, FALSE if 1 or more were invalid * @return bool TRUE if all headers are valid, FALSE if 1 or more were invalid
*/ */
public function verifyAll(RequestInterface $request) { public function verifyAll(RequestInterface $request) {
@ -78,7 +78,7 @@ class HandshakeVerifier {
/** /**
* Verify the Upgrade request to WebSockets. * Verify the Upgrade request to WebSockets.
* @param string MUST equal "websocket" * @param string $val MUST equal "websocket"
* @return bool * @return bool
*/ */
public function verifyUpgradeRequest($val) { public function verifyUpgradeRequest($val) {
@ -87,7 +87,7 @@ class HandshakeVerifier {
/** /**
* Verify the Connection header * Verify the Connection header
* @param string MUST equal "Upgrade" * @param string $val MUST equal "Upgrade"
* @return bool * @return bool
*/ */
public function verifyConnection($val) { public function verifyConnection($val) {

View File

@ -5,7 +5,7 @@ use Ratchet\WebSocket\Version\FrameInterface;
class Message implements MessageInterface, \Countable { class Message implements MessageInterface, \Countable {
/** /**
* @var SplDoublyLinkedList * @var \SplDoublyLinkedList
*/ */
protected $_frames; protected $_frames;

View File

@ -10,9 +10,9 @@ use Guzzle\Http\Message\RequestInterface;
interface VersionInterface extends MessageInterface { interface VersionInterface extends MessageInterface {
/** /**
* Given an HTTP header, determine if this version should handle the protocol * Given an HTTP header, determine if this version should handle the protocol
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface $request
* @return bool * @return bool
* @throws UnderflowException If the protocol thinks the headers are still fragmented * @throws \UnderflowException If the protocol thinks the headers are still fragmented
*/ */
function isProtocol(RequestInterface $request); function isProtocol(RequestInterface $request);
@ -24,16 +24,16 @@ interface VersionInterface extends MessageInterface {
/** /**
* Perform the handshake and return the response headers * Perform the handshake and return the response headers
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface $request
* @return Guzzle\Http\Message\Response * @return \Guzzle\Http\Message\Response
* @throws UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version) * @throws \UnderflowException If the message hasn't finished buffering (not yet implemented, theoretically will only happen with Hixie version)
*/ */
function handshake(RequestInterface $request); function handshake(RequestInterface $request);
/** /**
* @param Ratchet\ConnectionInterface * @param \Ratchet\ConnectionInterface $conn
* @param Ratchet\MessageInterface * @param \Ratchet\MessageInterface $coalescedCallback
* @return Ratchet\ConnectionInterface * @return \Ratchet\ConnectionInterface
*/ */
function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback); function upgradeConnection(ConnectionInterface $conn, MessageInterface $coalescedCallback);

View File

@ -22,8 +22,9 @@ class VersionManager {
/** /**
* Get the protocol negotiator for the request, if supported * Get the protocol negotiator for the request, if supported
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface $request
* @return Ratchet\WebSocket\Version\VersionInterface * @throws \InvalidArgumentException
* @return \Ratchet\WebSocket\Version\VersionInterface
*/ */
public function getVersion(RequestInterface $request) { public function getVersion(RequestInterface $request) {
foreach ($this->versions as $version) { foreach ($this->versions as $version) {
@ -36,7 +37,7 @@ class VersionManager {
} }
/** /**
* @param Guzzle\Http\Message\RequestInterface * @param \Guzzle\Http\Message\RequestInterface
* @return bool * @return bool
*/ */
public function isVersionEnabled(RequestInterface $request) { public function isVersionEnabled(RequestInterface $request) {
@ -51,8 +52,8 @@ class VersionManager {
/** /**
* Enable support for a specific version of the WebSocket protocol * Enable support for a specific version of the WebSocket protocol
* @param Ratchet\WebSocket\Version\VersionInterface * @param \Ratchet\WebSocket\Version\VersionInterface $version
* @return HandshakeNegotiator * @return VersionManager
*/ */
public function enableVersion(VersionInterface $version) { public function enableVersion(VersionInterface $version) {
$this->versions[$version->getVersionNumber()] = $version; $this->versions[$version->getVersionNumber()] = $version;
@ -68,8 +69,8 @@ class VersionManager {
/** /**
* Disable support for a specific WebSocket protocol version * Disable support for a specific WebSocket protocol version
* @param int The version ID to un-support * @param int $versionId The version ID to un-support
* @return HandshakeNegotiator * @return VersionManager
*/ */
public function disableVersion($versionId) { public function disableVersion($versionId) {
unset($this->versions[$versionId]); unset($this->versions[$versionId]);

View File

@ -29,12 +29,12 @@ class WsServer implements MessageComponentInterface {
/** /**
* Decorated component * Decorated component
* @var Ratchet\MessageComponentInterface * @var \Ratchet\MessageComponentInterface
*/ */
protected $_decorating; protected $_decorating;
/** /**
* @var SplObjectStorage * @var \SplObjectStorage
*/ */
protected $connections; protected $connections;
@ -47,7 +47,7 @@ class WsServer implements MessageComponentInterface {
/** /**
* UTF-8 validator * UTF-8 validator
* @var Ratchet\WebSocket\Encoding\ValidatorInterface * @var \Ratchet\WebSocket\Encoding\ValidatorInterface
*/ */
protected $validator; protected $validator;
@ -58,7 +58,7 @@ class WsServer implements MessageComponentInterface {
private $isSpGenerated = false; private $isSpGenerated = false;
/** /**
* @param Ratchet\MessageComponentInterface Your application to run with WebSockets * @param \Ratchet\MessageComponentInterface $component Your application to run with WebSockets
* If you want to enable sub-protocols have your component implement WsServerInterface as well * If you want to enable sub-protocols have your component implement WsServerInterface as well
*/ */
public function __construct(MessageComponentInterface $component) { public function __construct(MessageComponentInterface $component) {
@ -155,7 +155,7 @@ class WsServer implements MessageComponentInterface {
/** /**
* Disable a specific version of the WebSocket protocol * Disable a specific version of the WebSocket protocol
* @param int Version ID to disable * @param int $versionId Version ID to disable
* @return WsServer * @return WsServer
*/ */
public function disableVersion($versionId) { public function disableVersion($versionId) {
@ -192,7 +192,7 @@ class WsServer implements MessageComponentInterface {
} }
/** /**
* @param Traversable * @param \Traversable|null $requested
* @return string * @return string
*/ */
protected function getSubProtocolString(\Traversable $requested = null) { protected function getSubProtocolString(\Traversable $requested = null) {
@ -213,8 +213,9 @@ class WsServer implements MessageComponentInterface {
/** /**
* Close a connection with an HTTP response * Close a connection with an HTTP response
* @param Ratchet\ConnectionInterface * @param \Ratchet\ConnectionInterface $conn
* @param int HTTP status code * @param int $code HTTP status code
* @return void
*/ */
protected function close(ConnectionInterface $conn, $code = 400) { protected function close(ConnectionInterface $conn, $code = 400) {
$response = new Response($code, array( $response = new Response($code, array(