1 | <?php |
||
12 | class Options |
||
13 | { |
||
14 | /** |
||
15 | * The number of processes to run at a time |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $processes; |
||
20 | |||
21 | /** |
||
22 | * The test path pointing to tests that will |
||
23 | * be run |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $path; |
||
28 | |||
29 | /** |
||
30 | * The path to the PHPUnit binary that will be run |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $phpunit; |
||
35 | |||
36 | /** |
||
37 | * Determines whether or not ParaTest runs in |
||
38 | * functional mode. If enabled, ParaTest will run |
||
39 | * every test method in a separate process |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $functional; |
||
44 | |||
45 | /** |
||
46 | * Prevents starting new tests after a test has failed. |
||
47 | * |
||
48 | * @var boolean |
||
49 | */ |
||
50 | protected $stopOnFailure; |
||
51 | |||
52 | /** |
||
53 | * A collection of post-processed option values. This is the collection |
||
54 | * containing ParaTest specific options |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $filtered; |
||
59 | |||
60 | /** |
||
61 | * A collection of option values directly corresponding |
||
62 | * to certain annotations - i.e group |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $annotations = []; |
||
67 | |||
68 | 42 | public function __construct($opts = []) |
|
105 | |||
106 | /** |
||
107 | * Public read accessibility |
||
108 | * |
||
109 | * @param $var |
||
110 | * @return mixed |
||
111 | */ |
||
112 | 40 | public function __get($var) |
|
116 | |||
117 | /** |
||
118 | * Returns a collection of ParaTest's default |
||
119 | * option values |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | 42 | protected static function defaults() |
|
139 | |||
140 | /** |
||
141 | * Get the path to phpunit |
||
142 | * First checks if a Windows batch script is in the composer vendors directory. |
||
143 | * Composer automatically handles creating a .bat file, so if on windows this should be the case. |
||
144 | * Second look for the phpunit binary under nix |
||
145 | * Defaults to phpunit on the users PATH |
||
146 | * @return string $phpunit the path to phpunit |
||
147 | */ |
||
148 | 42 | protected static function phpunit() |
|
164 | |||
165 | /** |
||
166 | * Get the path to the vendor directory |
||
167 | * First assumes vendor directory is accessible from src (i.e development) |
||
168 | * Second assumes vendor directory is accessible within src |
||
169 | */ |
||
170 | 42 | protected static function vendorDir() |
|
179 | |||
180 | /** |
||
181 | * Filter options to distinguish between paratest |
||
182 | * internal options and any other options |
||
183 | * @param array $options |
||
184 | * @return array |
||
185 | */ |
||
186 | 42 | protected function filterOptions($options) |
|
207 | |||
208 | /** |
||
209 | * Take an array of filtered options and return a |
||
210 | * configuration path |
||
211 | * |
||
212 | * @param $filtered |
||
213 | * @return string|null |
||
214 | */ |
||
215 | 42 | protected function getConfigurationPath($filtered) |
|
222 | |||
223 | /** |
||
224 | * Retrieve the default configuration given a path (directory or file). |
||
225 | * This will search into the directory, if a directory is specified |
||
226 | * |
||
227 | * @param string $path The path to search into |
||
228 | * @param string $default The default value to give back |
||
229 | * @return string|null |
||
230 | */ |
||
231 | 42 | private function getDefaultConfigurationForPath($path = '.', $default = null) |
|
247 | |||
248 | /** |
||
249 | * Load options that are represented by annotations |
||
250 | * inside of tests i.e @group group1 = --group group1 |
||
251 | */ |
||
252 | 42 | protected function initAnnotations() |
|
261 | |||
262 | /** |
||
263 | * @param $file |
||
264 | * @return bool |
||
265 | */ |
||
266 | 42 | private function isFile($file) |
|
270 | } |
||
271 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: