1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright MediaCT. All rights reserved. |
4
|
|
|
* https://www.mediact.nl |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Mediact\DependencyGuard\Composer; |
8
|
|
|
|
9
|
|
|
use Composer\Composer; |
10
|
|
|
use Composer\IO\IOInterface; |
11
|
|
|
use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability; |
12
|
|
|
use Composer\Plugin\Capable; |
13
|
|
|
use Composer\Plugin\PluginInterface; |
14
|
|
|
|
15
|
|
|
class Plugin implements PluginInterface, Capable |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Announce the capabilities of the dependency guard plugin. |
19
|
|
|
* |
20
|
|
|
* @return string[] |
21
|
|
|
*/ |
22
|
1 |
|
public function getCapabilities(): array |
23
|
|
|
{ |
24
|
|
|
return [ |
25
|
1 |
|
CommandProviderCapability::class => CommandProvider::class |
26
|
|
|
]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Apply plugin modifications to Composer. |
31
|
|
|
* |
32
|
|
|
* @param Composer $composer |
33
|
|
|
* @param IOInterface $io |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
1 |
|
public function activate(Composer $composer, IOInterface $io): void |
38
|
|
|
{ |
39
|
|
|
// There is nothing explicit that needs to happen. |
40
|
1 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Remove any hooks from Composer |
44
|
|
|
* |
45
|
|
|
* This will be called when a plugin is deactivated before being |
46
|
|
|
* uninstalled, but also before it gets upgraded to a new version |
47
|
|
|
* so the old one can be deactivated and the new one activated. |
48
|
|
|
* |
49
|
|
|
* @param Composer $composer |
50
|
|
|
* @param IOInterface $io |
51
|
|
|
*/ |
52
|
|
|
public function deactivate(Composer $composer, IOInterface $io): void |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
// There is nothing explicit that needs to happen. |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Prepare the plugin to be uninstalled |
59
|
|
|
* |
60
|
|
|
* This will be called after deactivate. |
61
|
|
|
* |
62
|
|
|
* @param Composer $composer |
63
|
|
|
* @param IOInterface $io |
64
|
|
|
*/ |
65
|
|
|
public function uninstall(Composer $composer, IOInterface $io): void |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
// There is nothing explicit that needs to happen. |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.