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 EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.ec-cube.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\Command; |
||
15 | |||
16 | use Doctrine\Common\Collections\Criteria; |
||
17 | use Eccube\Common\Constant; |
||
18 | use Eccube\Repository\PluginRepository; |
||
19 | use Eccube\Service\Composer\ComposerApiService; |
||
20 | use Eccube\Service\PluginApiService; |
||
21 | use Symfony\Component\Console\Command\Command; |
||
22 | use Symfony\Component\Console\Input\InputInterface; |
||
23 | use Symfony\Component\Console\Output\OutputInterface; |
||
24 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
||
25 | use Symfony\Component\Console\Style\SymfonyStyle; |
||
26 | |||
27 | class ComposerRequireAlreadyInstalledPluginsCommand extends Command |
||
28 | { |
||
29 | protected static $defaultName = 'eccube:composer:require-already-installed'; |
||
30 | |||
31 | /** |
||
32 | * @var ComposerApiService |
||
33 | */ |
||
34 | private $composerService; |
||
35 | |||
36 | /** |
||
37 | * @var PluginApiService |
||
38 | */ |
||
39 | private $pluginApiService; |
||
40 | |||
41 | /** |
||
42 | * @var PluginRepository |
||
43 | */ |
||
44 | private $pluginRepository; |
||
45 | |||
46 | /** |
||
47 | * @var SymfonyStyle |
||
48 | */ |
||
49 | private $io; |
||
50 | |||
51 | public function __construct( |
||
52 | ComposerApiService $composerService, |
||
53 | PluginRepository $pluginRepository, |
||
54 | PluginApiService $pluginApiService |
||
55 | ) { |
||
56 | parent::__construct(); |
||
57 | $this->composerService = $composerService; |
||
58 | $this->pluginApiService = $pluginApiService; |
||
59 | $this->pluginRepository = $pluginRepository; |
||
60 | } |
||
61 | |||
62 | public function initialize(InputInterface $input, OutputInterface $output) |
||
63 | { |
||
64 | $this->io = new SymfonyStyle($input, $output); |
||
65 | } |
||
66 | |||
67 | protected function execute(InputInterface $input, OutputInterface $output) |
||
68 | { |
||
69 | $packageNames = []; |
||
70 | $unSupportedPlugins = []; |
||
71 | |||
72 | $criteria = Criteria::create() |
||
73 | ->where(Criteria::expr()->neq('source', 0)) |
||
74 | ->orderBy(['code' => 'ASC']); |
||
75 | $Plugins = $this->pluginRepository->matching($criteria); |
||
76 | |||
77 | foreach ($Plugins as $Plugin) { |
||
78 | $packageNames[] = 'ec-cube/'.$Plugin->getCode().':'.$Plugin->getVersion(); |
||
79 | $data = $this->pluginApiService->getPlugin($Plugin->getCode()); |
||
80 | if (isset($data['version_check']) && !$data['version_check']) { |
||
81 | $unSupportedPlugins[] = $Plugin; |
||
82 | } |
||
83 | } |
||
84 | |||
85 | foreach ($unSupportedPlugins as $Plugin) { |
||
86 | $message = trans('command.composer_require_already_installed.not_supported_plugin', [ |
||
87 | '%name%' => $Plugin->getName(), |
||
88 | '%plugin_version%' => $Plugin->getVersion(), |
||
89 | '%eccube_version%' => Constant::VERSION, |
||
90 | ]); |
||
91 | $question = new ConfirmationQuestion($message); |
||
92 | if (!$this->io->askQuestion($question)) { |
||
93 | return; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | if ($packageNames) { |
||
0 ignored issues
–
show
|
|||
98 | $this->composerService->execRequire(implode(' ', $packageNames), $this->io); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 |
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.