Skip to content

Commit

Permalink
Reduce redundant else-branching (after throws), add missing @throws a…
Browse files Browse the repository at this point in the history
…nnotations
  • Loading branch information
kay.stenschke committed Sep 7, 2020
1 parent c02f8e3 commit 5e8bb2e
Show file tree
Hide file tree
Showing 36 changed files with 453 additions and 328 deletions.
59 changes: 40 additions & 19 deletions library/Zend/Amf/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public function isProduction()
/**
* @param namespace of all incoming sessions defaults to Zend_Amf
* @return Zend_Amf_Server
* @throws Zend_Session_Exception
*/
public function setSession($namespace = 'Zend_Amf')
{
Expand All @@ -235,7 +236,9 @@ public function isSession()
*
* @param string|object $object Object or class being accessed
* @param string $function Function or method being accessed
* @return unknown_type
* @return bool
* @throws Zend_Acl_Exception
* @throws Zend_Amf_Server_Exception
*/
protected function _checkAcl($object, $function)
{
Expand Down Expand Up @@ -294,10 +297,13 @@ protected function getLoader()
* Loads a remote class or method and executes the function and returns
* the result
*
* @param string $method Is the method to execute
* @param mixed $param values for the method
* @param string $method Is the method to execute
* @param null $params
* @param null $source
* @return mixed $response the result of executing the method
* @throws Zend_Acl_Exception
* @throws Zend_Amf_Server_Exception
* @throws Zend_Server_Reflection_Exception
*/
protected function _dispatch($method, $params = null, $source = null)
{
Expand Down Expand Up @@ -380,9 +386,11 @@ protected function _dispatch($method, $params = null, $source = null)
*
* A command message is a flex.messaging.messages.CommandMessage
*
* @see Zend_Amf_Value_Messaging_CommandMessage
* @param Zend_Amf_Value_Messaging_CommandMessage $message
* @param Zend_Amf_Value_Messaging_CommandMessage $message
* @return Zend_Amf_Value_Messaging_AcknowledgeMessage
* @throws Zend_Amf_Server_Exception
* @throws Zend_Session_Exception
* @see Zend_Amf_Value_Messaging_CommandMessage
*/
protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
{
Expand Down Expand Up @@ -459,6 +467,8 @@ protected function _errorMessage($objectEncoding, $message, $description, $detai
* @param string $userid
* @param string $password
* @return boolean
* @throws Zend_Amf_Server_Exception
* @throws Zend_Session_Exception
*/
protected function _handleAuth( $userid, $password)
{
Expand Down Expand Up @@ -486,11 +496,11 @@ protected function _handleAuth( $userid, $password)
/**
* Takes the deserialized AMF request and performs any operations.
*
* @todo should implement and SPL observer pattern for custom AMF headers
* @param Zend_Amf_Request $request
* @return void
* @throws Zend_Amf_Server_Exception
* @todo DescribeService support
* @param Zend_Amf_Request $request
* @return Zend_Amf_Response
* @throws Zend_Amf_server_Exception|Exception
* @todo should implement and SPL observer pattern for custom AMF headers
*/
protected function _handle(Zend_Amf_Request $request)
{
Expand Down Expand Up @@ -635,8 +645,9 @@ protected function _handle(Zend_Amf_Request $request)
/**
* Handle an AMF call from the gateway.
*
* @param null|Zend_Amf_Request $request Optional
* @param null|Zend_Amf_Request $request Optional
* @return Zend_Amf_Response
* @throws Zend_Amf_Server_Exception
*/
public function handle($request = null)
{
Expand Down Expand Up @@ -672,8 +683,9 @@ public function handle($request = null)
/**
* Set request object
*
* @param string|Zend_Amf_Request $request
* @param string|Zend_Amf_Request $request
* @return Zend_Amf_Server
* @throws Zend_Amf_Server_Exception
*/
public function setRequest($request)
{
Expand All @@ -695,6 +707,7 @@ public function setRequest($request)
* Return currently registered request object
*
* @return null|Zend_Amf_Request
* @throws Zend_Amf_Server_Exception
*/
public function getRequest()
{
Expand All @@ -709,8 +722,9 @@ public function getRequest()
/**
* Public access method to private Zend_Amf_Server_Response reference
*
* @param string|Zend_Amf_Server_Response $response
* @param string|Zend_Amf_Server_Response $response
* @return Zend_Amf_Server
* @throws Zend_Amf_Server_Exception
*/
public function setResponse($response)
{
Expand All @@ -732,6 +746,7 @@ public function setResponse($response)
* get a reference to the Zend_Amf_response instance
*
* @return Zend_Amf_Server_Response
* @throws Zend_Amf_Server_Exception
*/
public function getResponse()
{
Expand All @@ -751,18 +766,21 @@ public function getResponse()
* a $namespace has been provided, that namespace is used to prefix
* AMF service call.
*
* @param string|object $class
* @param string $namespace Optional
* @param mixed $arg Optional arguments to pass to a method
* @param string|object $class
* @param string $namespace Optional
* @param mixed $arg Optional arguments to pass to a method
* @return Zend_Amf_Server
* @throws Zend_Amf_Server_Exception on invalid input
* @throws Zend_Server_Reflection_Exception
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)){
if (is_string($class) && !class_exists($class)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Invalid method or class');
} elseif (!is_string($class) && !is_object($class)) {
}

if (!is_string($class) && !is_object($class)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Invalid method or class; must be a classname or object');
}
Expand Down Expand Up @@ -793,10 +811,11 @@ public function setClass($class, $namespace = '', $argv = null)
* any arguments following the namespace will be aggregated and passed at
* dispatch time.
*
* @param string|array $function Valid callback
* @param string $namespace Optional namespace prefix
* @param string|array $function Valid callback
* @param string $namespace Optional namespace prefix
* @return Zend_Amf_Server
* @throws Zend_Amf_Server_Exception
* @throws Zend_Server_Reflection_Exception
*/
public function addFunction($function, $namespace = '')
{
Expand Down Expand Up @@ -829,6 +848,7 @@ public function addFunction($function, $namespace = '')
* TODO: add support for prefixes?
*
* @param string $dir
* @throws Zend_Loader_PluginLoader_Exception
*/
public function addDirectory($dir)
{
Expand All @@ -852,6 +872,7 @@ public function getDirectory()
* Zend_Server_Reflection_Function_Abstract pairs
*
* @return void
* @throws Zend_Amf_Server_Exception
*/
protected function _buildDispatchTable()
{
Expand Down
7 changes: 6 additions & 1 deletion library/Zend/Application/Resource/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function init()
* @return Zend_Translate
* @throws Zend_Application_Resource_Exception if registry key was used
* already but is no instance of Zend_Translate
* @throws Zend_Exception
* @throws Zend_Log_Exception
* @throws Zend_Translate_Exception
*/
public function getTranslate()
{
Expand All @@ -70,7 +73,9 @@ public function getTranslate()
if (!isset($options['content']) && !isset($options['data'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('No translation source data provided.');
} else if (array_key_exists('content', $options) && array_key_exists('data', $options)) {
}

if (array_key_exists('content', $options) && array_key_exists('data', $options)) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception(
'Conflict on translation source data: choose only one key between content and data.'
Expand Down
9 changes: 7 additions & 2 deletions library/Zend/Auth/Adapter/Http/Resolver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,26 @@ public function resolve($username, $realm)
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username is required');
} else if (!ctype_print($username) || strpos($username, ':') !== false) {
}

if (!ctype_print($username) || strpos($username, ':') !== false) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, '
. 'excluding the colon');
}

if (empty($realm)) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm is required');
} else if (!ctype_print($realm) || strpos($realm, ':') !== false) {
}

if (!ctype_print($realm) || strpos($realm, ':') !== false) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
Expand Down
63 changes: 37 additions & 26 deletions library/Zend/Cloud/QueueService/Adapter/ZendQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
/**
* Constructor
*
* @param array|Zend_Config $options
* @param array|Zend_Config $options
* @return void
* @throws Zend_Cloud_QueueService_Exception
*/
public function __construct ($options = [])
{
Expand All @@ -77,10 +78,11 @@ public function __construct ($options = [])
// Build Zend_Service_WindowsAzure_Storage_Blob instance
if (!isset($options[self::ADAPTER])) {
throw new Zend_Cloud_QueueService_Exception('No Zend_Queue adapter provided');
} else {
$adapter = $options[self::ADAPTER];
unset($options[self::ADAPTER]);
}

$adapter = $options[self::ADAPTER];
unset($options[self::ADAPTER]);

try {
$this->_queue = new Zend_Queue($adapter, $options);
} catch (Zend_Queue_Exception $e) {
Expand All @@ -93,9 +95,10 @@ public function __construct ($options = [])
* It may take some time to create the queue. Check your vendor's
* documentation for details.
*
* @param string $name
* @param array $options
* @param string $name
* @param array $options
* @return string Queue ID (typically URL)
* @throws Zend_Cloud_QueueService_Exception
*/
public function createQueue($name, $options = null)
{
Expand All @@ -110,9 +113,10 @@ public function createQueue($name, $options = null)
/**
* Delete a queue. All messages in the queue will also be deleted.
*
* @param string $queueId
* @param array $options
* @param string $queueId
* @param array $options
* @return boolean true if successful, false otherwise
* @throws Zend_Cloud_QueueService_Exception
*/
public function deleteQueue($queueId, $options = null)
{
Expand All @@ -132,8 +136,9 @@ public function deleteQueue($queueId, $options = null)
/**
* List all queues.
*
* @param array $options
* @param array $options
* @return array Queue IDs
* @throws Zend_Cloud_QueueService_Exception
*/
public function listQueues($options = null)
{
Expand All @@ -147,9 +152,10 @@ public function listQueues($options = null)
/**
* Get a key/value array of metadata for the given queue.
*
* @param string $queueId
* @param array $options
* @param string $queueId
* @param array $options
* @return array
* @throws Zend_Cloud_QueueService_Exception
*/
public function fetchQueueMetadata($queueId, $options = null)
{
Expand All @@ -168,10 +174,11 @@ public function fetchQueueMetadata($queueId, $options = null)
* WARNING: This operation overwrites any metadata that is located at
* $destinationPath. Some adapters may not support this method.
*
* @param string $queueId
* @param array $metadata
* @param array $options
* @param string $queueId
* @param array $metadata
* @param array $options
* @return void
* @throws Zend_Cloud_QueueService_Exception
*/
public function storeQueueMetadata($queueId, $metadata, $options = null)
{
Expand All @@ -188,10 +195,11 @@ public function storeQueueMetadata($queueId, $metadata, $options = null)
/**
* Send a message to the specified queue.
*
* @param string $queueId
* @param string $message
* @param array $options
* @param string $queueId
* @param string $message
* @param array $options
* @return string Message ID
* @throws Zend_Cloud_QueueService_Exception
*/
public function sendMessage($queueId, $message, $options = null)
{
Expand All @@ -209,10 +217,11 @@ public function sendMessage($queueId, $message, $options = null)
* Recieve at most $max messages from the specified queue and return the
* message IDs for messages recieved.
*
* @param string $queueId
* @param int $max
* @param array $options
* @param string $queueId
* @param int $max
* @param array $options
* @return array
* @throws Zend_Cloud_QueueService_Exception
*/
public function receiveMessages($queueId, $max = 1, $options = null)
{
Expand Down Expand Up @@ -252,10 +261,11 @@ protected function _makeMessages($messages)
/**
* Delete the specified message from the specified queue.
*
* @param string $queueId
* @param Zend_Cloud_QueueService_Message $message Message ID or message
* @param array $options
* @param string $queueId
* @param Zend_Cloud_QueueService_Message $message Message ID or message
* @param array $options
* @return void
* @throws Zend_Cloud_QueueService_Exception
*/
public function deleteMessage($queueId, $message, $options = null)
{
Expand All @@ -279,10 +289,11 @@ public function deleteMessage($queueId, $message, $options = null)
/**
* Peek at the messages from the specified queue without removing them.
*
* @param string $queueId
* @param int $num How many messages
* @param array $options
* @param string $queueId
* @param int $num How many messages
* @param array $options
* @return Zend_Cloud_QueueService_Message[]
* @throws Zend_Cloud_OperationNotAvailableException
*/
public function peekMessages($queueId, $num = 1, $options = null)
{
Expand Down
Loading

0 comments on commit 5e8bb2e

Please sign in to comment.