Skip to content

Commit

Permalink
Remove unnecessary code in PackagesListBuilder + Refactor tests (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Dec 9, 2023
1 parent f8288d9 commit 5c19a99
Show file tree
Hide file tree
Showing 113 changed files with 1,360 additions and 1,386 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Expand Up @@ -10,6 +10,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## 1.5.0 under development

- New #155: Add ability to specify recursion depth for recursive modifier (@vjik)
- Enh #157: Remove unnecessary code in `PackagesListBuilder` (@vjik)

## 1.4.0 November 17, 2023

Expand Down
6 changes: 6 additions & 0 deletions src/Composer/EventHandler.php
Expand Up @@ -34,13 +34,19 @@ public static function getSubscribedEvents(): array
];
}

/**
* @codeCoverageIgnore This method runs via eval and does not get into coverage.
*/
public function onCommand(CommandEvent $event): void
{
if ($event->getCommandName() === 'dump-autoload') {
$this->runOnAutoloadDump = true;
}
}

/**
* @codeCoverageIgnore This method runs via eval and does not get into coverage.
*/
public function onPostAutoloadDump(Event $event): void
{
if ($this->runOnAutoloadDump) {
Expand Down
12 changes: 4 additions & 8 deletions src/Composer/PackagesListBuilder.php
Expand Up @@ -5,7 +5,7 @@
namespace Yiisoft\Config\Composer;

use Composer\Composer;
use Composer\Package\CompletePackage;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;

use function array_key_exists;
Expand All @@ -24,7 +24,7 @@ public function __construct(
/**
* Builds and returns packages.
*
* @return array<string, CompletePackage>
* @return array<string, BasePackage>
*/
public function build(): array
{
Expand Down Expand Up @@ -68,7 +68,7 @@ private function getSortedPackageNames(array $packageDepths): array
}

/**
* @param array<string, CompletePackage> $allPackages
* @param array<string, BasePackage> $allPackages
* @param array<string, int> $packageDepths
*/
private function calculatePackageDepths(
Expand Down Expand Up @@ -105,7 +105,7 @@ private function calculatePackageDepths(
}

/**
* @return array<string, CompletePackage>
* @return array<string, BasePackage>
*/
private function getAllPackages(): array
{
Expand All @@ -116,10 +116,6 @@ private function getAllPackages(): array

$result = [];
foreach ($packages as $package) {
if (!$package instanceof CompletePackage) {
continue;
}

if (!in_array($package->getType(), $this->packageTypes)) {
continue;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Composer/ProcessHelper.php
Expand Up @@ -6,7 +6,7 @@

use Composer\Composer;
use Composer\Factory;
use Composer\Package\CompletePackage;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Yiisoft\Config\ConfigPaths;
use Yiisoft\Config\Options;
Expand All @@ -28,7 +28,7 @@ final class ProcessHelper
private array $rootPackageExtra;

/**
* @psalm-var array<string, CompletePackage>
* @psalm-var array<string, BasePackage>
*/
private array $packages;

Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct(Composer $composer)
/**
* Returns all vendor packages.
*
* @psalm-return array<string, CompletePackage>
* @psalm-return array<string, BasePackage>
*/
public function getPackages(): array
{
Expand All @@ -75,7 +75,7 @@ public function getPackages(): array
/**
* Returns vendor packages without packages from the vendor override sublayer.
*
* @psalm-return array<string, CompletePackage>
* @psalm-return array<string, BasePackage>
*/
public function getVendorPackages(): array
{
Expand All @@ -93,7 +93,7 @@ public function getVendorPackages(): array
/**
* Returns vendor packages only from the vendor override sublayer.
*
* @psalm-return array<string, CompletePackage>
* @psalm-return array<string, BasePackage>
*/
public function getVendorOverridePackages(): array
{
Expand Down
151 changes: 0 additions & 151 deletions tests/Command/CopyCommandTest.php

This file was deleted.

90 changes: 0 additions & 90 deletions tests/Command/RebuildCommandTest.php

This file was deleted.

0 comments on commit 5c19a99

Please sign in to comment.