Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
[#3919] Incorporate feedback
Browse files Browse the repository at this point in the history
- Ensure params/return/throws annotations are in correct order, with no
  whitespace between.
- Remove unnecessary empty lines.
- Ensure properties are in alphabetical order.
- Ensure classes referenced in docblocks are imported and/or resolved
  from current namespace.
  • Loading branch information
weierophinney committed Apr 30, 2013
1 parent 0a12ae1 commit 2104fc7
Show file tree
Hide file tree
Showing 23 changed files with 508 additions and 804 deletions.
96 changes: 31 additions & 65 deletions library/Zend/Soap/AutoDiscover.php
Expand Up @@ -17,10 +17,6 @@
use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy;
use Zend\Uri;

/**
* \Zend\Soap\AutoDiscover
*
*/
class AutoDiscover
{
/**
Expand All @@ -29,7 +25,7 @@ class AutoDiscover
protected $serviceName;

/**
* @var \Zend\Server\Reflection
* @var Reflection
*/
protected $reflection = null;

Expand Down Expand Up @@ -100,8 +96,12 @@ class AutoDiscover
* @param null|string $wsdlClass
* @param null|array $classMap
*/
public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri = null, $wsdlClass = null, array $classMap = array())
{
public function __construct(
ComplexTypeStrategy $strategy = null,
$endpointUri = null,
$wsdlClass = null,
array $classMap = array()
) {
$this->reflection = new Reflection();
$this->setDiscoveryStrategy(new ReflectionDiscovery());

Expand All @@ -121,13 +121,11 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri =
* Set the discovery strategy for method type and other information.
*
* @param DiscoveryStrategy $discoveryStrategy
*
* @return AutoDiscover
* @return self
*/
public function setDiscoveryStrategy(DiscoveryStrategy $discoveryStrategy)
{
$this->discoveryStrategy = $discoveryStrategy;

return $this;
}

Expand Down Expand Up @@ -155,7 +153,7 @@ public function getClassMap()
* Set the class map of php to wsdl mappings.
*
* @param array $classmap
* @return AutoDiscover
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setClassMap($classMap)
Expand All @@ -167,39 +165,37 @@ public function setClassMap($classMap)
(is_object($classMap) ? get_class($classMap) : gettype($classMap))
));
}
$this->classMap = $classMap;

$this->classMap = $classMap;
return $this;
}

/**
* Set service name
*
* @param string $serviceName
* @return self
* @throws Exception\InvalidArgumentException
*
* @return AutoDiscover
*/
public function setServiceName($serviceName)
{
$matches = array();

// first character must be letter or underscore {@see http://www.w3.org/TR/wsdl#_document-n}
$i = preg_match('/^[a-z\_]/ims', $serviceName, $matches);
if ($i != 1) {
throw new Exception\InvalidArgumentException('Service Name must start with letter or _');
}

$this->serviceName = $serviceName;

return $this;
}

/**
* Get service name
*
* @throws Exception\RuntimeException
*
* @return string
* @throws Exception\RuntimeException
*/
public function getServiceName()
{
Expand All @@ -210,7 +206,6 @@ public function getServiceName()
throw new Exception\RuntimeException('No service name given. Call AutoDiscover::setServiceName().');
}
}

return $this->serviceName;
}

Expand All @@ -219,9 +214,8 @@ public function getServiceName()
* Set the location at which the WSDL file will be available.
*
* @param Uri\Uri|string $uri
* @return self
* @throws Exception\InvalidArgumentException
*
* @return AutoDiscover
*/
public function setUri($uri)
{
Expand All @@ -239,16 +233,14 @@ public function setUri($uri)
}

$this->uri = $uri;

return $this;
}

/**
* Return the current Uri that the SOAP WSDL Service will be located at.
*
* @throws Exception\RuntimeException
*
* @return Uri\Uri
* @throws Exception\RuntimeException
*/
public function getUri()
{
Expand All @@ -260,17 +252,15 @@ public function getUri()
if (is_string($this->uri)) {
$this->uri = Uri\UriFactory::factory($this->uri);
}

return $this->uri;
}

/**
* Set the name of the WSDL handling class.
*
* @param string $wsdlClass
* @return self
* @throws Exception\InvalidArgumentException
*
* @return AutoDiscover
*/
public function setWsdlClass($wsdlClass)
{
Expand All @@ -281,7 +271,6 @@ public function setWsdlClass($wsdlClass)
}

$this->wsdlClass = $wsdlClass;

return $this;
}

Expand All @@ -302,17 +291,15 @@ public function getWsdlClass()
* 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/".
*
* @param array $operationStyle
* @return self
* @throws Exception\InvalidArgumentException
*
* @return AutoDiscover
*/
public function setOperationBodyStyle(array $operationStyle = array())
{
if (!isset($operationStyle['use'])) {
throw new Exception\InvalidArgumentException('Key "use" is required in Operation soap:body style.');
}
$this->operationBodyStyle = $operationStyle;

return $this;
}

