1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Robo\Task\Filesystem; |
4
|
|
|
|
5
|
|
|
trait loadTasks |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @param string|string[] $dirs |
9
|
|
|
* |
10
|
|
|
* @return \Robo\Task\Filesystem\CleanDir|\Robo\Collection\CollectionBuilder |
11
|
|
|
*/ |
12
|
|
|
protected function taskCleanDir($dirs) |
13
|
|
|
{ |
14
|
|
|
return $this->task(CleanDir::class, $dirs); |
|
|
|
|
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param string|string[] $dirs |
19
|
|
|
* |
20
|
|
|
* @return \Robo\Task\Filesystem\DeleteDir|\Robo\Collection\CollectionBuilder |
21
|
|
|
*/ |
22
|
|
|
protected function taskDeleteDir($dirs) |
23
|
|
|
{ |
24
|
|
|
return $this->task(DeleteDir::class, $dirs); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param string $prefix |
29
|
|
|
* @param string $base |
30
|
|
|
* @param bool $includeRandomPart |
31
|
|
|
* |
32
|
|
|
* @return \Robo\Task\Filesystem\WorkDir|\Robo\Collection\CollectionBuilder |
33
|
|
|
*/ |
34
|
|
|
protected function taskTmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) |
35
|
|
|
{ |
36
|
|
|
return $this->task(TmpDir::class, $prefix, $base, $includeRandomPart); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $finalDestination |
41
|
|
|
* |
42
|
|
|
* @return \Robo\Task\Filesystem\TmpDir|\Robo\Collection\CollectionBuilder |
43
|
|
|
*/ |
44
|
|
|
protected function taskWorkDir($finalDestination) |
45
|
|
|
{ |
46
|
|
|
return $this->task(WorkDir::class, $finalDestination); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string|string[] $dirs |
51
|
|
|
* |
52
|
|
|
* @return \Robo\Task\Filesystem\CopyDir|\Robo\Collection\CollectionBuilder |
53
|
|
|
*/ |
54
|
|
|
protected function taskCopyDir($dirs) |
55
|
|
|
{ |
56
|
|
|
return $this->task(CopyDir::class, $dirs); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string|string[] $dirs |
61
|
|
|
* |
62
|
|
|
* @return \Robo\Task\Filesystem\MirrorDir|\Robo\Collection\CollectionBuilder |
63
|
|
|
*/ |
64
|
|
|
protected function taskMirrorDir($dirs) |
65
|
|
|
{ |
66
|
|
|
return $this->task(MirrorDir::class, $dirs); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string|string[] $dirs |
71
|
|
|
* |
72
|
|
|
* @return \Robo\Task\Filesystem\FlattenDir|\Robo\Collection\CollectionBuilder |
73
|
|
|
*/ |
74
|
|
|
protected function taskFlattenDir($dirs) |
75
|
|
|
{ |
76
|
|
|
return $this->task(FlattenDir::class, $dirs); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return \Robo\Task\Filesystem\FilesystemStack|\Robo\Collection\CollectionBuilder |
81
|
|
|
*/ |
82
|
|
|
protected function taskFilesystemStack() |
83
|
|
|
{ |
84
|
|
|
return $this->task(FilesystemStack::class); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.