|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2013-2015 |
|
4
|
|
|
* Piotr Olaszewski <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
8
|
|
|
* in the Software without restriction, including without limitation the rights |
|
9
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
11
|
|
|
* furnished to do so, subject to the following conditions: |
|
12
|
|
|
* |
|
13
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
14
|
|
|
* all copies or substantial portions of the Software. |
|
15
|
|
|
* |
|
16
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
22
|
|
|
* SOFTWARE. |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace WSDL\XML\Styles; |
|
25
|
|
|
|
|
26
|
|
|
use WSDL\Parser\MethodParser; |
|
27
|
|
|
use WSDL\Types\Type; |
|
28
|
|
|
use WSDL\Utilities\TypeHelper; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* DocumentLiteralWrapped |
|
32
|
|
|
* |
|
33
|
|
|
* @author Piotr Olaszewski <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
class DocumentLiteralWrapped extends Style |
|
36
|
|
|
{ |
|
37
|
1 |
|
public function bindingStyle() |
|
38
|
|
|
{ |
|
39
|
1 |
|
return 'document'; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function bindingUse() |
|
43
|
|
|
{ |
|
44
|
1 |
|
return 'literal'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function methodInput(MethodParser $method) |
|
48
|
|
|
{ |
|
49
|
|
|
return array($this->_createPart($method)); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function methodOutput(MethodParser $method) |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->_createPart($method, 'Response'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function _createPart(MethodParser $method, $type = '') |
|
58
|
|
|
{ |
|
59
|
|
|
$name = 'parameters'; |
|
60
|
|
|
$elementName = 'ns:' . $method->getName() . $type; |
|
61
|
|
|
$element = array( |
|
62
|
|
|
'name' => $name, |
|
63
|
|
|
'element' => $elementName |
|
64
|
|
|
); |
|
65
|
|
|
return $element; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
7 |
|
public function typeParameters(MethodParser $method) |
|
69
|
1 |
|
{ |
|
70
|
7 |
|
$element = new TypesElement(); |
|
71
|
7 |
|
$element->setName($method->getName()); |
|
72
|
7 |
|
foreach ($method->parameters() as $parameter) { |
|
73
|
7 |
|
$this->_generateElements($parameter, $element); |
|
|
|
|
|
|
74
|
7 |
|
} |
|
75
|
7 |
|
return array($element); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
6 |
|
public function typeReturning(MethodParser $method) |
|
79
|
|
|
{ |
|
80
|
6 |
|
$element = new TypesElement(); |
|
81
|
6 |
|
$element->setName($method->getName() . 'Response'); |
|
82
|
6 |
|
foreach($method->returning() as $parameter) { |
|
|
|
|
|
|
83
|
6 |
|
$this->_generateElements($parameter, $element); |
|
84
|
6 |
|
} |
|
85
|
6 |
|
return $element; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
13 |
|
private function _generateElements(Type $parameter, TypesElement $element) |
|
89
|
|
|
{ |
|
90
|
13 |
|
list($type, $value) = $this->_prepareTypeAndValue($parameter); |
|
91
|
13 |
|
$element->setElementAttributes($type, $value, $parameter->getName()); |
|
92
|
13 |
|
if (!TypeHelper::isSimple($parameter)) { |
|
93
|
13 |
|
$complexType = $this->_generateComplexType($parameter); |
|
94
|
13 |
|
$element->setComplex($complexType); |
|
95
|
13 |
|
} |
|
96
|
13 |
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: