|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the LGPL. For more information please see |
|
17
|
|
|
* <http://phing.info>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract baseclass for the <condition> task as well as several |
|
22
|
|
|
* conditions - ensures that the types of conditions inside the task |
|
23
|
|
|
* and the "container" conditions are in sync. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Hans Lellelid <[email protected]> |
|
26
|
|
|
* @author Andreas Aderhold <[email protected]> |
|
27
|
|
|
* @copyright 2001,2002 THYRELL. All rights reserved |
|
28
|
|
|
* @package phing.tasks.system.condition |
|
29
|
|
|
*/ |
|
30
|
|
|
abstract class ConditionBase extends ProjectComponent implements IteratorAggregate, CustomChildCreator |
|
31
|
|
|
{ |
|
32
|
|
|
public $conditions = []; // needs to be public for "inner" class access |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string $taskName |
|
36
|
|
|
*/ |
|
37
|
|
|
private $taskName = 'condition'; |
|
38
|
|
|
|
|
39
|
225 |
|
public function __construct($taskName = 'component') |
|
40
|
|
|
{ |
|
41
|
225 |
|
parent::__construct(); |
|
42
|
225 |
|
$this->taskName = $taskName; |
|
43
|
225 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Sets the name to use in logging messages. |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $name The name to use in logging messages. |
|
49
|
|
|
* Should not be <code>null</code>. |
|
50
|
|
|
*/ |
|
51
|
|
|
public function setTaskName($name) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->taskName = $name; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Returns the name to use in logging messages. |
|
58
|
|
|
* |
|
59
|
|
|
* @return string the name to use in logging messages. |
|
60
|
|
|
*/ |
|
61
|
5 |
|
public function getTaskName() |
|
62
|
|
|
{ |
|
63
|
5 |
|
return $this->taskName; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return int |
|
68
|
|
|
*/ |
|
69
|
223 |
|
public function countConditions() |
|
70
|
|
|
{ |
|
71
|
223 |
|
return count($this->conditions); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Required for IteratorAggregate |
|
76
|
|
|
*/ |
|
77
|
39 |
|
public function getIterator() |
|
78
|
|
|
{ |
|
79
|
39 |
|
return new ConditionEnumeration($this); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return Condition[] |
|
84
|
|
|
*/ |
|
85
|
192 |
|
public function getConditions() |
|
86
|
|
|
{ |
|
87
|
192 |
|
return $this->conditions; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param AvailableTask $a |
|
92
|
|
|
* @return void |
|
93
|
|
|
*/ |
|
94
|
4 |
|
public function addAvailable(AvailableTask $a) |
|
95
|
|
|
{ |
|
96
|
4 |
|
$this->conditions[] = $a; |
|
97
|
4 |
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return NotCondition |
|
101
|
|
|
*/ |
|
102
|
4 |
|
public function createNot() |
|
103
|
|
|
{ |
|
104
|
4 |
|
$num = array_push($this->conditions, new NotCondition()); |
|
105
|
|
|
|
|
106
|
4 |
|
return $this->conditions[$num - 1]; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return AndCondition |
|
111
|
|
|
*/ |
|
112
|
2 |
|
public function createAnd() |
|
113
|
|
|
{ |
|
114
|
2 |
|
$num = array_push($this->conditions, new AndCondition()); |
|
115
|
|
|
|
|
116
|
2 |
|
return $this->conditions[$num - 1]; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return OrCondition |
|
121
|
|
|
*/ |
|
122
|
1 |
|
public function createOr() |
|
123
|
|
|
{ |
|
124
|
1 |
|
$num = array_push($this->conditions, new OrCondition()); |
|
125
|
|
|
|
|
126
|
1 |
|
return $this->conditions[$num - 1]; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @return XorCondition |
|
131
|
|
|
*/ |
|
132
|
7 |
|
public function createXor() |
|
133
|
|
|
{ |
|
134
|
7 |
|
$num = array_push($this->conditions, new XorCondition()); |
|
135
|
|
|
|
|
136
|
7 |
|
return $this->conditions[$num - 1]; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return EqualsCondition |
|
141
|
|
|
*/ |
|
142
|
12 |
|
public function createEquals() |
|
143
|
|
|
{ |
|
144
|
12 |
|
$num = array_push($this->conditions, new EqualsCondition()); |
|
145
|
|
|
|
|
146
|
12 |
|
return $this->conditions[$num - 1]; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return OsCondition |
|
151
|
|
|
*/ |
|
152
|
175 |
|
public function createOs() |
|
153
|
|
|
{ |
|
154
|
175 |
|
$num = array_push($this->conditions, new OsCondition()); |
|
155
|
|
|
|
|
156
|
175 |
|
return $this->conditions[$num - 1]; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* @return IsFalseCondition |
|
161
|
|
|
*/ |
|
162
|
|
|
public function createIsFalse() |
|
163
|
|
|
{ |
|
164
|
|
|
$num = array_push($this->conditions, new IsFalseCondition()); |
|
165
|
|
|
|
|
166
|
|
|
return $this->conditions[$num - 1]; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @return IsTrueCondition |
|
171
|
|
|
*/ |
|
172
|
7 |
|
public function createIsTrue() |
|
173
|
|
|
{ |
|
174
|
7 |
|
$num = array_push($this->conditions, new IsTrueCondition()); |
|
175
|
|
|
|
|
176
|
7 |
|
return $this->conditions[$num - 1]; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return IsPropertyFalseCondition |
|
181
|
|
|
*/ |
|
182
|
2 |
|
public function createIsPropertyFalse() |
|
183
|
|
|
{ |
|
184
|
2 |
|
$num = array_push($this->conditions, new IsPropertyFalseCondition()); |
|
185
|
|
|
|
|
186
|
2 |
|
return $this->conditions[$num - 1]; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @return IsPropertyTrueCondition |
|
191
|
|
|
*/ |
|
192
|
2 |
|
public function createIsPropertyTrue() |
|
193
|
|
|
{ |
|
194
|
2 |
|
$num = array_push($this->conditions, new IsPropertyTrueCondition()); |
|
195
|
|
|
|
|
196
|
2 |
|
return $this->conditions[$num - 1]; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @return ContainsCondition |
|
201
|
|
|
*/ |
|
202
|
1 |
|
public function createContains() |
|
203
|
|
|
{ |
|
204
|
1 |
|
$num = array_push($this->conditions, new ContainsCondition()); |
|
205
|
|
|
|
|
206
|
1 |
|
return $this->conditions[$num - 1]; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @return IsSetCondition |
|
211
|
|
|
*/ |
|
212
|
|
|
public function createIsSet() |
|
213
|
|
|
{ |
|
214
|
|
|
$num = array_push($this->conditions, new IsSetCondition()); |
|
215
|
|
|
|
|
216
|
|
|
return $this->conditions[$num - 1]; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @return ReferenceExistsCondition |
|
221
|
|
|
*/ |
|
222
|
1 |
|
public function createReferenceExists() |
|
223
|
|
|
{ |
|
224
|
1 |
|
$num = array_push($this->conditions, new ReferenceExistsCondition()); |
|
225
|
|
|
|
|
226
|
1 |
|
return $this->conditions[$num - 1]; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function createVersionCompare() |
|
230
|
|
|
{ |
|
231
|
|
|
$num = array_push($this->conditions, new VersionCompareCondition()); |
|
232
|
|
|
|
|
233
|
|
|
return $this->conditions[$num - 1]; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
public function createHttp() |
|
237
|
|
|
{ |
|
238
|
|
|
$num = array_push($this->conditions, new HttpCondition()); |
|
239
|
|
|
|
|
240
|
|
|
return $this->conditions[$num - 1]; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
1 |
|
public function createPhingVersion() |
|
244
|
|
|
{ |
|
245
|
1 |
|
$num = array_push($this->conditions, new PhingVersion()); |
|
246
|
|
|
|
|
247
|
1 |
|
return $this->conditions[$num - 1]; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
public function createHasFreeSpace() |
|
251
|
|
|
{ |
|
252
|
|
|
$num = array_push($this->conditions, new HasFreeSpaceCondition()); |
|
253
|
|
|
|
|
254
|
|
|
return $this->conditions[$num - 1]; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
3 |
|
public function createFilesMatch() |
|
258
|
|
|
{ |
|
259
|
3 |
|
$num = array_push($this->conditions, new FilesMatch()); |
|
260
|
|
|
|
|
261
|
3 |
|
return $this->conditions[$num - 1]; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
1 |
|
public function createSocket() |
|
265
|
|
|
{ |
|
266
|
1 |
|
$num = array_push($this->conditions, new SocketCondition()); |
|
267
|
|
|
|
|
268
|
1 |
|
return $this->conditions[$num - 1]; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
2 |
|
public function createIsFailure() |
|
272
|
|
|
{ |
|
273
|
2 |
|
$num = array_push($this->conditions, new IsFailure()); |
|
274
|
|
|
|
|
275
|
2 |
|
return $this->conditions[$num - 1]; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
6 |
|
public function createIsFileSelected() |
|
279
|
|
|
{ |
|
280
|
6 |
|
$num = array_push($this->conditions, new IsFileSelected()); |
|
281
|
|
|
|
|
282
|
6 |
|
return $this->conditions[$num - 1]; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
1 |
|
public function createMatches() |
|
286
|
|
|
{ |
|
287
|
1 |
|
$num = array_push($this->conditions, new Matches()); |
|
288
|
|
|
|
|
289
|
1 |
|
return $this->conditions[$num - 1]; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
6 |
|
public function createPdoSqlExec() |
|
293
|
|
|
{ |
|
294
|
6 |
|
$num = array_push($this->conditions, new PDOSQLExecTask()); |
|
295
|
|
|
|
|
296
|
6 |
|
return $this->conditions[$num - 1]; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* @param string $elementName |
|
301
|
|
|
* @param Project $project |
|
302
|
|
|
* @throws BuildException |
|
303
|
|
|
* @return Condition |
|
304
|
|
|
*/ |
|
305
|
1 |
|
public function customChildCreator($elementName, Project $project) |
|
306
|
|
|
{ |
|
307
|
1 |
|
$condition = $project->createCondition($elementName); |
|
308
|
1 |
|
$num = array_push($this->conditions, $condition); |
|
309
|
|
|
|
|
310
|
1 |
|
return $this->conditions[$num - 1]; |
|
311
|
|
|
} |
|
312
|
|
|
} |
|
313
|
|
|
|