1 | <?php |
||
26 | class ChangelogsPlugin implements PluginInterface, EventSubscriberInterface |
||
27 | { |
||
28 | const EXTRA_KEY = 'composer-changelogs'; |
||
29 | |||
30 | /** @var Composer */ |
||
31 | private $composer; |
||
32 | |||
33 | /** @var IOInterface */ |
||
34 | private $io; |
||
35 | |||
36 | /** @var Outputter */ |
||
37 | private $outputter; |
||
38 | |||
39 | /** @var ConfigLocator */ |
||
40 | private $configLocator; |
||
41 | |||
42 | /** @var Config */ |
||
43 | private $config; |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 6 | public function activate(Composer $composer, IOInterface $io) |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 3 | public static function getSubscribedEvents() |
|
79 | |||
80 | /** |
||
81 | * @param PackageEvent $event |
||
82 | */ |
||
83 | 5 | public function postPackageOperation(PackageEvent $event) |
|
89 | |||
90 | /** |
||
91 | * @param Event $event |
||
92 | */ |
||
93 | 5 | public function postUpdate(Event $event) |
|
99 | |||
100 | /** |
||
101 | * This method ensures all the classes required to make the plugin working |
||
102 | * are loaded. |
||
103 | * |
||
104 | * It's required to avoid composer looking for classes no longer existing |
||
105 | * (after the plugin is updated or removed for example). |
||
106 | * |
||
107 | * Lot of classes (like operation handlers, url generators, Outputter, etc) |
||
108 | * do not need this because they are already autoloaded at the activation |
||
109 | * of the plugin. |
||
110 | */ |
||
111 | 6 | private function autoloadNeededClasses() |
|
122 | |||
123 | 6 | private function setupConfig() |
|
139 | |||
140 | 5 | private function handleCommit() |
|
141 | { |
||
142 | 5 | if ($this->outputter->isEmpty()) { |
|
143 | return; |
||
144 | } |
||
145 | |||
146 | 5 | switch ($this->config->getCommitAuto()) { |
|
147 | 5 | case 'never': |
|
148 | 3 | return; |
|
149 | 2 | case 'ask': |
|
150 | if ($this->io->askConfirmation('<info>Would you like to commit the update? </info>[<comment>no</comment>]: ', false)) { |
||
151 | $this->doCommit(); |
||
152 | } |
||
153 | break; |
||
154 | 2 | case 'always': |
|
155 | 2 | $this->doCommit(); |
|
156 | 2 | } |
|
157 | 2 | } |
|
158 | |||
159 | 2 | private function doCommit() |
|
178 | } |
||
179 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.