These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Robo\Task\Testing; |
||
3 | |||
4 | use Robo\Contract\CommandInterface; |
||
5 | use Robo\Contract\PrintedInterface; |
||
6 | use Robo\Task\BaseTask; |
||
7 | |||
8 | /** |
||
9 | * Runs [atoum](http://atoum.org/) tests |
||
10 | * |
||
11 | * ``` php |
||
12 | * <?php |
||
13 | * $this->taskAtoum() |
||
14 | * ->files('path/to/test.php') |
||
15 | * ->configFile('config/dev.php') |
||
16 | * ->run() |
||
17 | * |
||
18 | * ?> |
||
19 | * ``` |
||
20 | */ |
||
21 | class Atoum extends BaseTask implements CommandInterface, PrintedInterface |
||
22 | { |
||
23 | use \Robo\Common\ExecOneCommand; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $command; |
||
29 | |||
30 | /** |
||
31 | * Atoum constructor. |
||
32 | * |
||
33 | * @param null|string $pathToAtoum |
||
34 | * |
||
35 | * @throws \Robo\Exception\TaskException |
||
36 | */ |
||
37 | View Code Duplication | public function __construct($pathToAtoum = null) |
|
38 | { |
||
39 | $this->command = $pathToAtoum; |
||
40 | if (!$this->command) { |
||
41 | $this->command = $this->findExecutable('atoum'); |
||
0 ignored issues
–
show
|
|||
42 | } |
||
43 | if (!$this->command) { |
||
44 | throw new \Robo\Exception\TaskException(__CLASS__, "Neither local atoum nor global composer installation not found"); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Tag or Tags to filter. |
||
50 | * |
||
51 | * @param string|array $tags |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function tags($tags) |
||
56 | { |
||
57 | return $this->addMultipleOption('tags', $tags); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Display result using the light reporter. |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function lightReport() |
||
66 | { |
||
67 | $this->option("--use-light-report"); |
||
68 | |||
69 | return $this; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Display result using the tap reporter. |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | public function tap() |
||
78 | { |
||
79 | $this->option("use-tap-report"); |
||
80 | |||
81 | return $this; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Path to the bootstrap file. |
||
86 | |||
87 | * @param string $file |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function bootstrap($file) |
||
92 | { |
||
93 | $this->option("bootstrap", $file); |
||
94 | |||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Path to the config file. |
||
100 | * |
||
101 | * @param string $file |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function configFile($file) |
||
106 | { |
||
107 | $this->option('-c', $file); |
||
108 | |||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Use atoum's debug mode. |
||
114 | * |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function debug() |
||
118 | { |
||
119 | $this->option("debug"); |
||
120 | |||
121 | return $this; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Test file or test files to run. |
||
126 | * |
||
127 | * @param string|array |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function files($files) |
||
132 | { |
||
133 | return $this->addMultipleOption('f', $files); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Test directory or directories to run. |
||
138 | * |
||
139 | * @param string|array A single directory or a list of directories. |
||
140 | * |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function directories($directories) |
||
144 | { |
||
145 | return $this->addMultipleOption('directories', $directories); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * @param string $option |
||
150 | * @param string|array $values |
||
151 | * |
||
152 | * @return $this |
||
153 | */ |
||
154 | protected function addMultipleOption($option, $values) |
||
155 | { |
||
156 | if (is_string($values)) { |
||
157 | $values = [$values]; |
||
158 | } |
||
159 | |||
160 | foreach ($values as $value) { |
||
161 | $this->option($option, $value); |
||
162 | } |
||
163 | |||
164 | return $this; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | public function getCommand() |
||
171 | { |
||
172 | return $this->command . $this->arguments; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | public function run() |
||
179 | { |
||
180 | $this->printTaskInfo('Running atoum ' . $this->arguments); |
||
181 | |||
182 | return $this->executeCommand($this->getCommand()); |
||
183 | } |
||
184 | } |
||
185 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.