Skip to content

Commit

Permalink
PHP 8.1 alias fix (#4873)
Browse files Browse the repository at this point in the history
* Ensure that alias is a string

* Do less if there is no alias
  • Loading branch information
alexpott committed Oct 29, 2021
1 parent b4f52a3 commit 887f624
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Preflight/PreflightSiteLocator.php
Expand Up @@ -36,7 +36,6 @@ public function __construct(SiteAliasManager $siteAliasManager)
*/
public function findSite(PreflightArgsInterface $preflightArgs, Environment $environment, $root)
{
$aliasName = $preflightArgs->alias();
$self = $this->determineSelf($preflightArgs, $environment, $root);

// If the user provided a uri on the commandline, inject it
Expand All @@ -61,19 +60,21 @@ public function findSite(PreflightArgsInterface $preflightArgs, Environment $env
*/
protected function determineSelf(PreflightArgsInterface $preflightArgs, Environment $environment, $root)
{
$aliasName = $preflightArgs->alias();

// If the user specified an @alias, that takes precidence.
if (SiteAliasName::isAliasName($aliasName)) {
// TODO: Should we do something about `@self` here? At the moment that will cause getAlias to
// call getSelf(), but we haven't built @self yet.
return $this->siteAliasManager->getAlias($aliasName);
}
if ($preflightArgs->hasAlias()) {
$aliasName = $preflightArgs->alias();

// If the user specified an @alias, that takes precedence.
if (SiteAliasName::isAliasName($aliasName)) {
// TODO: Should we do something about `@self` here? At the moment that will cause getAlias to
// call getSelf(), but we haven't built @self yet.
return $this->siteAliasManager->getAlias($aliasName);
}

// Ditto for a site spec (/path/to/drupal#uri)
$specParser = new SiteSpecParser();
if ($specParser->validSiteSpec($aliasName)) {
return new SiteAlias($specParser->parse($aliasName, $root), $aliasName);
// Ditto for a site spec (/path/to/drupal#uri)
$specParser = new SiteSpecParser();
if ($specParser->validSiteSpec($aliasName)) {
return new SiteAlias($specParser->parse($aliasName, $root), $aliasName);
}
}

// If the user provides the --root parameter then we don't want to use
Expand Down

0 comments on commit 887f624

Please sign in to comment.