netresearch /
kite
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 | * See class comment |
||
| 4 | * |
||
| 5 | * PHP Version 5 |
||
| 6 | * |
||
| 7 | * @category Netresearch |
||
| 8 | * @package Netresearch\Kite |
||
| 9 | * @subpackage Service |
||
| 10 | * @author Christian Opitz <[email protected]> |
||
| 11 | * @license http://www.netresearch.de Netresearch Copyright |
||
| 12 | * @link http://www.netresearch.de |
||
| 13 | */ |
||
| 14 | |||
| 15 | namespace Netresearch\Kite\Service; |
||
| 16 | |||
| 17 | use Netresearch\Kite\Console\Output\Output; |
||
| 18 | |||
| 19 | use Symfony\Component\Console\Application; |
||
| 20 | use Symfony\Component\Console\Helper; |
||
| 21 | use Symfony\Component\Console\Input\InputInterface; |
||
| 22 | use Symfony\Component\Console\Output\BufferedOutput; |
||
| 23 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * A shell command service |
||
| 27 | * |
||
| 28 | * @category Netresearch |
||
| 29 | * @package Netresearch\Kite |
||
| 30 | * @subpackage Service |
||
| 31 | * @author Christian Opitz <[email protected]> |
||
| 32 | * @license http://www.netresearch.de Netresearch Copyright |
||
| 33 | * @link http://www.netresearch.de |
||
| 34 | */ |
||
| 35 | class Console |
||
| 36 | { |
||
| 37 | /** |
||
| 38 | * @var Output |
||
| 39 | */ |
||
| 40 | protected $output = null; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var Output Second instance for debug output (all) |
||
| 44 | */ |
||
| 45 | private $debugOutput; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var \Symfony\Component\Console\Input\InputInterface |
||
| 49 | */ |
||
| 50 | protected $input = null; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var Application |
||
| 54 | */ |
||
| 55 | protected $application; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var int |
||
| 59 | */ |
||
| 60 | private $outputType = OutputInterface::OUTPUT_NORMAL; |
||
| 61 | |||
| 62 | private $previousVerbosities = array(); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var Filesystem |
||
| 66 | */ |
||
| 67 | protected $filesystem; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var Factory |
||
| 71 | */ |
||
| 72 | protected $factory; |
||
| 73 | |||
| 74 | protected $config; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Console constructor. |
||
| 78 | * |
||
| 79 | * @param Config $config Config |
||
| 80 | */ |
||
| 81 | public function __construct(Config $config) |
||
| 82 | { |
||
| 83 | $this->config = $config; |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Get the config |
||
| 88 | * |
||
| 89 | * @return Config |
||
| 90 | */ |
||
| 91 | public function getConfig() |
||
| 92 | { |
||
| 93 | return $this->config; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Get the factory |
||
| 98 | * |
||
| 99 | * @return Factory |
||
| 100 | */ |
||
| 101 | public function getFactory() |
||
| 102 | { |
||
| 103 | if (!$this->factory) { |
||
| 104 | $this->factory = new Factory($this); |
||
| 105 | } |
||
| 106 | return $this->factory; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Get the filesystem service |
||
| 111 | * |
||
| 112 | * @return Filesystem |
||
| 113 | */ |
||
| 114 | public function getFilesystem() |
||
| 115 | { |
||
| 116 | if (!$this->filesystem) { |
||
| 117 | $this->filesystem = new Filesystem($this); |
||
| 118 | } |
||
| 119 | return $this->filesystem; |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Get a new process |
||
| 124 | * |
||
| 125 | * @param string $command The command to execute |
||
| 126 | * @param string $cwd The directory to execute the command in |
||
| 127 | * |
||
| 128 | * @return Process |
||
| 129 | */ |
||
| 130 | public function createProcess($command, $cwd = null) |
||
| 131 | { |
||
| 132 | return new Process($this, $command, $cwd); |
||
| 133 | } |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Get the debug output |
||
| 137 | * |
||
| 138 | * @return Output |
||
| 139 | */ |
||
| 140 | public function getDebugOutput() |
||
| 141 | { |
||
| 142 | return $this->debugOutput; |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Set debug output |
||
| 147 | * |
||
| 148 | * @param Output $debugOutput The output |
||
| 149 | * |
||
| 150 | * @return void |
||
| 151 | */ |
||
| 152 | public function setDebugOutput(Output $debugOutput) |
||
| 153 | { |
||
| 154 | $this->debugOutput = $debugOutput; |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Set the application |
||
| 159 | * |
||
| 160 | * @param Application $application The application |
||
| 161 | * |
||
| 162 | * @return Console |
||
| 163 | */ |
||
| 164 | public function setApplication($application) |
||
| 165 | { |
||
| 166 | $this->application = $application; |
||
| 167 | return $this; |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Get the application |
||
| 172 | * |
||
| 173 | * @return Application |
||
| 174 | */ |
||
| 175 | public function getApplication() |
||
| 176 | { |
||
| 177 | return $this->application; |
||
| 178 | } |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Set the output |
||
| 182 | * |
||
| 183 | * @param BufferedOutput|OutputInterface $output The output |
||
| 184 | * |
||
| 185 | * @return Console |
||
| 186 | */ |
||
| 187 | public function setOutput(Output $output) |
||
| 188 | { |
||
| 189 | $this->output = $output; |
||
| 190 | return $this; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Get the output |
||
| 195 | * |
||
| 196 | * @return \Symfony\Component\Console\Output\Output |
||
| 197 | */ |
||
| 198 | public function getOutput() |
||
| 199 | { |
||
| 200 | return $this->output; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Set the input |
||
| 205 | * |
||
| 206 | * @param InputInterface $input The input |
||
| 207 | * |
||
| 208 | * @return Console |
||
| 209 | */ |
||
| 210 | public function setInput($input) |
||
| 211 | { |
||
| 212 | $this->input = $input; |
||
| 213 | return $this; |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Get the input |
||
| 218 | * |
||
| 219 | * @return \Symfony\Component\Console\Input\InputInterface |
||
| 220 | */ |
||
| 221 | public function getInput() |
||
| 222 | { |
||
| 223 | return $this->input; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Get a console helper |
||
| 228 | * |
||
| 229 | * @param string $name Helper name |
||
| 230 | * |
||
| 231 | * @return Helper\HelperInterface |
||
| 232 | */ |
||
| 233 | public function getHelper($name) |
||
| 234 | { |
||
| 235 | return $this->application->getHelperSet()->get($name); |
||
| 236 | } |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Increase indention for all following lines |
||
| 240 | * |
||
| 241 | * @param int $tabs The tabs |
||
| 242 | * |
||
| 243 | * @return void |
||
| 244 | */ |
||
| 245 | public function indent($tabs = 1) |
||
| 246 | { |
||
| 247 | if ($this->output) { |
||
| 248 | $this->output->indent($tabs); |
||
| 249 | } |
||
| 250 | if ($this->debugOutput) { |
||
| 251 | $this->debugOutput->indent($tabs); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | |||
| 255 | /** |
||
| 256 | * Decrease indention for all following lines |
||
| 257 | * |
||
| 258 | * @param int $tabs The tabs |
||
| 259 | * |
||
| 260 | * @return void |
||
| 261 | */ |
||
| 262 | public function outdent($tabs = 1) |
||
| 263 | { |
||
| 264 | if ($this->output) { |
||
| 265 | $this->output->outdent($tabs); |
||
| 266 | } |
||
| 267 | if ($this->debugOutput) { |
||
| 268 | $this->debugOutput->outdent($tabs); |
||
| 269 | } |
||
| 270 | } |
||
| 271 | |||
| 272 | /** |
||
| 273 | * Set a new minimum severity for messages to be shown |
||
| 274 | * |
||
| 275 | * @param int $verbosity The verbosity |
||
| 276 | * |
||
| 277 | * @return $this |
||
| 278 | */ |
||
| 279 | public function setVerbosity($verbosity) |
||
| 280 | { |
||
| 281 | $this->previousVerbosities[] = $this->output->getVerbosity(); |
||
| 282 | $this->output->setVerbosity($verbosity); |
||
| 283 | return $this; |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * Get verbosity for messages to be shown |
||
| 288 | * |
||
| 289 | * @return int |
||
| 290 | */ |
||
| 291 | public function getVerbosity() |
||
| 292 | { |
||
| 293 | return $this->output->getVerbosity(); |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Restore the verbosity that was set before the last call to setSeverity |
||
| 298 | * |
||
| 299 | * @return $this |
||
| 300 | */ |
||
| 301 | public function restoreVerbosity() |
||
| 302 | { |
||
| 303 | if ($this->previousVerbosities) { |
||
|
0 ignored issues
–
show
|
|||
| 304 | $this->output->setVerbosity(array_pop($this->previousVerbosities)); |
||
| 305 | } |
||
| 306 | return $this; |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Output a string |
||
| 311 | * |
||
| 312 | * @param string $message The message |
||
| 313 | * @param int|bool $verbosityOrNewLine Severity or whether to print a newline |
||
| 314 | * @param bool $newLine Whether to print a newline |
||
| 315 | * @param bool $raw If true, don't style the output |
||
| 316 | * |
||
| 317 | * @return void |
||
| 318 | */ |
||
| 319 | public function output($message, $verbosityOrNewLine = OutputInterface::VERBOSITY_NORMAL, $newLine = true, $raw = false) |
||
| 320 | { |
||
| 321 | if (is_bool($verbosityOrNewLine)) { |
||
| 322 | $newLine = $verbosityOrNewLine; |
||
| 323 | $verbosityOrNewLine = OutputInterface::VERBOSITY_NORMAL; |
||
| 324 | } |
||
| 325 | |||
| 326 | if ($this->debugOutput) { |
||
| 327 | $this->debugOutput->write($message, $newLine, $raw ? OutputInterface::OUTPUT_RAW : $this->outputType); |
||
| 328 | } |
||
| 329 | |||
| 330 | $verbosity = $this->output->getVerbosity(); |
||
| 331 | |||
| 332 | if ($verbosity !== 0 && $verbosityOrNewLine <= $verbosity) { |
||
| 333 | $this->output->write($message, $newLine, $raw ? OutputInterface::OUTPUT_RAW : $this->outputType); |
||
| 334 | } |
||
| 335 | } |
||
| 336 | } |
||
| 337 | ?> |
||
| 338 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.