This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Robo\Task\Testing; |
||
4 | |||
5 | use Robo\Contract\CommandInterface; |
||
6 | use Robo\Contract\PrintedInterface; |
||
7 | use Robo\Task\BaseTask; |
||
8 | |||
9 | /** |
||
10 | * Runs [atoum](http://atoum.org/) tests |
||
11 | * |
||
12 | * ``` php |
||
13 | * <?php |
||
14 | * $this->taskAtoum() |
||
15 | * ->files('path/to/test.php') |
||
16 | * ->configFile('config/dev.php') |
||
17 | * ->run() |
||
18 | * |
||
19 | * ?> |
||
20 | * ``` |
||
21 | */ |
||
22 | class Atoum extends BaseTask implements CommandInterface, PrintedInterface |
||
23 | { |
||
24 | use \Robo\Common\ExecOneCommand; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $command; |
||
30 | |||
31 | /** |
||
32 | * Atoum constructor. |
||
33 | * |
||
34 | * @param null|string $pathToAtoum |
||
35 | * |
||
36 | * @throws \Robo\Exception\TaskException |
||
37 | */ |
||
38 | View Code Duplication | public function __construct($pathToAtoum = null) |
|
0 ignored issues
–
show
|
|||
39 | { |
||
40 | $this->command = $pathToAtoum; |
||
41 | if (!$this->command) { |
||
0 ignored issues
–
show
The expression
$this->command of type null|string is loosely compared to false ; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
Loading history...
|
|||
42 | $this->command = $this->findExecutable('atoum'); |
||
0 ignored issues
–
show
It seems like
$this->findExecutable('atoum') can also be of type false . However, the property $command is declared as type string . Maybe add an additional type check?
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 Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
43 | } |
||
44 | if (!$this->command) { |
||
0 ignored issues
–
show
The expression
$this->command of type string|false is loosely compared to false ; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
Loading history...
|
|||
45 | throw new \Robo\Exception\TaskException(__CLASS__, "Neither local atoum nor global composer installation not found"); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Tag or Tags to filter. |
||
51 | * |
||
52 | * @param string|string[] $tags |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function tags($tags) |
||
57 | { |
||
58 | return $this->addMultipleOption('tags', $tags); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Display result using the light reporter. |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function lightReport() |
||
67 | { |
||
68 | $this->option("--use-light-report"); |
||
69 | |||
70 | return $this; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Display result using the tap reporter. |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function tap() |
||
79 | { |
||
80 | $this->option("use-tap-report"); |
||
81 | |||
82 | return $this; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Path to the bootstrap file. |
||
87 | |||
88 | * @param string $file |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | public function bootstrap($file) |
||
93 | { |
||
94 | $this->option("bootstrap", $file); |
||
95 | |||
96 | return $this; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Path to the config file. |
||
101 | * |
||
102 | * @param string $file |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function configFile($file) |
||
107 | { |
||
108 | $this->option('-c', $file); |
||
109 | |||
110 | return $this; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Use atoum's debug mode. |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | public function debug() |
||
119 | { |
||
120 | $this->option("debug"); |
||
121 | |||
122 | return $this; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Test file or test files to run. |
||
127 | * |
||
128 | * @param string|string[] |
||
129 | * |
||
130 | * @return $this |
||
131 | */ |
||
132 | public function files($files) |
||
133 | { |
||
134 | return $this->addMultipleOption('f', $files); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * Test directory or directories to run. |
||
139 | * |
||
140 | * @param string|string[] |
||
141 | * A single directory or a list of directories. |
||
142 | * |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function directories($directories) |
||
146 | { |
||
147 | return $this->addMultipleOption('directories', $directories); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @param string $option |
||
152 | * @param string|string[] $values |
||
153 | * |
||
154 | * @return $this |
||
155 | */ |
||
156 | protected function addMultipleOption($option, $values) |
||
157 | { |
||
158 | if (is_string($values)) { |
||
159 | $values = [$values]; |
||
160 | } |
||
161 | |||
162 | foreach ($values as $value) { |
||
163 | $this->option($option, $value); |
||
164 | } |
||
165 | |||
166 | return $this; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | public function getCommand() |
||
173 | { |
||
174 | return $this->command . $this->arguments; |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * {@inheritdoc} |
||
179 | */ |
||
180 | public function run() |
||
181 | { |
||
182 | $this->printTaskInfo('Running atoum ' . $this->arguments); |
||
183 | |||
184 | return $this->executeCommand($this->getCommand()); |
||
185 | } |
||
186 | } |
||
187 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.