Expand All @@ -322,8 +309,7 @@ public function setOperationBodyStyle(array $operationStyle = array())
* By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'.
*
* @param array $bindingStyle
*
* @return AutoDiscover
* @return self
*/
public function setBindingStyle(array $bindingStyle = array())
{
Expand All @@ -333,45 +319,39 @@ public function setBindingStyle(array $bindingStyle = array())
if (isset($bindingStyle['transport'])) {
$this->bindingStyle['transport'] = $bindingStyle['transport'];
}

return $this;
}

/**
* Set the strategy that handles functions and classes that are added AFTER this call.
*
* @param ComplexTypeStrategy $strategy
*
* @return AutoDiscover
* @return self
*/
public function setComplexTypeStrategy(ComplexTypeStrategy $strategy)
{
$this->strategy = $strategy;

return $this;
}

/**
* Set the Class the SOAP server will use
*
* @param string $class Class Name
*
* @return AutoDiscover
* @return self
*/
public function setClass($class)
{
$this->class = $class;

return $this;
}

/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $function Function Name
* @return self
* @throws Exception\InvalidArgumentException
*
* @return AutoDiscover
*/
public function addFunction($function)
{
Expand All @@ -393,7 +373,6 @@ public function addFunction($function)
'Argument to Zend\Soap\AutoDiscover::addFunction should be string or array of strings.'
);
}

return $this;
}

Expand All @@ -418,15 +397,13 @@ protected function _generateFunctions()
foreach (array_unique($this->functions) as $func) {
$methods[] = $this->reflection->reflectFunction($func);
}

return $this->_generateWsdl($methods);
}

/**
* Generate the WSDL for a set of reflection method instances.
*
* @param array $reflectionMethods
*
* @param array $reflectionMethods
* @return Wsdl
*/
protected function _generateWsdl(array $reflectionMethods)
Expand All @@ -435,7 +412,6 @@ protected function _generateWsdl(array $reflectionMethods)

$serviceName = $this->getServiceName();

/** @var $wsdl \Zend\Soap\Wsdl */
$wsdl = new $this->wsdlClass($serviceName, $uri, $this->strategy, $this->classMap);

// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
Expand All @@ -457,13 +433,11 @@ protected function _generateWsdl(array $reflectionMethods)
/**
* Add a function to the WSDL document.
*
* @param $function \Zend\Server\Reflection\AbstractFunction function to add
* @param $wsdl \Zend\Soap\Wsdl WSDL document
* @param $port \DOMElement wsdl:portType
* @param $binding \DOMElement wsdl:binding
* @param $function Reflection\AbstractFunction function to add
* @param $wsdl Wsdl WSDL document
* @param $port \DOMElement wsdl:portType
* @param $binding \DOMElement wsdl:binding
* @throws Exception\InvalidArgumentException
*
* @return void
*/
protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
{
Expand All @@ -472,7 +446,6 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
// We only support one prototype: the one with the maximum number of arguments
$prototype = null;
$maxNumArgumentsOfPrototype = -1;
/** @var $tmpPrototype \Zend\Server\Reflection\Prototype */
foreach ($function->getPrototypes() as $tmpPrototype) {
$numParams = count($tmpPrototype->getParameters());
if ($numParams > $maxNumArgumentsOfPrototype) {
Expand All @@ -494,7 +467,6 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
if ($this->bindingStyle['style'] == 'document') {
// Document style: wrap all parameters in a sequence element
$sequence = array();
/** @var $param Reflection\ReflectionParameter */
foreach ($prototype->getParameters() as $param) {
$sequenceElement = array(
'name' => $param->getName(),
Expand All @@ -516,7 +488,6 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)

} else {
// RPC style: add each parameter as a typed part
/** @var $param Reflection\ReflectionParameter */
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = array(
'type' => $wsdl->getType($this->discoveryStrategy->getFunctionParameterType($param))
Expand Down Expand Up @@ -597,9 +568,8 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
/**
* Generate the WSDL file from the configured input.
*
* @throws Exception\RuntimeException
*
* @return Wsdl
* @throws Exception\RuntimeException
*/
public function generate()
{
Expand All @@ -619,10 +589,9 @@ public function generate()
/**
* Proxy to WSDL dump function
*
* @param string $filename
* @throws \Zend\Soap\Exception\RuntimeException
*
* @param string $filename
* @return bool
* @throws Exception\RuntimeException
*/
public function dump($filename)
{
Expand All @@ -632,9 +601,8 @@ public function dump($filename)
/**
* Proxy to WSDL toXml() function
*
* @throws \Zend\Soap\Exception\RuntimeException
*
* @return string
* @throws Exception\RuntimeException
*/
public function toXml()
{
Expand All @@ -643,8 +611,6 @@ public function toXml()

/**
* Handle WSDL document.
*
* @return void
*/
public function handle()
{
Expand Down

0 comments on commit 2104fc7

Please sign in to comment.