Skip to content

Commit

Permalink
Look for standards mappings in other packages of the local repository…
Browse files Browse the repository at this point in the history
… (e.g. in case this was provided by a metapackage)
  • Loading branch information
frenck committed Oct 24, 2016
1 parent 9a1ed62 commit ca4557e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ca4557e

Please sign in to comment.