1
0
Fork 0

Fix regex escaping and remove constants

pull/4964/head
Jordi Boggiano 2016-02-25 19:07:09 +00:00
parent 06be9b88c2
commit 3c640e689e
2 changed files with 6 additions and 10 deletions

View File

@ -21,10 +21,6 @@ class Config
{
const RELATIVE_PATHS = 1;
const INSTALL_PREFERENCE_AUTO = 'auto';
const INSTALL_PREFERENCE_DIST = 'dist';
const INSTALL_PREFERENCE_SOURCE = 'source';
public static $defaultConfig = array(
'process-timeout' => 300,
'use-include-path' => false,

View File

@ -197,7 +197,7 @@ class DownloadManager
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
}
if (!$preferSource && ($this->preferDist || Config::INSTALL_PREFERENCE_DIST === $this->resolvePackageInstallPreference($package))) {
if (!$preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
$sources = array_reverse($sources);
}
@ -308,15 +308,15 @@ class DownloadManager
protected function resolvePackageInstallPreference(PackageInterface $package)
{
foreach ($this->packagePreferences as $pattern => $preference) {
$pattern = '{^'.str_replace('*', '.*', $pattern).'$}i';
$pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
if (preg_match($pattern, $package->getName())) {
if (Config::INSTALL_PREFERENCE_DIST === $preference || (!$package->isDev() && Config::INSTALL_PREFERENCE_AUTO === $preference)) {
return Config::INSTALL_PREFERENCE_DIST;
if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
return 'dist';
}
return Config::INSTALL_PREFERENCE_SOURCE;
return 'source';
}
}
return $package->isDev() ? Config::INSTALL_PREFERENCE_SOURCE : Config::INSTALL_PREFERENCE_DIST;
return $package->isDev() ? 'source' : 'dist';
}
}