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 | /* |
||
4 | * This file is part of the `liip/LiipImagineBundle` project. |
||
5 | * |
||
6 | * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE.md |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Liip\ImagineBundle\Command; |
||
13 | |||
14 | use Imagine\Exception\RuntimeException; |
||
15 | use Liip\ImagineBundle\Component\Console\Style\ImagineStyle; |
||
16 | use Liip\ImagineBundle\Imagine\Cache\CacheManager; |
||
17 | use Liip\ImagineBundle\Imagine\Filter\FilterManager; |
||
18 | use Symfony\Component\Console\Input\InputInterface; |
||
19 | use Symfony\Component\Console\Output\OutputInterface; |
||
20 | |||
21 | /** |
||
22 | * @internal |
||
23 | */ |
||
24 | trait CacheCommandTrait |
||
25 | { |
||
26 | /** |
||
27 | * @var CacheManager |
||
28 | */ |
||
29 | private $cacheManager; |
||
30 | |||
31 | /** |
||
32 | * @var FilterManager |
||
33 | */ |
||
34 | private $filterManager; |
||
35 | |||
36 | /** |
||
37 | * @var ImagineStyle |
||
38 | */ |
||
39 | private $io; |
||
40 | |||
41 | /** |
||
42 | * @var bool |
||
43 | */ |
||
44 | private $outputMachineReadable; |
||
45 | |||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | private $failures = 0; |
||
50 | |||
51 | private function setupOutputStyle(InputInterface $input, OutputInterface $output): void |
||
52 | { |
||
53 | $this->outputMachineReadable = $input->getOption('as-script'); |
||
0 ignored issues
–
show
|
|||
54 | $this->io = new ImagineStyle($input, $output, $this->outputMachineReadable ? false : !$input->getOption('no-colors')); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return array[] |
||
59 | */ |
||
60 | private function resolveInputFiltersAndPaths(InputInterface $input): array |
||
61 | { |
||
62 | return [ |
||
63 | $input->getArgument('paths'), |
||
64 | $this->normalizeFilterList($input->getOption('filter')), |
||
65 | ]; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param string[] $filters |
||
70 | * |
||
71 | * @return string[] |
||
72 | */ |
||
73 | private function normalizeFilterList(array $filters): array |
||
74 | { |
||
75 | if (0 < \count($filters)) { |
||
76 | return $filters; |
||
77 | } |
||
78 | |||
79 | if (0 < \count($filters = array_keys((array) $this->filterManager->getFilterConfiguration()->all()))) { |
||
80 | return $filters; |
||
81 | } |
||
82 | |||
83 | throw new RuntimeException('No filters have been defined in the active configuration!'); |
||
84 | } |
||
85 | |||
86 | private function outputCommandHeader(): void |
||
87 | { |
||
88 | if (!$this->outputMachineReadable) { |
||
89 | $this->io->title($this->getName(), 'liip/imagine-bundle'); |
||
0 ignored issues
–
show
It seems like
getName() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param string[] $images |
||
95 | * @param string[] $filters |
||
96 | */ |
||
97 | private function outputCommandResult(array $images, array $filters, string $singularAction): void |
||
98 | { |
||
99 | if (!$this->outputMachineReadable) { |
||
100 | $wordPluralizer = function (int $count, string $singular) { |
||
101 | return 1 === $count ? $singular : sprintf('%ss', $singular); |
||
102 | }; |
||
103 | |||
104 | $imagePathsSize = \count($images); |
||
105 | $filterSetsSize = \count($filters); |
||
106 | $allActionsSize = 0 === $imagePathsSize ? $filterSetsSize : ($filterSetsSize * $imagePathsSize) - $this->failures; |
||
107 | $allActionsWord = $wordPluralizer($allActionsSize, $singularAction); |
||
108 | |||
109 | $rootTextOutput = sprintf('Completed %d %s', $allActionsSize, $allActionsWord); |
||
110 | |||
111 | $detailTextFormat = '%d %s'; |
||
112 | |||
113 | $detailTextsOutput = []; |
||
114 | |||
115 | if (0 !== $imagePathsSize) { |
||
116 | $detailTextsOutput[] = sprintf($detailTextFormat, $imagePathsSize, $wordPluralizer($imagePathsSize, 'image')); |
||
117 | } |
||
118 | |||
119 | if (0 !== $filterSetsSize) { |
||
120 | $detailTextsOutput[] = sprintf($detailTextFormat, $filterSetsSize, $wordPluralizer($filterSetsSize, 'filter')); |
||
121 | } |
||
122 | |||
123 | if (!empty($detailTextsOutput)) { |
||
124 | $rootTextOutput = sprintf('%s (%s)', $rootTextOutput, implode(', ', $detailTextsOutput)); |
||
125 | } |
||
126 | |||
127 | if ($this->failures) { |
||
128 | $this->io->critBlock(sprintf('%s %%s', $rootTextOutput), [ |
||
129 | sprintf('[encountered %d failures]', $this->failures), |
||
130 | ]); |
||
131 | } else { |
||
132 | $this->io->okayBlock($rootTextOutput); |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 | |||
137 | private function getResultCode(): int |
||
138 | { |
||
139 | return 0 === $this->failures ? 0 : 255; |
||
140 | } |
||
141 | } |
||
142 |
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.