1 | <?php |
||
2 | /** |
||
3 | * Copyright © Vaimo Group. All rights reserved. |
||
4 | * See LICENSE_VAIMO.txt for license details. |
||
5 | */ |
||
6 | namespace Vaimo\ComposerPatches\Managers; |
||
7 | |||
8 | use Composer\Repository\WritableRepositoryInterface; |
||
9 | use Composer\Package\PackageInterface; |
||
10 | use Composer\DependencyResolver\Operation\UninstallOperation; |
||
11 | |||
12 | use Vaimo\ComposerPatches\Composer\ResetOperation; |
||
13 | |||
14 | class RepositoryManager |
||
15 | { |
||
16 | /** |
||
17 | * @var \Composer\Installer\InstallationManager |
||
18 | */ |
||
19 | private $installationManager; |
||
20 | |||
21 | /** |
||
22 | * @var \Vaimo\ComposerPatches\Interfaces\PackageResetStrategyInterface |
||
23 | */ |
||
24 | private $packageResetStrategy; |
||
25 | |||
26 | /** |
||
27 | * @var \Vaimo\ComposerPatches\Console\Silencer |
||
28 | */ |
||
29 | private $consoleSilencer; |
||
30 | |||
31 | /** |
||
32 | * @var \Vaimo\ComposerPatches\Compatibility\Executor |
||
33 | */ |
||
34 | private $compExecutor; |
||
35 | |||
36 | /** |
||
37 | * @param \Composer\Installer\InstallationManager $installationManager |
||
38 | * @param \Vaimo\ComposerPatches\Interfaces\PackageResetStrategyInterface $packageResetStrategy |
||
39 | * @param \Vaimo\ComposerPatches\Console\Silencer $consoleSilencer |
||
40 | */ |
||
41 | public function __construct( |
||
42 | \Composer\Installer\InstallationManager $installationManager, |
||
43 | \Vaimo\ComposerPatches\Interfaces\PackageResetStrategyInterface $packageResetStrategy, |
||
44 | \Vaimo\ComposerPatches\Console\Silencer $consoleSilencer |
||
45 | ) { |
||
46 | $this->installationManager = $installationManager; |
||
47 | $this->packageResetStrategy = $packageResetStrategy; |
||
48 | $this->consoleSilencer = $consoleSilencer; |
||
49 | $this->compExecutor = new \Vaimo\ComposerPatches\Compatibility\Executor(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
54 | * |
||
55 | * @param WritableRepositoryInterface $repository |
||
56 | * @param PackageInterface $package |
||
57 | * @throws \Vaimo\ComposerPatches\Exceptions\PackageResetException |
||
58 | */ |
||
59 | public function resetPackage(WritableRepositoryInterface $repository, PackageInterface $package) |
||
60 | { |
||
61 | $resetOperation = new ResetOperation($package, 'Package reset due to changes in patches configuration'); |
||
0 ignored issues
–
show
|
|||
62 | $uninstallOperation = new UninstallOperation($package); |
||
63 | |||
64 | if (!$this->packageResetStrategy->shouldAllowReset($package)) { |
||
65 | throw new \Vaimo\ComposerPatches\Exceptions\PackageResetException( |
||
66 | sprintf('Package reset halted due to encountering local changes: %s', $package->getName()) |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | $compExecutor = $this->compExecutor; |
||
71 | $installationManager = $this->installationManager; |
||
72 | return $this->consoleSilencer->applyToCallback( |
||
73 | function () use ($compExecutor, $installationManager, $repository, $resetOperation, $uninstallOperation) { |
||
74 | return $compExecutor->processReinstallOperation($repository, $installationManager, $resetOperation, $uninstallOperation); |
||
75 | } |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.