Consistently reuse the new PlatformRepository::isPlatformPackage() method
parent
046c54fdb8
commit
bd6f62c535
|
@ -122,7 +122,7 @@ class AutoloadGenerator
|
||||||
{
|
{
|
||||||
if (is_array($ignorePlatformReqs)) {
|
if (is_array($ignorePlatformReqs)) {
|
||||||
$this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
|
$this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
|
||||||
return (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
return PlatformRepository::isPlatformPackage($req);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
|
$this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
|
||||||
|
|
|
@ -82,7 +82,7 @@ EOT
|
||||||
* @var Link[] $links
|
* @var Link[] $links
|
||||||
*/
|
*/
|
||||||
foreach ($requires as $require => $links) {
|
foreach ($requires as $require => $links) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $require)) {
|
if (PlatformRepository::isPlatformPackage($require)) {
|
||||||
$candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
|
$candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
|
||||||
if ($candidates) {
|
if ($candidates) {
|
||||||
$reqResults = array();
|
$reqResults = array();
|
||||||
|
|
|
@ -737,7 +737,7 @@ EOT
|
||||||
if (!$package) {
|
if (!$package) {
|
||||||
// platform packages can not be found in the pool in versions other than the local platform's has
|
// platform packages can not be found in the pool in versions other than the local platform's has
|
||||||
// so if platform reqs are ignored we just take the user's word for it
|
// so if platform reqs are ignored we just take the user's word for it
|
||||||
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
|
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
|
||||||
return array($name, $requiredVersion ?: '*');
|
return array($name, $requiredVersion ?: '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ EOT
|
||||||
if (empty($package)) {
|
if (empty($package)) {
|
||||||
$options = $input->getOptions();
|
$options = $input->getOptions();
|
||||||
if (!isset($options['working-dir']) || !file_exists('composer.json')) {
|
if (!isset($options['working-dir']) || !file_exists('composer.json')) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $input->getArgument('package')) && !$input->getOption('platform')) {
|
if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
|
||||||
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
|
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
|
||||||
}
|
}
|
||||||
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
|
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
|
||||||
|
|
|
@ -130,7 +130,7 @@ abstract class Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
|
if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $this->reasonData->getTarget())) {
|
if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach ($request->getFixedPackages() as $package) {
|
foreach ($request->getFixedPackages() as $package) {
|
||||||
|
@ -147,7 +147,7 @@ abstract class Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
|
if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $this->reasonData['packageName'])) {
|
if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach ($request->getFixedPackages() as $package) {
|
foreach ($request->getFixedPackages() as $package) {
|
||||||
|
|
|
@ -176,7 +176,7 @@ class RuleSetGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($package->getRequires() as $link) {
|
foreach ($package->getRequires() as $link) {
|
||||||
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class RuleSetGenerator
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ class RuleSetGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request->getRequires() as $packageName => $constraint) {
|
foreach ($request->getRequires() as $packageName => $constraint) {
|
||||||
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $packageName)) {
|
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ class Solver
|
||||||
protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
|
protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
|
||||||
{
|
{
|
||||||
foreach ($request->getRequires() as $packageName => $constraint) {
|
foreach ($request->getRequires() as $packageName => $constraint) {
|
||||||
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $packageName)) {
|
if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ class Transaction
|
||||||
if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
|
if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
|
||||||
// get the package's requires, but filter out any platform requirements
|
// get the package's requires, but filter out any platform requirements
|
||||||
$requires = array_filter(array_keys($package->getRequires()), function ($req) {
|
$requires = array_filter(array_keys($package->getRequires()), function ($req) {
|
||||||
return !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
return !PlatformRepository::isPlatformPackage($req);
|
||||||
});
|
});
|
||||||
|
|
||||||
// is this a plugin with no meaningful dependencies?
|
// is this a plugin with no meaningful dependencies?
|
||||||
|
|
|
@ -761,7 +761,7 @@ class Installer
|
||||||
$rootRequires = array();
|
$rootRequires = array();
|
||||||
foreach ($requires as $req => $constraint) {
|
foreach ($requires as $req => $constraint) {
|
||||||
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
||||||
if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($constraint instanceof Link) {
|
if ($constraint instanceof Link) {
|
||||||
|
@ -870,7 +870,7 @@ class Installer
|
||||||
{
|
{
|
||||||
$platformReqs = array();
|
$platformReqs = array();
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
if (PlatformRepository::isPlatformPackage($link->getTarget())) {
|
||||||
$platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
|
$platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1152,7 @@ class Installer
|
||||||
{
|
{
|
||||||
if (is_array($ignorePlatformReqs)) {
|
if (is_array($ignorePlatformReqs)) {
|
||||||
$this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
|
$this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
|
||||||
return (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
return PlatformRepository::isPlatformPackage($req);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
|
$this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
|
||||||
|
|
|
@ -117,7 +117,7 @@ class JsonManipulator
|
||||||
private function sortPackages(array &$packages = array())
|
private function sortPackages(array &$packages = array())
|
||||||
{
|
{
|
||||||
$prefix = function ($requirement) {
|
$prefix = function ($requirement) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $requirement)) {
|
if (PlatformRepository::isPlatformPackage($requirement)) {
|
||||||
return preg_replace(
|
return preg_replace(
|
||||||
array(
|
array(
|
||||||
'/^php/',
|
'/^php/',
|
||||||
|
|
|
@ -249,7 +249,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
|
($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
|
||||||
&& 'require' === $linkType
|
&& 'require' === $linkType
|
||||||
&& $linkConstraint->matches($unboundConstraint)
|
&& $linkConstraint->matches($unboundConstraint)
|
||||||
&& !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $package)
|
&& !PlatformRepository::isPlatformPackage($package)
|
||||||
) {
|
) {
|
||||||
$this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
|
$this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
|
||||||
} elseif (
|
} elseif (
|
||||||
|
@ -372,7 +372,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
|
|
||||||
public static function hasPackageNamingError($name, $isLink = false)
|
public static function hasPackageNamingError($name, $isLink = false)
|
||||||
{
|
{
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
|
if (PlatformRepository::isPlatformPackage($name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class VersionParser extends SemverVersionParser
|
||||||
|
|
||||||
for ($i = 0, $count = count($pairs); $i < $count; $i++) {
|
for ($i = 0, $count = count($pairs); $i < $count; $i++) {
|
||||||
$pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
|
$pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
|
||||||
if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $pairs[$i + 1])) {
|
if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
|
||||||
$pair .= ' '.$pairs[$i + 1];
|
$pair .= ' '.$pairs[$i + 1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,7 +536,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
{
|
{
|
||||||
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
|
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
|
||||||
// skip platform packages, root package and composer-plugin-api
|
// skip platform packages, root package and composer-plugin-api
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) {
|
if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
|
|
||||||
$realName = preg_replace('{~dev$}', '', $name);
|
$realName = preg_replace('{~dev$}', '', $name);
|
||||||
// skip platform packages, root package and composer-plugin-api
|
// skip platform packages, root package and composer-plugin-api
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $realName) || '__root__' === $realName) {
|
if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ class FilesystemRepository extends WritableArrayRepository
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
foreach ($package->getReplaces() as $replace) {
|
foreach ($package->getReplaces() as $replace) {
|
||||||
// exclude platform replaces as when they are really there we can not check for their presence
|
// exclude platform replaces as when they are really there we can not check for their presence
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $replace->getTarget())) {
|
if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$replaced = $replace->getPrettyConstraint();
|
$replaced = $replace->getPrettyConstraint();
|
||||||
|
@ -169,7 +169,7 @@ class FilesystemRepository extends WritableArrayRepository
|
||||||
}
|
}
|
||||||
foreach ($package->getProvides() as $provide) {
|
foreach ($package->getProvides() as $provide) {
|
||||||
// exclude platform provides as when they are really there we can not check for their presence
|
// exclude platform provides as when they are really there we can not check for their presence
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $provide->getTarget())) {
|
if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$provided = $provide->getPrettyConstraint();
|
$provided = $provide->getPrettyConstraint();
|
||||||
|
|
|
@ -169,7 +169,7 @@ class InstalledRepository extends CompositeRepository
|
||||||
// When inverting, we need to check for conflicts of the needles' requirements against installed packages
|
// When inverting, we need to check for conflicts of the needles' requirements against installed packages
|
||||||
if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
|
if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
|
||||||
foreach ($package->getRequires() as $link) {
|
foreach ($package->getRequires() as $link) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
|
if (PlatformRepository::isPlatformPackage($link->getTarget())) {
|
||||||
if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
|
if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class PlatformRepository extends ArrayRepository
|
||||||
// Later we might even replace the extensions instead.
|
// Later we might even replace the extensions instead.
|
||||||
foreach ($this->overrides as $override) {
|
foreach ($this->overrides as $override) {
|
||||||
// Check that it's a platform package.
|
// Check that it's a platform package.
|
||||||
if (!preg_match(self::PLATFORM_PACKAGE_REGEX, $override['name'])) {
|
if (!self::isPlatformPackage($override['name'])) {
|
||||||
throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
|
throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ class RepositorySet
|
||||||
$this->stabilityFlags = $stabilityFlags;
|
$this->stabilityFlags = $stabilityFlags;
|
||||||
$this->rootRequires = $rootRequires;
|
$this->rootRequires = $rootRequires;
|
||||||
foreach ($rootRequires as $name => $constraint) {
|
foreach ($rootRequires as $name => $constraint) {
|
||||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
|
if (PlatformRepository::isPlatformPackage($name)) {
|
||||||
unset($this->rootRequires[$name]);
|
unset($this->rootRequires[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue