From 2e155db8f9e2885751b90fd25e854f59ce22b112 Mon Sep 17 00:00:00 2001 From: Andreas Schamberger Date: Sat, 17 Dec 2011 16:05:25 +0100 Subject: [PATCH] CS fixes --- src/BeSimple/SoapClient/Curl.php | 18 ++--- src/BeSimple/SoapClient/FilterHelper.php | 44 +++++++------ src/BeSimple/SoapClient/SoapClient.php | 34 ++++++---- src/BeSimple/SoapClient/SoapRequest.php | 11 ++-- src/BeSimple/SoapClient/SoapResponse.php | 11 ++-- .../SoapClient/WsAddressingFilter.php | 37 +++++++---- src/BeSimple/SoapClient/WsSecurityFilter.php | 66 +++++++++++-------- src/BeSimple/SoapClient/WsdlDownloader.php | 22 ++++--- 8 files changed, 140 insertions(+), 103 deletions(-) diff --git a/src/BeSimple/SoapClient/Curl.php b/src/BeSimple/SoapClient/Curl.php index a8e508e..ae57933 100644 --- a/src/BeSimple/SoapClient/Curl.php +++ b/src/BeSimple/SoapClient/Curl.php @@ -50,8 +50,8 @@ class Curl /** * Constructor. * - * @param array $options - * @param int $followLocationMaxRedirects + * @param array $options Options array from SoapClient constructor + * @param int $followLocationMaxRedirects Redirection limit for Location header */ public function __construct(array $options = array(), $followLocationMaxRedirects = 10) { @@ -109,9 +109,10 @@ class Curl * Execute HTTP request. * Returns true if request was successfull. * - * @param string $location - * @param string $request - * @param array $requestHeaders + * @param string $location HTTP location + * @param string $request Request body + * @param array $requestHeaders Request header strings + * * @return bool */ public function exec($location, $request = null, $requestHeaders = array()) @@ -136,9 +137,8 @@ class Curl * Custom curl_exec wrapper that allows to follow redirects when specific * http response code is set. SOAP only allows 307. * - * @param resource $ch - * @param int $maxRedirects - * @param int $redirects + * @param int $redirects Current redirection count + * * @return mixed */ private function execManualRedirect($redirects = 0) @@ -186,7 +186,7 @@ class Curl * * http://curl.haxx.se/libcurl/c/libcurl-errors.html * - * @var array(int=>string) + * @return array(int=>string) */ protected function getErrorCodeMapping() { diff --git a/src/BeSimple/SoapClient/FilterHelper.php b/src/BeSimple/SoapClient/FilterHelper.php index f25e8bf..cb21c01 100644 --- a/src/BeSimple/SoapClient/FilterHelper.php +++ b/src/BeSimple/SoapClient/FilterHelper.php @@ -36,7 +36,7 @@ class FilterHelper /** * Constructor. * - * @param \DOMDocument $domDocument + * @param \DOMDocument $domDocument SOAP document */ public function __construct(\DOMDocument $domDocument) { @@ -46,10 +46,11 @@ class FilterHelper /** * Add new soap header. * - * @param \DOMElement $node - * @param boolean $mustUnderstand - * @param string $actor - * @param string $soapVersion + * @param \DOMElement $node DOMElement to add + * @param boolean $mustUnderstand SOAP header mustUnderstand attribute + * @param string $actor SOAP actor/role + * @param string $soapVersion SOAP version SOAP_1_1|SOAP_1_2 + * * @return void */ public function addHeaderElement(\DOMElement $node, $mustUnderstand = null, $actor = null, $soapVersion = SOAP_1_1) @@ -58,7 +59,7 @@ class FilterHelper $namespace = $root->namespaceURI; $prefix = $root->prefix; if (null !== $mustUnderstand) { - $node->appendChild(new \DOMAttr($prefix . ':mustUnderstand', (int)$mustUnderstand)); + $node->appendChild(new \DOMAttr($prefix . ':mustUnderstand', (int) $mustUnderstand)); } if (null !== $actor) { $attributeName = ($soapVersion == SOAP_1_1) ? 'actor' : 'role'; @@ -86,7 +87,8 @@ class FilterHelper /** * Add new soap body element. * - * @param \DOMElement $node + * @param \DOMElement $node DOMElement to add + * * @return void */ public function addBodyElement(\DOMElement $node) @@ -109,8 +111,9 @@ class FilterHelper /** * Add new namespace to root tag. * - * @param string $prefix - * @param string $namespaceURI + * @param string $prefix Namespace prefix + * @param string $namespaceURI Namespace URI + * * @return void */ public function addNamespace($prefix, $namespaceURI) @@ -125,9 +128,10 @@ class FilterHelper /** * Create new element for given namespace. * - * @param string $namespaceURI - * @param string $name - * @param string $value + * @param string $namespaceURI Namespace URI + * @param string $name Element name + * @param string $value Element value + * * @return \DOMElement */ public function createElement($namespaceURI, $name, $value = null) @@ -140,13 +144,14 @@ class FilterHelper /** * Add new attribute to element with given namespace. * - * @param \DOMElement $element - * @param string $namespaceURI - * @param string $name - * @param string $value + * @param \DOMElement $element DOMElement to edit + * @param string $namespaceURI Namespace URI + * @param string $name Attribute name + * @param string $value Attribute value + * * @return void */ - public function setAttribute(\DOMElement $element, $namespaceURI = null, $name, $value) + public function setAttribute(\DOMElement $element, $namespaceURI, $name, $value) { if (null !== $namespaceURI) { $prefix = $this->namespaces[$namespaceURI]; @@ -159,8 +164,9 @@ class FilterHelper /** * Register namespace. * - * @param string $prefix - * @param string $namespaceURI + * @param string $prefix Namespace prefix + * @param string $namespaceURI Namespace URI + * * @return void */ public function registerNamespace($prefix, $namespaceURI) diff --git a/src/BeSimple/SoapClient/SoapClient.php b/src/BeSimple/SoapClient/SoapClient.php index a6386ed..b130c7b 100644 --- a/src/BeSimple/SoapClient/SoapClient.php +++ b/src/BeSimple/SoapClient/SoapClient.php @@ -113,7 +113,8 @@ class SoapClient extends \SoapClient /** * Perform HTTP request with cURL. * - * @param SoapRequest $soapRequest + * @param SoapRequest $soapRequest SoapRequest object + * * @return SoapResponse */ private function __doHttpRequest(SoapRequest $soapRequest) @@ -126,7 +127,7 @@ class SoapClient extends \SoapClient // execute HTTP request with cURL $responseSuccessfull = $this->curl->exec($soapRequest->getLocation(), $soapRequest->getContent(), - $headers); + $headers); // tracing enabled: store last request header and body if ($this->tracingEnabled === true) { $this->lastRequestHeaders = $this->curl->getRequestHeaders(); @@ -136,7 +137,7 @@ class SoapClient extends \SoapClient if ($responseSuccessfull === false) { // get error message from curl $faultstring = $this->curl->getErrorMessage(); - throw new \SoapFault( 'HTTP', $faultstring ); + throw new \SoapFault('HTTP', $faultstring); } // tracing enabled: store last response header and body if ($this->tracingEnabled === true) { @@ -144,24 +145,27 @@ class SoapClient extends \SoapClient $this->lastResponse = $this->curl->getResponseBody(); } // wrap response data in SoapResponse object - $soapResponse = SoapResponse::create($this->curl->getResponseBody(), + $soapResponse = SoapResponse::create( + $this->curl->getResponseBody(), $soapRequest->getLocation(), $soapRequest->getAction(), $soapRequest->getVersion(), - $this->curl->getResponseContentType()); + $this->curl->getResponseContentType() + ); return $soapResponse; - } + } - /** + /** * Custom request method to be able to modify the SOAP messages. * $oneWay parameter is not used at the moment. * - * @param string $request - * @param string $location - * @param string $action - * @param int $version - * @param int $oneWay 0|1 + * @param string $request Request string + * @param string $location Location + * @param string $action SOAP action + * @param int $version SOAP version + * @param int $oneWay 0|1 + * * @return string */ public function __doRequest($request, $location, $action, $version, $oneWay = 0) @@ -180,7 +184,8 @@ class SoapClient extends \SoapClient * Runs the currently registered request filters on the request, performs * the HTTP request and runs the response filters. * - * @param SoapRequest $soapRequest + * @param SoapRequest $soapRequest SOAP request object + * * @return SoapResponse */ protected function __doRequest2(SoapRequest $soapRequest) @@ -262,7 +267,7 @@ class SoapClient extends \SoapClient $contentType = $this->curl->getResponseContentType(); if ($contentType != 'application/soap+xml' && $contentType != 'application/soap+xml') { - if (strncmp($response , "mixed) $options Options array + * * @return string */ private function loadWsdl($wsdl, array $options) diff --git a/src/BeSimple/SoapClient/SoapRequest.php b/src/BeSimple/SoapClient/SoapRequest.php index afe684f..00580cb 100644 --- a/src/BeSimple/SoapClient/SoapRequest.php +++ b/src/BeSimple/SoapClient/SoapRequest.php @@ -25,17 +25,18 @@ class SoapRequest extends CommonSoapRequest /** * Factory function for SoapRequest. * - * @param string $content - * @param string $location - * @param string $action - * @param string $version + * @param string $content Content + * @param string $location Location + * @param string $action SOAP action + * @param string $version SOAP version + * * @return BeSimple\SoapClient\SoapRequest */ public static function create($content, $location, $action, $version) { $request = new SoapRequest(); // $content is if unmodified from SoapClient not a php string type! - $request->setContent((string)$content); + $request->setContent((string) $content); $request->setLocation($location); $request->setAction($action); $request->setVersion($version); diff --git a/src/BeSimple/SoapClient/SoapResponse.php b/src/BeSimple/SoapClient/SoapResponse.php index a9317da..24a12c3 100644 --- a/src/BeSimple/SoapClient/SoapResponse.php +++ b/src/BeSimple/SoapClient/SoapResponse.php @@ -25,11 +25,12 @@ class SoapResponse extends CommonSoapResponse /** * Factory function for SoapResponse. * - * @param string $content - * @param string $location - * @param string $action - * @param string $version - * @param string $contentType + * @param string $content Content + * @param string $location Location + * @param string $action SOAP action + * @param string $version SOAP version + * @param string $contentType Content type header + * * @return BeSimple\SoapClient\SoapResponse */ public static function create($content, $location, $action, $version, $contentType) diff --git a/src/BeSimple/SoapClient/WsAddressingFilter.php b/src/BeSimple/SoapClient/WsAddressingFilter.php index 67d94c0..b112f82 100644 --- a/src/BeSimple/SoapClient/WsAddressingFilter.php +++ b/src/BeSimple/SoapClient/WsAddressingFilter.php @@ -126,10 +126,11 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Add additional reference parameters * - * @param string $ns - * @param string $pfx - * @param string $parameter - * @param string $value + * @param string $ns Namespace URI + * @param string $pfx Namespace prefix + * @param string $parameter Parameter name + * @param string $value Parameter value + * * @return void */ public function addReferenceParameter($ns, $pfx, $parameter, $value) @@ -145,8 +146,9 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Get additional reference parameters. * - * @param string $ns - * @param string $parameter + * @param string $ns Namespace URI + * @param string $parameter Parameter name + * * @return string|null */ public function getReferenceParameter($ns, $parameter) @@ -162,7 +164,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Set FaultTo address of type xs:anyURI. * - * @param string $action + * @param string $faultTo xs:anyURI + * * @return void */ public function setFaultTo($faultTo) @@ -173,7 +176,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Set From address of type xs:anyURI. * - * @param string $action + * @param string $from xs:anyURI + * * @return void */ public function setFrom($from) @@ -185,7 +189,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter * Set MessageId of type xs:anyURI. * Default: UUID v4 e.g. 'uuid:550e8400-e29b-11d4-a716-446655440000' * - * @param string $messageId + * @param string $messageId xs:anyURI + * * @return void */ public function setMessageId($messageId = null) @@ -200,8 +205,9 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter * Set RelatesTo of type xs:anyURI with the optional relationType * (of type xs:anyURI). * - * @param string $relatesTo - * @param string $relationType + * @param string $relatesTo xs:anyURI + * @param string $relationType xs:anyURI + * * @return void */ public function setRelatesTo($relatesTo, $relationType = null) @@ -216,7 +222,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter * Set ReplyTo address of type xs:anyURI * Default: self::ENDPOINT_REFERENCE_ANONYMOUS * - * @param string $replyTo + * @param string $replyTo xs:anyURI + * * @return void */ public function setReplyTo($replyTo = null) @@ -230,7 +237,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Modify the given request XML. * - * @param SoapRequest $dom + * @param SoapRequest $request SOAP request + * * @return void */ public function filterRequest(SoapRequest $request) @@ -298,7 +306,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter /** * Modify the given response XML. * - * @param SoapResponse $response + * @param SoapResponse $response SOAP response + * * @return void */ public function filterResponse(SoapResponse $response) diff --git a/src/BeSimple/SoapClient/WsSecurityFilter.php b/src/BeSimple/SoapClient/WsSecurityFilter.php index 8eb368c..e8cd60c 100644 --- a/src/BeSimple/SoapClient/WsSecurityFilter.php +++ b/src/BeSimple/SoapClient/WsSecurityFilter.php @@ -152,8 +152,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter * Constructor. * * @param boolean $addTimestamp (SMS 10) Add security timestamp. - * @param int $expires (SMS 10) Security timestamp expires time in seconds. - * @param string $actor + * @param int $expires (SMS 10) Security timestamp expires time in seconds. + * @param string $actor SOAP actor */ public function __construct($addTimestamp = true, $expires = 300, $actor = null) { @@ -165,9 +165,10 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Add user data. * - * @param string $username - * @param string $password - * @param int $passwordType self::PASSWORD_TYPE_DIGEST | self::PASSWORD_TYPE_TEXT + * @param string $username Username + * @param string $password Password + * @param int $passwordType self::PASSWORD_TYPE_DIGEST | self::PASSWORD_TYPE_TEXT + * * @return void */ public function addUserData($username, $password = null, $passwordType = self::PASSWORD_TYPE_DIGEST) @@ -180,7 +181,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Get service security key. * - * @param \BeSimple\SoapCommon\WsSecurityKey $serviceSecurityKey + * @param \BeSimple\SoapCommon\WsSecurityKey $serviceSecurityKey Service security key + * * @return void */ public function setServiceSecurityKeyObject(WsSecurityKey $serviceSecurityKey) @@ -191,7 +193,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Get user security key. * - * @param \BeSimple\SoapCommon\WsSecurityKey $userSecurityKey + * @param \BeSimple\SoapCommon\WsSecurityKey $userSecurityKey User security key + * * @return void */ public function setUserSecurityKeyObject(WsSecurityKey $userSecurityKey) @@ -202,8 +205,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Set security options. * - * @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1 - * @param boolean $encryptSignature + * @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1 + * @param boolean $encryptSignature Encrypt signature + * * @return void */ public function setSecurityOptionsEncryption($tokenReference, $encryptSignature = false) @@ -215,8 +219,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Set security options. * - * @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1 - * @param boolean $signAllHeaders + * @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1 + * @param boolean $signAllHeaders Sign all headers? + * * @return void */ public function setSecurityOptionsSignature($tokenReference, $signAllHeaders = false) @@ -228,7 +233,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Modify the given request XML. * - * @param SoapRequest $dom + * @param SoapRequest $request SOAP request to modify + * * @return void */ public function filterRequest(SoapRequest $request) @@ -278,7 +284,7 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) { $nonce = mt_rand(); - $password = base64_encode(sha1($nonce . $createdTimestamp . $this->password , true)); + $password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true)); $passwordType = Helper::NAME_WSS_UTP . '#PasswordDigest'; } else { $password = $this->password; @@ -349,7 +355,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Modify the given request XML. * - * @param SoapResponse $response + * @param SoapResponse $response SOAP response to modify + * * @return void */ public function filterResponse(SoapResponse $response) @@ -397,12 +404,11 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Adds the configured KeyInfo to the parentNode. * - * @param FilterHelper $filterHelper - * @param int $tokenReference - * @param \DOMNode $parentNode - * @param string $guid - * @param \ass\XmlSecurity\Key $xmlSecurityKey - * @param \DOMNode $insertBefore + * @param FilterHelper $filterHelper Filter helper object + * @param int $tokenReference Token reference type + * @param string $guid Unique ID + * @param \ass\XmlSecurity\Key $xmlSecurityKey XML security key + * * @return \DOMElement */ protected function createKeyInfo(FilterHelper $filterHelper, $tokenReference, $guid, XmlSecurityKey $xmlSecurityKey = null) @@ -444,8 +450,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Create a list of \DOMNodes that should be encrypted. * - * @param \DOMDocument $dom - * @param \DOMElement $security + * @param \DOMDocument $dom DOMDocument to query + * @param \DOMElement $security Security element + * * @return \DOMNodeList */ protected function createNodeListForEncryption(\DOMDocument $dom, \DOMElement $security) @@ -465,8 +472,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Create a list of \DOMNodes that should be signed. * - * @param \DOMDocument $dom - * @param \DOMElement $security + * @param \DOMDocument $dom DOMDocument to query + * @param \DOMElement $security Security element + * * @return array(\DOMNode) */ protected function createNodeListForSigning(\DOMDocument $dom, \DOMElement $security) @@ -496,8 +504,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Gets the referenced node for the given URI. * - * @param \DOMElement $node - * @param string $uri + * @param \DOMElement $node Node + * @param string $uri URI + * * @return \DOMElement */ protected function getReferenceNodeForUri(\DOMElement $node, $uri) @@ -514,8 +523,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter /** * Tries to resolve a key from the given \DOMElement. * - * @param \DOMElement $node - * @param string $algorithm + * @param \DOMElement $node Node where to resolve the key + * @param string $algorithm XML security key algorithm + * * @return \ass\XmlSecurity\Key|null */ public function keyInfoSecurityTokenReferenceResolver(\DOMElement $node, $algorithm) diff --git a/src/BeSimple/SoapClient/WsdlDownloader.php b/src/BeSimple/SoapClient/WsdlDownloader.php index 5dda4f9..828fe1c 100644 --- a/src/BeSimple/SoapClient/WsdlDownloader.php +++ b/src/BeSimple/SoapClient/WsdlDownloader.php @@ -1,4 +1,4 @@ -curl = $curl; $this->resolveRemoteIncludes = $resolveRemoteIncludes; // get current WSDL caching config - $this->cacheEnabled = (bool)ini_get('soap.wsdl_cache_enabled'); + $this->cacheEnabled = (bool) ini_get('soap.wsdl_cache_enabled'); if ($this->cacheEnabled === true && $cacheWsdl === WSDL_CACHE_NONE) { $this->cacheEnabled = false; @@ -87,7 +87,8 @@ class WsdlDownloader /** * Download given WSDL file and return name of cache file. * - * @param string $wsdl + * @param string $wsdl WSDL file URL/path + * * @return string */ public function download($wsdl) @@ -134,7 +135,8 @@ class WsdlDownloader /** * Do we have a remote file? * - * @param string $file + * @param string $file File URL/path + * * @return boolean */ private function isRemoteFile($file) @@ -153,9 +155,10 @@ class WsdlDownloader /** * Resolves remote WSDL/XSD includes within the WSDL files. * - * @param string $xml - * @param string $cacheFile - * @param unknown_type $parentIsRemote + * @param string $xml XML file + * @param string $cacheFile Cache file name + * @param boolean $parentFile Parent file name + * * @return void */ private function resolveRemoteIncludes($xml, $cacheFile, $parentFile = null) @@ -203,8 +206,9 @@ class WsdlDownloader /** * Resolves the relative path to base into an absolute. * - * @param string $base - * @param string $relative + * @param string $base Base path + * @param string $relative Relative path + * * @return string */ private function resolveRelativePathInUrl($base, $relative)