1 | <?php |
||
36 | class RoboFile extends AbstractRoboFile |
||
|
|||
37 | { |
||
38 | |||
39 | /** |
||
40 | * Load the appserver.io base tasks. |
||
41 | * |
||
42 | * @var \AppserverIo\RoboTasks\Base\loadTasks |
||
43 | */ |
||
44 | use AppserverIo\RoboTasks\Base\loadTasks; |
||
45 | |||
46 | /** |
||
47 | * Initializes the default configuration. |
||
48 | */ |
||
49 | public function __construct() |
||
50 | { |
||
51 | |||
52 | // call parent constructor |
||
53 | parent::__construct(); |
||
54 | |||
55 | // initialize the default configuration |
||
56 | Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, 'dist'), sprintf('%s/dist', getcwd())); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Run's the composer install command. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | public function composerInstall() |
||
65 | { |
||
66 | // optimize autoloader with custom path |
||
67 | $this->taskComposerInstall() |
||
68 | ->preferDist() |
||
69 | ->optimizeAutoloader() |
||
70 | ->run(); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Run's the composer update command. |
||
75 | * |
||
76 | * @return void |
||
77 | */ |
||
78 | public function composerUpdate() |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Clean up the environment for a new build. |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | public function clean() |
||
93 | { |
||
94 | $this->taskDeleteDir($this->getTargetDir())->run(); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Prepare's the environment for a new build. |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | public function prepare() |
||
103 | { |
||
104 | $this->taskFileSystemStack() |
||
105 | ->mkdir($this->getDistDir()) |
||
106 | ->mkdir($this->getTargetDir()) |
||
107 | ->mkdir($this->getReportsDir()) |
||
108 | ->run(); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Run's the PHPMD. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | public function runMd() |
||
117 | { |
||
118 | |||
119 | // run the mess detector |
||
120 | $this->_exec( |
||
121 | sprintf( |
||
122 | '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit || exit 0', |
||
123 | $this->getVendorDir(), |
||
124 | $this->getSrcDir(), |
||
125 | $this->getTargetDir() |
||
126 | ) |
||
127 | ); |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Run's the PHPCPD. |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | public function runCpd() |
||
145 | ) |
||
146 | ); |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * Run's the PHPCodeSniffer. |
||
151 | * |
||
152 | * @return void |
||
153 | */ |
||
154 | public function runCs() |
||
164 | ) |
||
165 | ); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * Run's the PHPUnit tests. |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | public function runTests() |
||
174 | { |
||
175 | |||
176 | // run PHPUnit |
||
177 | $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->getVendorDir())) |
||
178 | ->configFile('phpunit.xml') |
||
179 | ->run(); |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * The complete build process. |
||
184 | * |
||
185 | * @return void |
||
186 | */ |
||
187 | public function build() |
||
188 | { |
||
189 | $this->clean(); |
||
190 | $this->prepare(); |
||
191 | $this->runCs(); |
||
192 | $this->runCpd(); |
||
193 | $this->runMd(); |
||
194 | $this->runTests(); |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * Returns the distribution directory. |
||
199 | * |
||
200 | * @return string The distribution directory |
||
201 | */ |
||
202 | protected function getDistDir() |
||
205 | } |
||
206 | } |
||
207 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.