From 907ed7bbabe5de7ddc9204f2a553898ef2416dd0 Mon Sep 17 00:00:00 2001 From: hussainweb Date: Fri, 11 Sep 2020 18:05:16 -0400 Subject: [PATCH 1/2] Change getJobType to getOperationType Composer 2 has subsequently changed the method name of `getJobType` to `getOperationType` in https://github.com/composer/composer/pull/8537 --- src/Patches.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Patches.php b/src/Patches.php index 7e60dd05..51c61437 100644 --- a/src/Patches.php +++ b/src/Patches.php @@ -176,7 +176,7 @@ public function gatherPatches(PackageEvent $event) { $operations = $event->getOperations(); $this->io->write('Gathering patches for dependencies. This might take a minute.'); foreach ($operations as $operation) { - if ($operation->getJobType() == 'install' || $operation->getJobType() == 'update') { + if ($operation->getOperationType() == 'install' || $operation->getOperationType() == 'update') { $package = $this->getPackageFromOperation($operation); $extra = $package->getExtra(); if (isset($extra['patches'])) { From 22397c86d2049c98116cabc6f75b9622d073e4cd Mon Sep 17 00:00:00 2001 From: hussainweb Date: Fri, 11 Sep 2020 23:07:19 -0400 Subject: [PATCH 2/2] Use instanceof to check if the operation Using getOperationType isn't a good idea as it would break with composer 1. This method would work for both composer 1 and 2. --- src/Patches.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Patches.php b/src/Patches.php index 51c61437..0e36c7ff 100644 --- a/src/Patches.php +++ b/src/Patches.php @@ -176,7 +176,7 @@ public function gatherPatches(PackageEvent $event) { $operations = $event->getOperations(); $this->io->write('Gathering patches for dependencies. This might take a minute.'); foreach ($operations as $operation) { - if ($operation->getOperationType() == 'install' || $operation->getOperationType() == 'update') { + if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) { $package = $this->getPackageFromOperation($operation); $extra = $package->getExtra(); if (isset($extra['patches'])) {