1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\Groups; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\CodeGeneration\AccessTypeTraits; |
6
|
|
|
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType; |
10
|
|
|
|
11
|
|
|
trait TFunctionImportAttributesTrait |
12
|
|
|
{ |
13
|
|
|
use TSimpleIdentifierTrait, AccessTypeTraits, IsOKToolboxTrait; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @property string $name |
17
|
|
|
*/ |
18
|
|
|
private $name = null; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType[] $returnType |
22
|
|
|
*/ |
23
|
|
|
private $returnType = []; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType $entitySet |
27
|
|
|
*/ |
28
|
|
|
private $entitySet = null; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @property boolean $isComposable |
32
|
|
|
*/ |
33
|
|
|
private $isComposable = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @property boolean $isSideEffecting |
37
|
|
|
*/ |
38
|
|
|
private $isSideEffecting = true; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @property boolean $isBindable |
42
|
|
|
*/ |
43
|
|
|
private $isBindable = false; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @property string $methodAccess |
47
|
|
|
*/ |
48
|
|
|
private $methodAccess = null; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Gets as name |
52
|
|
|
* |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function getName() |
56
|
|
|
{ |
57
|
|
|
return $this->name; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Sets a new name |
62
|
|
|
* |
63
|
|
|
* @param string $name |
64
|
|
|
* @return self |
65
|
|
|
*/ |
66
|
|
|
public function setName($name) |
67
|
|
|
{ |
68
|
|
|
$msg = null; |
|
|
|
|
69
|
|
|
if (!$this->isTSimpleIdentifierValid($name)) { |
70
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
71
|
|
|
throw new \InvalidArgumentException($msg); |
72
|
|
|
} |
73
|
|
|
$this->name = $name; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Adds as returnType |
79
|
|
|
* |
80
|
|
|
* @return self |
81
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType $returnType |
82
|
|
|
*/ |
83
|
|
View Code Duplication |
public function addToReturnType(TFunctionImportReturnTypeType $returnType) |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
$msg = null; |
86
|
|
|
if (!$returnType->isOK($msg)) { |
87
|
|
|
throw new \InvalidArgumentException($msg); |
88
|
|
|
} |
89
|
|
|
$this->returnType[] = $returnType; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* isset returnType |
95
|
|
|
* |
96
|
|
|
* @param scalar $index |
97
|
|
|
* @return boolean |
98
|
|
|
*/ |
99
|
|
|
public function issetReturnType($index) |
100
|
|
|
{ |
101
|
|
|
return isset($this->returnType[$index]); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* unset returnType |
106
|
|
|
* |
107
|
|
|
* @param scalar $index |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
public function unsetReturnType($index) |
111
|
|
|
{ |
112
|
|
|
unset($this->returnType[$index]); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Gets as returnType |
117
|
|
|
* |
118
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType[] |
119
|
|
|
*/ |
120
|
|
|
public function getReturnType() |
121
|
|
|
{ |
122
|
|
|
return $this->returnType; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Sets a new returnType |
127
|
|
|
* |
128
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType[] $returnType |
129
|
|
|
* @return self |
130
|
|
|
*/ |
131
|
|
|
public function setReturnType(array $returnType) |
132
|
|
|
{ |
133
|
|
|
$msg = null; |
134
|
|
|
if (!$this->isValidArrayOK( |
135
|
|
|
$returnType, |
136
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType', |
137
|
|
|
$msg |
138
|
|
|
)) { |
139
|
|
|
throw new \InvalidArgumentException($msg); |
140
|
|
|
} |
141
|
|
|
$this->returnType = $returnType; |
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Gets as entitySet |
147
|
|
|
* |
148
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType |
149
|
|
|
*/ |
150
|
|
|
public function getEntitySet() |
151
|
|
|
{ |
152
|
|
|
return $this->entitySet; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Sets a new entitySet |
157
|
|
|
* |
158
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType $entitySet |
159
|
|
|
* @return self |
160
|
|
|
*/ |
161
|
|
View Code Duplication |
public function setEntitySet(TOperandType $entitySet) |
|
|
|
|
162
|
|
|
{ |
163
|
|
|
$msg = null; |
164
|
|
|
if (!$entitySet->isOK($msg)) { |
165
|
|
|
throw new \InvalidArgumentException($msg); |
166
|
|
|
} |
167
|
|
|
$this->entitySet = $entitySet; |
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Gets as isComposable |
173
|
|
|
* |
174
|
|
|
* @return boolean |
175
|
|
|
*/ |
176
|
|
|
public function getIsComposable() |
177
|
|
|
{ |
178
|
|
|
return $this->isComposable; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Sets a new isComposable |
183
|
|
|
* |
184
|
|
|
* @param boolean $isComposable |
185
|
|
|
* @return self |
186
|
|
|
*/ |
187
|
|
|
public function setIsComposable($isComposable) |
188
|
|
|
{ |
189
|
|
|
$this->isComposable = boolval($isComposable); |
190
|
|
|
return $this; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Gets as isSideEffecting |
195
|
|
|
* |
196
|
|
|
* @return boolean |
197
|
|
|
*/ |
198
|
|
|
public function getIsSideEffecting() |
199
|
|
|
{ |
200
|
|
|
return $this->isSideEffecting; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Sets a new isSideEffecting |
205
|
|
|
* |
206
|
|
|
* @param boolean $isSideEffecting |
207
|
|
|
* @return self |
208
|
|
|
*/ |
209
|
|
|
public function setIsSideEffecting($isSideEffecting) |
210
|
|
|
{ |
211
|
|
|
$this->isSideEffecting = boolval($isSideEffecting); |
212
|
|
|
return $this; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Gets as isBindable |
217
|
|
|
* |
218
|
|
|
* @return boolean |
219
|
|
|
*/ |
220
|
|
|
public function getIsBindable() |
221
|
|
|
{ |
222
|
|
|
return $this->isBindable; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Sets a new isBindable |
227
|
|
|
* |
228
|
|
|
* @param boolean $isBindable |
229
|
|
|
* @return self |
230
|
|
|
*/ |
231
|
|
|
public function setIsBindable($isBindable) |
232
|
|
|
{ |
233
|
|
|
$this->isBindable = boolval($isBindable); |
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Gets as methodAccess |
239
|
|
|
* |
240
|
|
|
* @return string |
241
|
|
|
*/ |
242
|
|
|
public function getMethodAccess() |
243
|
|
|
{ |
244
|
|
|
return $this->methodAccess; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Sets a new methodAccess |
249
|
|
|
* |
250
|
|
|
* @param string $methodAccess |
251
|
|
|
* @return self |
252
|
|
|
*/ |
253
|
|
|
public function setMethodAccess($methodAccess) |
254
|
|
|
{ |
255
|
|
|
$msg = null; |
|
|
|
|
256
|
|
|
if (null != $methodAccess && $this->isTAccessOk($methodAccess)) { |
257
|
|
|
$msg = "Method access must be a valid TAccess"; |
258
|
|
|
throw new \InvalidArgumentException($msg); |
259
|
|
|
} |
260
|
|
|
$this->methodAccess = $methodAccess; |
261
|
|
|
return $this; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
|
265
|
|
|
public function isTFunctionImportAttributesValid(&$msg) |
266
|
|
|
{ |
267
|
|
View Code Duplication |
if (!$this->isTSimpleIdentifierValid($this->name)) { |
|
|
|
|
268
|
|
|
$msg = "Name must be a valid TSimpleIdentifier: " . get_class($this); |
269
|
|
|
return false; |
270
|
|
|
} |
271
|
|
|
if ($this->isComposable && $this->isSideEffecting) { |
272
|
|
|
$msg = "Cannot both be composable and side-effecting"; |
273
|
|
|
return false; |
274
|
|
|
} |
275
|
|
|
/* |
|
|
|
|
276
|
|
|
if (null != $this->entitySet && !$this->isTSimpleIdentifierValid($this->entitySet)) { |
277
|
|
|
$msg = "Entity set must be a valid TSimpleIdentifier"; |
278
|
|
|
return false; |
279
|
|
|
}*/ |
280
|
|
|
if (!$this->isObjectNullOrType('\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', $this->entitySet)) { |
281
|
|
|
$msg = "Entity set must be either null or an instance of TOperandType: " . get_class($this); |
282
|
|
|
return false; |
283
|
|
|
} |
284
|
|
|
if (null != $this->methodAccess && $this->isTAccessOk($this->methodAccess)) { |
285
|
|
|
$msg = "Method access must be a valid TAccess: " . get_class($this); |
286
|
|
|
return false; |
287
|
|
|
} |
288
|
|
|
if (!$this->isValidArrayOK( |
289
|
|
|
$this->returnType, |
290
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType', |
291
|
|
|
$msg |
292
|
|
|
)) { |
293
|
|
|
return false; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
return true; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.