Skip to content

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
onspli committed Sep 27, 2024
1 parent 4efcf6d commit f61b0db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
9 changes: 4 additions & 5 deletions src/PackageSelection/PackageSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -917,25 +917,24 @@ private function filterRepositories(array $repositories): array
$repositories,
function ($repository) {
if ($repository instanceof ConfigurableRepositoryInterface) {

$config = $repository->getRepoConfig();
if (!isset($config['url'])) {
return false;
}

return in_array($config['url'], $this->repositoriesFilter ?? [], true);

} else if ($repository instanceof ArrayRepository) {
} elseif ($repository instanceof ArrayRepository) {
$packages = $repository->getPackages();
foreach ($packages as $package) {
if (in_array($package->getSourceUrl(), $this->repositoriesFilter ?? [], true)) {
return true;
}
}

return false;
} else {
return false;
}

return false;
}
);
}
Expand Down
26 changes: 12 additions & 14 deletions tests/PackageSelection/PackageSelectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,35 +788,35 @@ public function dataFilterRepos(): array
'source' => [
'url' => '[email protected]:vendor/project-alpha.git',
'type' => 'vcs',
'reference' => '1.2.3.1'
]
'reference' => '1.2.3.1',
],
],
'alpha2' => [
'name' => 'vendor/project-alpha',
'version' => '1.2.3.2',
'source' => [
'url' => '[email protected]:vendor/project-alpha.git',
'type' => 'vcs',
'reference' => '1.2.3.2'
]
'reference' => '1.2.3.2',
],
],
'beta1' => [
'name' => 'vendor/project-beta',
'version' => '1.2.3.1',
'source' => [
'url' => '[email protected]:vendor/project-beta.git',
'type' => 'vcs',
'reference' => '1.2.3.1'
]
'reference' => '1.2.3.1',
],
],
'gamma1' => [
'name' => 'vendor/project-gamma',
'version' => '1.2.3.1',
'source' => [
'url' => '[email protected]:vendor/project-gamma.git',
'type' => 'vcs',
'reference' => '1.2.3.1'
]
'reference' => '1.2.3.1',
],
],
];

Expand All @@ -826,19 +826,19 @@ public function dataFilterRepos(): array
'package' => [
$packages['alpha1'],
$packages['alpha2'],
]
],
],
'beta_packages' => [
'type' => 'package',
'package' => [
$packages['beta1'],
]
],
],
'gamma_packages' => [
'type' => 'package',
'package' => [
$packages['gamma1'],
]
],
],
];

Expand Down Expand Up @@ -868,7 +868,7 @@ public function dataFilterRepos(): array
],
['[email protected]:vendor/project-beta.git'],
];

$data['Filter by two repositories'] = [
[
$packages['alpha1'],
Expand All @@ -890,11 +890,9 @@ public function dataFilterRepos(): array
* @param string[] $expected
* @param array<string, mixed> $config
* @param string[]|null $filterRepos
* @param string[]|null $filterPackages
*/
public function testFilterRepos(array $expected, array $config, array $filterRepos = null): void
{

unset(Config::$defaultRepositories['packagist'], Config::$defaultRepositories['packagist.org']);

$composer = (new Factory())->createComposer(new NullIO(), $config, true, null, false);
Expand Down

0 comments on commit f61b0db

Please sign in to comment.