1 | <?php |
||
23 | final class Verify implements PluginInterface, EventSubscriberInterface |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritDoc} |
||
27 | */ |
||
28 | 1 | public static function getSubscribedEvents() : array |
|
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | * |
||
38 | * @codeCoverageIgnore |
||
39 | */ |
||
40 | public function activate(Composer $composer, IOInterface $io) : void |
||
44 | |||
45 | /** |
||
46 | * @param Event $composerEvent |
||
47 | * |
||
48 | * @throws \Roave\ComposerGpgVerify\Exception\PackagesTrustCheckFailed |
||
49 | * @throws \RuntimeException |
||
50 | * @throws \Roave\ComposerGpgVerify\Exception\PreferredInstallIsNotSource |
||
51 | */ |
||
52 | 15 | public static function verify(Event $composerEvent) : void |
|
92 | |||
93 | 14 | private static function verifyPackage( |
|
94 | InstallationManager $installationManager, |
||
95 | PackageInterface $package |
||
96 | ) : PackageVerification { |
||
97 | 14 | $gitDirectory = $installationManager->getInstallPath($package) . '/.git'; |
|
98 | |||
99 | 14 | if (! is_dir($gitDirectory)) { |
|
100 | 1 | return UnknownPackageFormat::fromNonGitPackage($package); |
|
101 | } |
||
102 | |||
103 | 13 | return GitPackage::fromPackageAndSignatureChecks( |
|
104 | $package, |
||
105 | 13 | self::checkCurrentCommitSignature($gitDirectory, $package), |
|
106 | 13 | ...self::checkTagSignatures($gitDirectory, $package, ...self::getTagsForCurrentCommit($gitDirectory)) |
|
107 | ); |
||
108 | } |
||
109 | |||
110 | 13 | private static function checkCurrentCommitSignature( |
|
123 | |||
124 | /** |
||
125 | * @param string $gitDirectory |
||
126 | * |
||
127 | * @return string[] |
||
128 | */ |
||
129 | 13 | private static function getTagsForCurrentCommit(string $gitDirectory) : array |
|
141 | |||
142 | |||
143 | /** |
||
144 | * @param string $gitDirectory |
||
145 | * @param PackageInterface $package |
||
146 | * @param string[] $tags |
||
147 | * |
||
148 | * @return GitSignatureCheck[] |
||
149 | */ |
||
150 | 13 | private static function checkTagSignatures(string $gitDirectory, PackageInterface $package, string ...$tags) : array |
|
172 | |||
173 | /** |
||
174 | * @param Config $config |
||
175 | * |
||
176 | * |
||
177 | * @throws \RuntimeException |
||
178 | * @throws \Roave\ComposerGpgVerify\Exception\PreferredInstallIsNotSource |
||
179 | */ |
||
180 | 15 | private static function assertSourceInstallation(Config $config) : void |
|
188 | } |
||
189 |
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.