|
9 | 9 | use Composer\Script\Event; |
10 | 10 | use PhpStaticAnalysis\Attributes\Returns; |
11 | 11 |
|
12 | | -class Plugin implements PluginInterface, EventSubscriberInterface |
| 12 | +final class Plugin implements PluginInterface, EventSubscriberInterface |
13 | 13 | { |
14 | 14 | public function activate(Composer $composer, IOInterface $io) |
15 | 15 | { |
@@ -50,12 +50,25 @@ private static function applyPatches(Event $event): void |
50 | 50 | $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); |
51 | 51 |
|
52 | 52 | $dependencyPath = $vendorDir . '/vimeo/psalm'; |
53 | | - $patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-config-php.patch'; |
| 53 | + $patchesDir = __DIR__ . '/../../patches/'; |
| 54 | + $patchFiles = glob($patchesDir . '*.patch'); |
54 | 55 |
|
55 | | - exec("patch -p1 -d $dependencyPath --forward < $patchFile"); |
| 56 | + if ($patchFiles === false) { |
| 57 | + echo "No patches to apply\n"; |
| 58 | + return; |
| 59 | + } |
| 60 | + foreach ($patchFiles as $patchFile) { |
| 61 | + $escapedPatchFile = escapeshellarg($patchFile); |
| 62 | + $escapedDependencyPath = escapeshellarg($dependencyPath); |
56 | 63 |
|
57 | | - $patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-codebase-php.patch'; |
| 64 | + $cmd = "patch -p1 -d $escapedDependencyPath --forward < $escapedPatchFile"; |
| 65 | + exec($cmd, $output, $returnVar); |
58 | 66 |
|
59 | | - exec("patch -p1 -d $dependencyPath --forward < $patchFile"); |
| 67 | + if ($returnVar !== 0) { |
| 68 | + echo "Failed to apply patch: $patchFile\n"; |
| 69 | + } else { |
| 70 | + echo "Applied patch: $patchFile\n"; |
| 71 | + } |
| 72 | + } |
60 | 73 | } |
61 | 74 | } |
0 commit comments