-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.complextypedemo.php
158 lines (142 loc) · 4.02 KB
/
class.complextypedemo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
if(basename($_SERVER['SCRIPT_FILENAME'])==basename(__FILE__))
exit;
// The @pw_element and @pw_complex are non-standard keywords for documentaion
// I had to define to support those complex types for WSDL generation. The
// "pw" stands for "PhpWsdl". But who cares?
/**
* This is how to define a complex type f.e. - the class ComplexTypeDemo doesn't need to exists,
* but it would make it easier for you to return that complex type from a method
*
* @pw_element string $StringA A string with a value
* @pw_element string $StringB A string with a NULL value
* @pw_element int $Integer An integer
* @pw_element boolean $Boolean A boolean
* @pw_element DemoEnum $Enum An enumeration
* @pw_complex ComplexTypeDemo The complex type name definition
*/
class ComplexTypeDemo{
/**
* A string
*
* @var string
*/
public $StringA='String A';
/**
* Another string
*
* @var string
*/
public $StringB=null;
/**
* An integer
*
* @var int
*/
public $Integer=123;
/**
* A boolean
*
* @var boolean
*/
public $Boolean=true;
/**
* An enumeration
*
* @var DemoEnum
*/
public $Enum;
/**
* The constructor
*
* @ignore
*/
public function ComplexTypeDemo(){
$this->Enum=DemoEnum::ValueB;
}
}
// Now a demonstration how to implement inherited complex types:
/**
* This complex type inherits all properties of ComplexTypeDemo
*
* @pw_element string $AdditionalString An additional string
* @pw_set inherit=ComplexTypeDemo <- To tell PhpWsdl about the base type
* @pw_complex ComplexTypeDemoB The complex type name definition
*/
class ComplexTypeDemoB extends ComplexTypeDemo{
/**
* An additional string
*
* @var string
*/
public $AdditionalString='';
/**
* The constructor
*
* @ignore
*/
public function ComplexTypeDemoB(){
parent::ComplexTypeDemo();
}
}
// You can also create array types as complex type. Here for the string type and the ComplexTypeDemo complex type.
// As you can see you simply need to add "Array" to the name of the type. Not one line of code.
/**
* @pw_complex stringArray A string array type
*/
/**
* @pw_complex ComplexTypeDemoBArray An array of ComplexTypeDemoB
*/
// But you may also create an array without any name restrictions. To use the arrayOfInt[] finally, use the type
// name without the "[]" (that's only required for parsing the correct target type)
/**
* @pw_complex arrayOfInt[] int An int array type
*/
// This is how to implement an enumeration with the @pw_enum keyword. An enumeration needs a type, a name
// and a comma seperated list of enumerateable values of the type. You should only use types that can be interpreted
// when placing them between single or double quotes (string, int, float, ...). String values can't include a comma
// because this is the list seperator.
/**
* This is how to define an enumeration. You don't need the class DemoEnum - it's just to demonstrate how
* I handle enumerations in PHP.
*
* @pw_enum string DemoEnum ValueA=ValueA,ValueB=ValueB,ValueC=ValueC A sample enumeration
*/
abstract class DemoEnum{
/**
* A description for ValueA
*
* @var string
*/
const ValueA='ValueA';
/**
* A description for ValueB
*
* @var string
*/
const ValueB='ValueB';
/**
* A description for ValueC
*
* @var string
*/
const ValueC='ValueC';
/**
* Constructor that will throw an exception because you can't instance an enumeration
*
* @ignore
*/
public function DemoEnum(){
throw(new Exception('This is an enumeration - instances are not supported!'));
}
}
// This complex type will be used as exception type for all methods
/**
* This is the exception type for all methods
*
* @pw_element string $message The message
* @pw_element int $code The code
* @pw_element string $file The file name
* @pw_element int $line The line number
* @pw_complex SoapFault A complex type describing the SoapFault exception
*/