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
|
|
|
* This is an abstract task that should be used by all those tasks that |
22
|
|
|
* require to include or exclude files based on pattern matching. |
23
|
|
|
* |
24
|
|
|
* This is very closely based on the ANT class of the same name. |
25
|
|
|
* |
26
|
|
|
* @author Hans Lellelid <[email protected]> (Phing) |
27
|
|
|
* @author Arnout J. Kuiper <[email protected]> (Ant) |
28
|
|
|
* @author Stefano Mazzocchi <[email protected]> (Ant) |
29
|
|
|
* @author Sam Ruby <[email protected]> (Ant) |
30
|
|
|
* @author Jon S. Stevens <[email protected]> (Ant |
31
|
|
|
* @author Stefan Bodewig <[email protected]> (Ant) |
32
|
|
|
* @author Bruce Atherton <[email protected]> (Ant) |
33
|
|
|
* @package phing.tasks.system |
34
|
|
|
*/ |
35
|
|
|
abstract class MatchingTask extends Task implements SelectorContainer |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var boolean |
40
|
|
|
*/ |
41
|
|
|
protected $useDefaultExcludes = true; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var FileSet |
45
|
|
|
*/ |
46
|
|
|
protected $fileset; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Create instance; set fileset to new FileSet. |
50
|
|
|
*/ |
51
|
14 |
|
public function __construct() |
52
|
|
|
{ |
53
|
14 |
|
parent::__construct(); |
54
|
14 |
|
$this->fileset = new FileSet(); |
55
|
14 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @see ProjectComponent::setProject() |
59
|
|
|
* @param Project $project |
60
|
|
|
*/ |
61
|
14 |
|
public function setProject($project) |
62
|
|
|
{ |
63
|
14 |
|
parent::setProject($project); |
64
|
14 |
|
$this->fileset->setProject($project); |
65
|
14 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* add a name entry on the include list |
69
|
|
|
* |
70
|
|
|
* @return PatternSetNameEntry |
71
|
|
|
*/ |
72
|
|
|
public function createInclude() |
73
|
|
|
{ |
74
|
|
|
return $this->fileset->createInclude(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* add a name entry on the include files list |
79
|
|
|
* |
80
|
|
|
* @return PatternSetNameEntry |
81
|
|
|
*/ |
82
|
|
|
public function createIncludesFile() |
83
|
|
|
{ |
84
|
|
|
return $this->fileset->createIncludesFile(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* add a name entry on the exclude list |
89
|
|
|
* |
90
|
|
|
* @return PatternSetNameEntry |
91
|
|
|
*/ |
92
|
|
|
public function createExclude() |
93
|
|
|
{ |
94
|
|
|
return $this->fileset->createExclude(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* add a name entry on the include files list |
99
|
|
|
* |
100
|
|
|
* @return PatternSetNameEntry |
101
|
|
|
*/ |
102
|
|
|
public function createExcludesFile() |
103
|
|
|
{ |
104
|
|
|
return $this->fileset->createExcludesFile(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* add a set of patterns |
109
|
|
|
* |
110
|
|
|
* @return PatternSet |
111
|
|
|
*/ |
112
|
|
|
public function createPatternSet() |
113
|
|
|
{ |
114
|
|
|
return $this->fileset->createPatternSet(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Sets the set of include patterns. Patterns may be separated by a comma |
119
|
|
|
* or a space. |
120
|
|
|
* |
121
|
|
|
* @param string $includes the string containing the include patterns |
122
|
|
|
* @return void |
123
|
|
|
*/ |
124
|
|
|
public function setIncludes($includes) |
125
|
|
|
{ |
126
|
|
|
$this->fileset->setIncludes($includes); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Sets the set of exclude patterns. Patterns may be separated by a comma |
131
|
|
|
* or a space. |
132
|
|
|
* |
133
|
|
|
* @param string $excludes the string containing the exclude patterns |
134
|
|
|
*/ |
135
|
|
|
public function setExcludes($excludes) |
136
|
|
|
{ |
137
|
|
|
$this->fileset->setExcludes($excludes); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Sets whether default exclusions should be used or not. |
142
|
|
|
* |
143
|
|
|
* @param boolean $useDefaultExcludes "true"|"on"|"yes" when default exclusions |
144
|
|
|
* should be used, "false"|"off"|"no" when they |
145
|
|
|
* shouldn't be used. |
146
|
|
|
*/ |
147
|
|
|
public function setDefaultexcludes(bool $useDefaultExcludes) |
148
|
|
|
{ |
149
|
|
|
$this->useDefaultExcludes = $useDefaultExcludes; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns the directory scanner needed to access the files to process. |
154
|
|
|
* |
155
|
|
|
* @param PhingFile $baseDir |
156
|
|
|
* @throws BuildException |
157
|
|
|
* @return DirectoryScanner |
158
|
|
|
*/ |
159
|
|
|
protected function getDirectoryScanner(PhingFile $baseDir) |
160
|
|
|
{ |
161
|
|
|
$this->fileset->setDir($baseDir); |
162
|
|
|
$this->fileset->setDefaultexcludes($this->useDefaultExcludes); |
163
|
|
|
|
164
|
|
|
return $this->fileset->getDirectoryScanner($this->project); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Sets the name of the file containing the includes patterns. |
169
|
|
|
* |
170
|
|
|
* @param PhingFile $includesfile A string containing the filename to fetch |
171
|
|
|
* the include patterns from. |
172
|
|
|
* @return void |
173
|
|
|
*/ |
174
|
|
|
public function setIncludesfile(PhingFile $includesfile) |
175
|
|
|
{ |
176
|
|
|
$this->fileset->setIncludesfile($includesfile); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Sets the name of the file containing the includes patterns. |
181
|
|
|
* |
182
|
|
|
* @param PhingFile $excludesfile A string containing the filename to fetch |
183
|
|
|
* the include patterns from. |
184
|
|
|
* @return void |
185
|
|
|
*/ |
186
|
|
|
public function setExcludesfile(PhingFile $excludesfile) |
187
|
|
|
{ |
188
|
|
|
$this->fileset->setExcludesfile($excludesfile); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Sets case sensitivity of the file system |
193
|
|
|
* |
194
|
|
|
* @param boolean $isCaseSensitive "true"|"on"|"yes" if file system is case |
195
|
|
|
* sensitive, "false"|"off"|"no" when not. |
196
|
|
|
* @return void |
197
|
|
|
*/ |
198
|
|
|
public function setCaseSensitive($isCaseSensitive) |
199
|
|
|
{ |
200
|
|
|
$this->fileset->setCaseSensitive($isCaseSensitive); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Sets whether or not symbolic links should be followed. |
205
|
|
|
* |
206
|
|
|
* @param boolean $followSymlinks whether or not symbolic links should be followed |
207
|
|
|
* @return void |
208
|
|
|
*/ |
209
|
|
|
public function setFollowSymlinks($followSymlinks) |
210
|
|
|
{ |
211
|
|
|
$this->fileset->setExpandSymbolicLinks($followSymlinks); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Indicates whether there are any selectors here. |
216
|
|
|
* |
217
|
|
|
* @return boolean Whether any selectors are in this container |
218
|
|
|
*/ |
219
|
|
|
public function hasSelectors() |
220
|
|
|
{ |
221
|
|
|
return $this->fileset->hasSelectors(); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Gives the count of the number of selectors in this container |
226
|
|
|
* |
227
|
|
|
* @return int The number of selectors in this container |
228
|
|
|
*/ |
229
|
|
|
public function count() |
230
|
|
|
{ |
231
|
|
|
return $this->fileset->count(); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Returns the set of selectors as an array. |
236
|
|
|
* |
237
|
|
|
* @param Project $p |
238
|
|
|
* @return array FileSelector[] An array of selectors in this container |
239
|
|
|
*/ |
240
|
|
|
public function getSelectors(Project $p) |
241
|
|
|
{ |
242
|
|
|
return $this->fileset->getSelectors($p); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Returns an enumerator for accessing the set of selectors. |
247
|
|
|
* |
248
|
|
|
* @return array an enumerator that goes through each of the selectors |
249
|
|
|
*/ |
250
|
|
|
public function selectorElements() |
251
|
|
|
{ |
252
|
|
|
return $this->fileset->selectorElements(); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Add a new selector into this container. |
257
|
|
|
* |
258
|
|
|
* @param FileSelector $selector the new selector to add |
259
|
|
|
*/ |
260
|
|
|
public function appendSelector(FileSelector $selector) |
261
|
|
|
{ |
262
|
|
|
$this->fileset->appendSelector($selector); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/* Methods below all add specific selectors */ |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* add a "Select" selector entry on the selector list |
269
|
|
|
*/ |
270
|
|
|
public function addSelector(SelectSelector $selector) |
271
|
|
|
{ |
272
|
|
|
$this->fileset->addSelector($selector); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* add an "And" selector entry on the selector list |
277
|
|
|
*/ |
278
|
|
|
public function addAnd(AndSelector $selector) |
279
|
|
|
{ |
280
|
|
|
$this->fileset->addAnd($selector); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* add an "Or" selector entry on the selector list |
285
|
|
|
*/ |
286
|
|
|
public function addOr(OrSelector $selector) |
287
|
|
|
{ |
288
|
|
|
$this->fileset->addOr($selector); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* add a "Not" selector entry on the selector list |
293
|
|
|
*/ |
294
|
|
|
public function addNot(NotSelector $selector) |
295
|
|
|
{ |
296
|
|
|
$this->fileset->addNot($selector); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* add a "None" selector entry on the selector list |
301
|
|
|
*/ |
302
|
|
|
public function addNone(NoneSelector $selector) |
303
|
|
|
{ |
304
|
|
|
$this->fileset->addNone($selector); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* add a majority selector entry on the selector list |
309
|
|
|
*/ |
310
|
|
|
public function addMajority(MajoritySelector $selector) |
311
|
|
|
{ |
312
|
|
|
$this->fileset->addMajority($selector); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* add a selector date entry on the selector list |
317
|
|
|
*/ |
318
|
|
|
public function addDate(DateSelector $selector) |
319
|
|
|
{ |
320
|
|
|
$this->fileset->addDate($selector); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* add a selector size entry on the selector list |
325
|
|
|
*/ |
326
|
|
|
public function addSize(SizeSelector $selector) |
327
|
|
|
{ |
328
|
|
|
$this->fileset->addSize($selector); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* add a selector filename entry on the selector list |
333
|
|
|
*/ |
334
|
|
|
public function addFilename(FilenameSelector $selector) |
335
|
|
|
{ |
336
|
|
|
$this->fileset->addFilename($selector); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* add an extended selector entry on the selector list |
341
|
|
|
* |
342
|
|
|
* @return ExtendSelector |
343
|
|
|
*/ |
344
|
|
|
public function addCustom(ExtendSelector $selector) |
345
|
|
|
{ |
346
|
|
|
return $this->fileset->addCustom($selector); |
|
|
|
|
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* add a contains selector entry on the selector list |
351
|
|
|
*/ |
352
|
|
|
public function addContains(ContainsSelector $selector) |
353
|
|
|
{ |
354
|
|
|
$this->fileset->addContains($selector); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* add a present selector entry on the selector list |
359
|
|
|
*/ |
360
|
|
|
public function addPresent(PresentSelector $selector) |
361
|
|
|
{ |
362
|
|
|
$this->fileset->addPresent($selector); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* add a depth selector entry on the selector list |
367
|
|
|
*/ |
368
|
|
|
public function addDepth(DepthSelector $selector) |
369
|
|
|
{ |
370
|
|
|
$this->fileset->addDepth($selector); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* add a depends selector entry on the selector list |
375
|
|
|
*/ |
376
|
|
|
public function addDepend(DependSelector $selector) |
377
|
|
|
{ |
378
|
|
|
$this->fileset->addDepend($selector); |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* add a executable selector entry on the selector list |
383
|
|
|
*/ |
384
|
|
|
public function addExecutable(ExecutableSelector $selector) |
385
|
|
|
{ |
386
|
|
|
$this->fileset->addExecutable($selector); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* add a readable selector entry on the selector list |
391
|
|
|
*/ |
392
|
|
|
public function addReadable(ReadableSelector $selector) |
393
|
|
|
{ |
394
|
|
|
$this->fileset->addReadable($selector); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* add a writable selector entry on the selector list |
399
|
|
|
*/ |
400
|
|
|
public function addWritable(WritableSelector $selector) |
401
|
|
|
{ |
402
|
|
|
$this->fileset->addWritable($selector); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* add a different selector entry on the selector list |
407
|
|
|
*/ |
408
|
|
|
public function addDifferent(DifferentSelector $selector) |
409
|
|
|
{ |
410
|
|
|
$this->fileset->addDifferent($selector); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* add a different selector entry on the selector list |
415
|
|
|
*/ |
416
|
|
|
public function addModified(ModifiedSelector $selector) |
417
|
|
|
{ |
418
|
|
|
$this->fileset->addModified($selector); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* add a type selector entry on the selector list |
423
|
|
|
* |
424
|
|
|
* @param TypeSelector $selector |
425
|
|
|
*/ |
426
|
|
|
public function addType(TypeSelector $selector) |
427
|
|
|
{ |
428
|
|
|
$this->fileset->addType($selector); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* add a contains selector entry on the selector list |
433
|
|
|
* |
434
|
|
|
* @param ContainsRegexpSelector $selector |
435
|
|
|
*/ |
436
|
|
|
public function addContainsRegexp(ContainsRegexpSelector $selector) |
437
|
|
|
{ |
438
|
|
|
$this->fileset->addContainsRegexp($selector); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
public function addSymlink(SymlinkSelector $selector) |
442
|
|
|
{ |
443
|
|
|
$this->fileset->addSymlink($selector); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Accessor for the implict fileset. |
448
|
|
|
* |
449
|
|
|
* @return FileSet |
450
|
|
|
*/ |
451
|
|
|
final protected function getImplicitFileSet() |
452
|
|
|
{ |
453
|
|
|
return $this->fileset; |
454
|
|
|
} |
455
|
|
|
} |
456
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.