From ca4557eff1f3d24050bfc0bac64afb0b16565888 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 24 Oct 2016 15:18:03 +0200 Subject: [PATCH] Look for standards mappings in other packages of the local repository (e.g. in case this was provided by a metapackage) --- src/Installer.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Installer.php b/src/Installer.php index 4d7f3486..e3267e47 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -27,11 +27,21 @@ public function getInstallPath(PackageInterface $package) { $this->initializeVendorDir(); - $rootPackageExtra = $this->composer->getPackage()->getExtra(); - $packageExtra = $package->getExtra(); + $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); + $packages[] = $this->composer->getPackage(); + + $mapping = []; + foreach($packages as $localPackage) { + $extra = $localPackage->getExtra(); + if (isset($extra['phpcodesniffer-mapping']) === true) { + $mapping = array_merge($mapping, $extra['phpcodesniffer-mapping']); + } + } + + $packageExtra = $package->getExtra(); - if (isset($rootPackageExtra['phpcodesniffer-mapping'][$package->getPrettyName()]) === true) { - $standardDir = $rootPackageExtra['phpcodesniffer-mapping'][$package->getPrettyName()]; + if (isset($mapping[$package->getPrettyName()]) === true) { + $standardDir = $mapping[$package->getPrettyName()]; } elseif (isset($packageExtra['phpcodesniffer-standard']) === true) { $standardDir = $packageExtra['phpcodesniffer-standard']; } else {