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\PrintedInterface; |
||
6 | use Robo\Task\BaseTask; |
||
7 | use Robo\Contract\CommandInterface; |
||
8 | |||
9 | /** |
||
10 | * Executes Phpspec tests |
||
11 | * |
||
12 | * ``` php |
||
13 | * <?php |
||
14 | * $this->taskPhpspec() |
||
15 | * ->format('pretty') |
||
16 | * ->noInteraction() |
||
17 | * ->run(); |
||
18 | * ?> |
||
19 | * ``` |
||
20 | * |
||
21 | */ |
||
22 | class Phpspec extends BaseTask implements CommandInterface, PrintedInterface |
||
23 | { |
||
24 | use \Robo\Common\ExecOneCommand; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $command; |
||
30 | |||
31 | /** |
||
32 | * @var string[] $formaters |
||
33 | * Available formaters for format option. |
||
34 | */ |
||
35 | protected $formaters = ['progress', 'html', 'pretty', 'junit', 'dot', 'tap']; |
||
36 | |||
37 | /** |
||
38 | * @var array $verbose_levels |
||
39 | * Available verbose levels. |
||
40 | */ |
||
41 | protected $verbose_levels = ['v', 'vv', 'vvv']; |
||
42 | |||
43 | /** |
||
44 | * Phpspec constructor. |
||
45 | * |
||
46 | * @param null|string $pathToPhpspec |
||
47 | * |
||
48 | * @throws \Robo\Exception\TaskException |
||
49 | */ |
||
50 | View Code Duplication | public function __construct($pathToPhpspec = null) |
|
51 | { |
||
52 | $this->command = $pathToPhpspec; |
||
53 | if (!$this->command) { |
||
0 ignored issues
–
show
|
|||
54 | $this->command = $this->findExecutable('phpspec'); |
||
0 ignored issues
–
show
It seems like
$this->findExecutable('phpspec') 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...
|
|||
55 | } |
||
56 | 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...
|
|||
57 | throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Phpspec found"); |
||
58 | } |
||
59 | $this->arg('run'); |
||
60 | } |
||
61 | |||
62 | public function stopOnFail() |
||
63 | { |
||
64 | $this->option('stop-on-failure'); |
||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | public function noCodeGeneration() |
||
69 | { |
||
70 | $this->option('no-code-generation'); |
||
71 | return $this; |
||
72 | } |
||
73 | |||
74 | public function quiet() |
||
75 | { |
||
76 | $this->option('quiet'); |
||
77 | return $this; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @param string $level |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | View Code Duplication | public function verbose($level = 'v') |
|
86 | { |
||
87 | if (!in_array($level, $this->verbose_levels)) { |
||
88 | throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels)); |
||
89 | } |
||
90 | $this->option('-' . $level); |
||
91 | return $this; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function noAnsi() |
||
98 | { |
||
99 | $this->option('no-ansi'); |
||
100 | return $this; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function noInteraction() |
||
107 | { |
||
108 | $this->option('no-interaction'); |
||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param string $config_file |
||
114 | * |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function config($config_file) |
||
118 | { |
||
119 | $this->option('config', $config_file); |
||
120 | return $this; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @param string $formater |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | View Code Duplication | public function format($formater) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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.
Loading history...
|
|||
129 | { |
||
130 | if (!in_array($formater, $this->formaters)) { |
||
131 | throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters)); |
||
132 | } |
||
133 | $this->option('format', $formater); |
||
134 | return $this; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function getCommand() |
||
141 | { |
||
142 | return $this->command . $this->arguments; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | public function run() |
||
149 | { |
||
150 | $this->printTaskInfo('Running phpspec {arguments}', ['arguments' => $this->arguments]); |
||
151 | return $this->executeCommand($this->getCommand()); |
||
152 | } |
||
153 | } |
||
154 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: