| Conditions | 5 |
| Paths | 5 |
| Total Lines | 31 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function run(OutputInterface $output) |
||
| 36 | { |
||
| 37 | foreach ($this->resolveFiles() as $file) { |
||
|
|
|||
| 38 | if ($this->fileSystem->exists($file)) { |
||
| 39 | if (!$this->continueOnError()) { |
||
| 40 | throw new TaskRuntimeException($this->getName(), "File `$file` already exist."); |
||
| 41 | } |
||
| 42 | |||
| 43 | if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) { |
||
| 44 | $output->writeln( |
||
| 45 | [ |
||
| 46 | "", |
||
| 47 | sprintf( |
||
| 48 | "<error> [Error] Task: %s \n Message: %s</error>", |
||
| 49 | $this->getName(), |
||
| 50 | "File `$file` already exist." |
||
| 51 | ), |
||
| 52 | "" |
||
| 53 | ] |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | continue; |
||
| 58 | } |
||
| 59 | |||
| 60 | $this->fileSystem->mkdir([$file]); |
||
| 61 | $output->writeln( |
||
| 62 | ["", sprintf(" <info>[%s]</info> - <comment>Creating %s</comment>", $this->getName(), $file), ""] |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.