|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SoapClient; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This class can be overridden at your will. |
|
7
|
|
|
* Its only purpose is to show you how you can use your own SoapClient client. |
|
8
|
|
|
*/ |
|
9
|
|
|
class SoapClient extends \SoapClient |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $lastModifiedRequest; |
|
15
|
|
|
/** |
|
16
|
|
|
* @param string $request |
|
17
|
|
|
* @param string $location |
|
18
|
|
|
* @param string $action |
|
19
|
|
|
* @param string $version |
|
20
|
|
|
* @param number $one_way |
|
21
|
|
|
* @return mixed |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __doRequest($request, $location, $action, $version, $one_way = 0) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->removeEmptyTags($request); |
|
26
|
|
|
return parent::__doRequest($this->__getLastRequest(), $location, $action, $version, $one_way); |
|
27
|
|
|
} |
|
28
|
|
|
/** |
|
29
|
|
|
* Returns last request |
|
30
|
|
|
* @see SoapClient::__getLastRequest() |
|
31
|
|
|
* @return string |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __getLastRequest() |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->lastModifiedRequest; |
|
36
|
|
|
} |
|
37
|
|
|
/** |
|
38
|
|
|
* Sets last request values |
|
39
|
|
|
* @param string $_lastRequest |
|
|
|
|
|
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __setLastRequest($lastRequest) |
|
43
|
|
|
{ |
|
44
|
|
|
return ($this->lastModifiedRequest = $lastRequest); |
|
45
|
|
|
} |
|
46
|
|
|
/** |
|
47
|
|
|
* Removes empty tags from XML |
|
48
|
|
|
* @param string $xml |
|
49
|
|
|
* @param array $exceptTags |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
private function removeEmptyTags($xml, $exceptTags = array()) |
|
53
|
|
|
{ |
|
54
|
|
|
if (!empty($xml)) { |
|
55
|
|
|
$dom = new \DOMDocument('1.0', 'UTF-8'); |
|
56
|
|
|
$dom->formatOutput = true; |
|
57
|
|
|
if ($dom->loadXML($xml) && $dom->hasChildNodes()) { |
|
58
|
|
|
$mainNode = $dom->childNodes->item(0); |
|
59
|
|
|
self::removeEmptyTagsFromDomNode($mainNode, $exceptTags); |
|
60
|
|
|
$xml = $dom->saveXML($mainNode); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
return $this->__setLastRequest($xml); |
|
64
|
|
|
} |
|
65
|
|
|
/** |
|
66
|
|
|
* Removes empty tags from \DOMNode |
|
67
|
|
|
* @uses RemoveEmptyRequestTags::removeEmptyTagsFromDomNode() |
|
68
|
|
|
* @param \DOMNode $domNode |
|
69
|
|
|
* @return void |
|
70
|
|
|
*/ |
|
71
|
|
|
private static function removeEmptyTagsFromDomNode(\DOMNode &$domNode, $exceptTags = array()) |
|
72
|
|
|
{ |
|
73
|
|
|
if ($domNode->hasChildNodes()) { |
|
74
|
|
|
foreach ($domNode->childNodes as $childNode) { |
|
75
|
|
|
self::removeEmptyTagsFromDomNode($childNode, $exceptTags); |
|
76
|
|
|
} |
|
77
|
|
|
} elseif (trim($domNode->nodeValue) === '' && !in_array($domNode->nodeName, $exceptTags) && $domNode->attributes->length === 0) { |
|
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* As the parent might not have returned an empty value as it contained this child |
|
80
|
|
|
* we go process back the parent to be sure that he validated as not empty |
|
81
|
|
|
*/ |
|
82
|
|
|
$parentNode = $domNode->parentNode; |
|
83
|
|
|
$domNode->parentNode->removeChild($domNode); |
|
84
|
|
|
self::removeEmptyTagsFromDomNode($parentNode, $exceptTags); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.