comodojo /
comodojo-installer
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 namespace Comodojo\Installer; |
||
| 2 | |||
| 3 | use Composer\Composer; |
||
| 4 | use Composer\IO\IOInterface; |
||
| 5 | use Composer\Installer\LibraryInstaller; |
||
| 6 | use Composer\Package\PackageInterface; |
||
| 7 | use Composer\Repository\InstalledRepositoryInterface; |
||
| 8 | use Comodojo\Exception\InstallerException; |
||
| 9 | use Comodojo\Installer\Properties\Parser; |
||
| 10 | use Comodojo\Installer\Registry\SupportedTypes; |
||
| 11 | use Comodojo\Configuration\Installer as PackageInstaller; |
||
| 12 | |||
| 13 | |||
| 14 | /** |
||
| 15 | * |
||
| 16 | * |
||
| 17 | * @package Comodojo Framework |
||
| 18 | * @author Marco Giovinazzi <[email protected]> |
||
| 19 | * @author Marco Castiello <[email protected]> |
||
| 20 | * @license GPL-3.0+ |
||
| 21 | * |
||
| 22 | * LICENSE: |
||
| 23 | * |
||
| 24 | * This program is free software: you can redistribute it and/or modify |
||
| 25 | * it under the terms of the GNU Affero General Public License as |
||
| 26 | * published by the Free Software Foundation, either version 3 of the |
||
| 27 | * License, or (at your option) any later version. |
||
| 28 | * |
||
| 29 | * This program is distributed in the hope that it will be useful, |
||
| 30 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 31 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 32 | * GNU Affero General Public License for more details. |
||
| 33 | * |
||
| 34 | * You should have received a copy of the GNU Affero General Public License |
||
| 35 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 36 | */ |
||
| 37 | |||
| 38 | class Installer extends LibraryInstaller { |
||
| 39 | |||
| 40 | protected $package_installer; |
||
| 41 | |||
| 42 | public function __construct(Composer $composer, IOInterface $io, PackageInstaller $package_installer) { |
||
| 43 | |||
| 44 | $this->package_installer = $package_installer; |
||
| 45 | |||
| 46 | parent::__construct($composer, $io); |
||
|
0 ignored issues
–
show
$io is of type object<Composer\IO\IOInterface>, but the function expects a object<Composer\Composer>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 47 | |||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritDoc} |
||
| 52 | */ |
||
| 53 | public function supports($packageType) { |
||
| 54 | |||
| 55 | return in_array($packageType, SupportedTypes::getTypes()); |
||
| 56 | |||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritDoc} |
||
| 61 | */ |
||
| 62 | public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { |
||
| 63 | |||
| 64 | parent::install($repo, $package); |
||
| 65 | |||
| 66 | $this->packageInstall($package); |
||
| 67 | |||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritDoc} |
||
| 72 | */ |
||
| 73 | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { |
||
| 74 | |||
| 75 | parent::update($repo, $initial, $target); |
||
| 76 | |||
| 77 | $this->packageUpdate($initial, $target); |
||
| 78 | |||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritDoc} |
||
| 83 | */ |
||
| 84 | public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { |
||
| 85 | |||
| 86 | $this->packageUninstall($package); |
||
| 87 | |||
| 88 | parent::uninstall($repo, $package); |
||
| 89 | |||
| 90 | } |
||
| 91 | |||
| 92 | View Code Duplication | private function packageInstall($package) { |
|
| 93 | |||
| 94 | $actions_map = Parser::parse($package); |
||
| 95 | |||
| 96 | $package_name = $package->getPrettyName(); |
||
| 97 | |||
| 98 | $package_path = $this->composer->getInstallationManager()->getInstallPath($package); |
||
| 99 | |||
| 100 | $installer = $this->getPackageInstaller(); |
||
| 101 | |||
| 102 | foreach ($actions_map as $action_class => $extra) { |
||
| 103 | |||
| 104 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_class; |
||
| 105 | |||
| 106 | $action = new $action_fqcn($this->composer, $this->io, $package_path, $installer); |
||
| 107 | |||
| 108 | $action->install($package_name, $extra); |
||
| 109 | |||
| 110 | } |
||
| 111 | |||
| 112 | } |
||
| 113 | |||
| 114 | View Code Duplication | private function packageUninstall($package) { |
|
| 115 | |||
| 116 | $actions_map = Parser::parse($package); |
||
| 117 | |||
| 118 | $package_name = $package->getPrettyName(); |
||
| 119 | |||
| 120 | $package_path = $this->composer->getInstallationManager()->getInstallPath($package); |
||
| 121 | |||
| 122 | $installer = $this->getPackageInstaller(); |
||
| 123 | |||
| 124 | foreach ($actions_map as $action_class => $extra) { |
||
| 125 | |||
| 126 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_class; |
||
| 127 | |||
| 128 | $action = new $action_fqcn($this->composer, $this->io, $package_path, $installer); |
||
| 129 | |||
| 130 | $action->uninstall($package_name, $extra); |
||
| 131 | |||
| 132 | } |
||
| 133 | |||
| 134 | } |
||
| 135 | |||
| 136 | private function packageUpdate($initial, $target) { |
||
| 137 | |||
| 138 | $initial_actions_map = Parser::parse($initial); |
||
| 139 | |||
| 140 | $target_actions_map = Parser::parse($target); |
||
| 141 | |||
| 142 | $initial_package_name = $initial->getPrettyName(); |
||
| 143 | |||
| 144 | $target_package_name = $target->getPrettyName(); |
||
| 145 | |||
| 146 | $initial_package_path = $this->composer->getInstallationManager()->getInstallPath($initial); |
||
| 147 | |||
| 148 | $target_package_path = $this->composer->getInstallationManager()->getInstallPath($target); |
||
| 149 | |||
| 150 | $initial_actions = array_keys($initial_actions_map); |
||
| 151 | |||
| 152 | $target_actions = array_keys($target_actions_map); |
||
| 153 | |||
| 154 | $uninstall = array_diff($initial_actions, $target_actions); |
||
| 155 | |||
| 156 | $install = array_diff($target_actions, $initial_actions); |
||
| 157 | |||
| 158 | $update = array_intersect($initial_actions, $target_actions); |
||
| 159 | |||
| 160 | $installer = $this->getPackageInstaller(); |
||
| 161 | |||
| 162 | foreach ($uninstall as $action_uninstall) { |
||
| 163 | |||
| 164 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_uninstall; |
||
| 165 | |||
| 166 | $action = new $action_fqcn($this->composer, $this->io, $initial_package_path, $installer); |
||
| 167 | |||
| 168 | $action->uninstall($initial_package_name, $initial_actions_map[$action_uninstall]); |
||
| 169 | |||
| 170 | } |
||
| 171 | |||
| 172 | View Code Duplication | foreach ($install as $action_install) { |
|
| 173 | |||
| 174 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_install; |
||
| 175 | |||
| 176 | $action = new $action_fqcn($this->composer, $this->io, $target_package_path, $installer); |
||
| 177 | |||
| 178 | $action->install($target_package_name, $target_actions_map[$action_install]); |
||
| 179 | |||
| 180 | } |
||
| 181 | |||
| 182 | View Code Duplication | foreach ($update as $action_update) { |
|
| 183 | |||
| 184 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_update; |
||
| 185 | |||
| 186 | $action = new $action_fqcn($this->composer, $this->io, $target_package_path, $installer); |
||
| 187 | |||
| 188 | $action->update($target_package_name, $initial_actions_map[$action_update], $target_actions_map[$action_update]); |
||
| 189 | |||
| 190 | } |
||
| 191 | |||
| 192 | } |
||
| 193 | |||
| 194 | private function getPackageInstaller() { |
||
| 195 | |||
| 196 | return $this->package_installer; |
||
| 197 | |||
| 198 | } |
||
| 199 | |||
| 200 | } |
||
| 201 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: