1 | <?php |
||
21 | class PHPUnit extends Tester |
||
22 | { |
||
23 | /** |
||
24 | * @var \ParaTest\Console\Commands\ParaTestCommand |
||
25 | */ |
||
26 | protected $command; |
||
27 | |||
28 | /** |
||
29 | * Configures the ParaTestCommand with PHPUnit specific |
||
30 | * definitions. |
||
31 | * |
||
32 | * @param Command $command |
||
33 | */ |
||
34 | 8 | public function configure(Command $command) |
|
51 | |||
52 | /** |
||
53 | * Executes the PHPUnit Runner. Will Display help if no config and no path |
||
54 | * supplied. |
||
55 | * |
||
56 | * @param InputInterface $input |
||
57 | * @param OutputInterface $output |
||
58 | * |
||
59 | * @return int|mixed |
||
60 | */ |
||
61 | public function execute(InputInterface $input, OutputInterface $output) |
||
62 | { |
||
63 | if (!$this->hasConfig($input) && !$this->hasPath($input)) { |
||
64 | $this->displayHelp($input, $output); |
||
65 | } |
||
66 | |||
67 | if ($input->getOption('runner') === 'WrapperRunner') { |
||
68 | $runner = new WrapperRunner($this->getRunnerOptions($input)); |
||
69 | } else { |
||
70 | if ($input->getOption('runner') !== '') { |
||
71 | // because we want to have to bootstrap script inherited before check/initialization |
||
72 | $runnerOption = $this->getRunnerOptions($input); |
||
73 | $runnerClass = $input->getOption('runner'); |
||
74 | if (null !== $runnerClass && class_exists($runnerClass)) { |
||
75 | $runner = new $runnerClass($runnerOption); |
||
76 | } |
||
77 | } |
||
78 | } |
||
79 | |||
80 | if (!isset($runner)) { |
||
81 | $runner = new Runner($this->getRunnerOptions($input)); |
||
82 | } |
||
83 | |||
84 | $runner->run(); |
||
85 | |||
86 | return $runner->getExitCode(); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Returns whether or not a test path has been supplied |
||
91 | * via option or regular input. |
||
92 | * |
||
93 | * @param InputInterface $input |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | protected function hasPath(InputInterface $input) |
||
104 | |||
105 | /** |
||
106 | * Is there a PHPUnit xml configuration present. |
||
107 | * |
||
108 | * @param InputInterface $input |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | 4 | protected function hasConfig(InputInterface $input): bool |
|
116 | |||
117 | /** |
||
118 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
119 | * |
||
120 | * @return \ParaTest\Runners\PHPUnit\Configuration|bool |
||
121 | */ |
||
122 | 4 | protected function getConfig(InputInterface $input) |
|
138 | |||
139 | /** |
||
140 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
141 | * |
||
142 | * @throws \RuntimeException |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | 4 | public function getRunnerOptions(InputInterface $input): array |
|
163 | |||
164 | /** |
||
165 | * Require the bootstrap. If the file is specified, but does not exist |
||
166 | * then an exception will be raised. |
||
167 | * |
||
168 | * @param $file |
||
169 | * |
||
170 | * @throws \RuntimeException |
||
171 | */ |
||
172 | 5 | public function requireBootstrap(string $file) |
|
185 | |||
186 | /** |
||
187 | * This function limits the scope of a required file |
||
188 | * so that variables defined in it do not break |
||
189 | * this object's configuration. |
||
190 | * |
||
191 | * @param mixed $file |
||
192 | */ |
||
193 | 5 | protected function scopedRequire(string $file) |
|
199 | |||
200 | /** |
||
201 | * Return whether or not code coverage information should be collected. |
||
202 | * |
||
203 | * @param $options |
||
204 | * |
||
205 | * @return bool |
||
206 | */ |
||
207 | 4 | protected function hasCoverage(array $options): bool |
|
214 | |||
215 | /** |
||
216 | * Fetch the path to the bootstrap file. |
||
217 | * |
||
218 | * @param InputInterface $input |
||
219 | * @param array $options |
||
220 | * |
||
221 | * @return string |
||
222 | */ |
||
223 | 4 | protected function getBootstrapFile(InputInterface $input, array $options): string |
|
238 | } |
||
239 |
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 given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.