Skip to content

Commit

Permalink
Fix type error in getProjectConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 27, 2024
1 parent b5decef commit d1894e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Command/Project/ProjectSetRemoteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$gitRemotes = [];
foreach ([$this->config->getStr('detection.git_remote_name'), 'origin'] as $remote) {
$url = $this->git->getConfig(sprintf('remote.%s.url', $remote));
if (\is_string($url) && $this->localProject->parseGitUrl($url) !== false) {
if (\is_string($url) && $this->localProject->parseGitUrl($url) !== null) {
$gitRemotes[$remote] = $url;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Local/LocalProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public function readProjectConfigFile(string $dir, string $configFile): ?array
}

/**
* @return array{id: string, host: string}|false
* The project ID and hostname, or false on failure.
* @return array{id: string, host: string}|null
* The project ID and hostname, or null on failure.
*/
public function parseGitUrl(string $gitUrl): false|array
public function parseGitUrl(string $gitUrl): ?array
{
$gitDomain = $this->config->getStr('detection.git_domain');
$pattern = '/^([a-z0-9]{12,})@git\.(([a-z0-9\-]+\.)?' . preg_quote($gitDomain) . '):\1\.git$/';
if (!preg_match($pattern, $gitUrl, $matches)) {
return false;
return null;
}

return ['id' => $matches[1], 'host' => $matches[2]];
Expand Down

0 comments on commit d1894e4

Please sign in to comment.