Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jan 20, 2024
1 parent 15c3fd6 commit e7cc7ba
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/Asset/AssetManagerFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function addManager(AssetManagerInterface $manager): void
/**
* Find the asset manager.
*
* @param null|string $manager The name of the asset manager
* @param string|null $manager The name of the asset manager
*
* @throws RuntimeException When the asset manager does not exist
* @throws RuntimeException When the asset manager is not found
Expand Down
6 changes: 3 additions & 3 deletions src/Config/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ConfigBuilder
*
* @param Composer $composer The composer.
* @param array $defaults The default values.
* @param null|IOInterface $io The composer input/output.
* @param IOInterface|null $io The composer input/output.
*/
public static function build(Composer $composer, array $defaults = [], IOInterface $io = null): Config
{
Expand All @@ -42,7 +42,7 @@ public static function build(Composer $composer, array $defaults = [], IOInterfa
* Get the base of data.
*
* @param Composer $composer The composer.
* @param null|IOInterface $io The composer input/output.
* @param IOInterface|null $io The composer input/output.
*/
private static function getConfigBase(Composer $composer, IOInterface $io = null): array
{
Expand All @@ -61,7 +61,7 @@ private static function getConfigBase(Composer $composer, IOInterface $io = null
*
* @param Composer $composer The composer.
* @param string $filename The filename.
* @param null|IOInterface $io The composer input/output.
* @param IOInterface|null $io The composer input/output.
*/
private static function getGlobalConfig(Composer $composer, string $filename, IOInterface $io = null): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Fallback/ComposerFallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class ComposerFallback implements FallbackInterface
* @param IOInterface $io The IO.
* @param Config $config The config.
* @param InputInterface $input The input.
* @param null|Filesystem $fs The composer filesystem.
* @param null|Installer $installer The installer.
* @param Filesystem|null $fs The composer filesystem.
* @param Installer|null $installer The installer.
*/
public function __construct(
protected Composer $composer,
Expand Down
8 changes: 4 additions & 4 deletions src/Foxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ final class Foxy implements PluginInterface, EventSubscriberInterface
* The list of the classes of asset managers.
*/
private static $assetManagers = [
\Foxy\Asset\NpmManager::class,
\Foxy\Asset\PnpmManager::class,
\Foxy\Asset\YarnManager::class,
Asset\NpmManager::class,
Asset\PnpmManager::class,
Asset\YarnManager::class,
];

/**
Expand Down Expand Up @@ -119,7 +119,7 @@ public static function getSubscribedEvents(): array

public function activate(Composer $composer, IOInterface $io): void
{
ComposerUtil::validateVersion(static::REQUIRED_COMPOSER_VERSION, Composer::VERSION);
ComposerUtil::validateVersion(self::REQUIRED_COMPOSER_VERSION, Composer::VERSION);

$input = ConsoleUtil::getInput($io);
$executor = new ProcessExecutor($io);
Expand Down
1 change: 0 additions & 1 deletion src/Json/JsonFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function write(array $hash, int $options = 448): void
self::$encodeIndent = 4;
}


public static function encode(mixed $data, int $options = 448, string $indent = self::INDENT_DEFAULT): string
{
$result = parent::encode($data, $options, $indent);
Expand Down
3 changes: 2 additions & 1 deletion src/Solver/Solver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class Solver implements SolverInterface
*
* @param AssetManagerInterface $assetManager The asset manager instance.
* @param Config $config The config instance.
* @param null|FallbackInterface $composerFallback The composer fallback instance.
* @param FallbackInterface|null $composerFallback The composer fallback instance.
*/
public function __construct(
protected AssetManagerInterface $assetManager,
Expand Down Expand Up @@ -89,6 +89,7 @@ public function solve(Composer $composer, IOInterface $io): void
* @param array $packages The package dependencies.
*
* @psalm-param PackageInterface[] $packages The package dependencies.
*
* @psalm-return array[] The package name and the relative package path from the current directory.
*/
protected function getAssets(Composer $composer, string $assetDir, array $packages): array
Expand Down
10 changes: 5 additions & 5 deletions src/Util/AssetUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function getPath(
): string|null {
$path = null;

if (static::isAsset($package, $configPackages)) {
if (self::isAsset($package, $configPackages)) {
$installPath = $installationManager->getInstallPath($package);
$filename = $installPath . '/' . $assetManager->getPackageName();
$path = \file_exists($filename) ? \str_replace('\\', '/', \realpath($filename)) : null;
Expand All @@ -72,9 +72,9 @@ public static function isAsset(PackageInterface $package, array $configPackages
$projectConfig = self::getProjectActivation($package, $configPackages);
$enabled = false !== $projectConfig;

return $enabled && (static::hasExtraActivation($package)
|| static::hasPluginDependency($package->getRequires())
|| static::hasPluginDependency($package->getDevRequires())
return $enabled && (self::hasExtraActivation($package)
|| self::hasPluginDependency($package->getRequires())
|| self::hasPluginDependency($package->getDevRequires())
|| true === $projectConfig);
}

Expand Down Expand Up @@ -173,7 +173,7 @@ private static function formatVersion(string $version): string
* @param PackageInterface $package The package instance.
* @param array $configPackages The packages defined in config.
*
* @return null|bool returns NULL, if the package isn't defined in the project config
* @return bool|null returns NULL, if the package isn't defined in the project config
*/
private static function getProjectActivation(PackageInterface $package, array $configPackages): bool|null
{
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ConsoleUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function getPreferredInstallOptions(Config $config, InputInterface
$preferSource = true;

break;

case 'dist':
$preferDist = true;

Expand Down
2 changes: 1 addition & 1 deletion src/Util/LockerUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function getLocker(
string $composerFile
): Locker {
$lockFile = str_replace('.json', '.lock', $composerFile);

return new Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile));
}
}
8 changes: 3 additions & 5 deletions src/Util/PackageUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ final class PackageUtil
public static function loadLockPackages(array $lockData): array
{
$loader = new ArrayLoader();
$lockData = static::loadLockPackage($loader, $lockData);
$lockData = static::loadLockPackage($loader, $lockData, true);
$lockData = static::convertLockAlias($lockData);

return $lockData;
$lockData = self::loadLockPackage($loader, $lockData);
$lockData = self::loadLockPackage($loader, $lockData, true);
return self::convertLockAlias($lockData);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions tests/Asset/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testAddDependenciesForInstallCommand(): void
$expectedPackage = [
'dependencies' => [
'@composer-asset/foo--bar' => 'file:./path/foo/bar',
'@composer-asset/new--dependency' => 'file:./path/new/dependency'
'@composer-asset/new--dependency' => 'file:./path/new/dependency',
],
];
$allDependencies = [
Expand Down Expand Up @@ -191,7 +191,7 @@ public function testAddDependenciesForUpdateCommand(): void
$expectedPackage = [
'dependencies' => [
'@composer-asset/foo--bar' => 'file:./path/foo/bar',
'@composer-asset/new--dependency' => 'file:./path/new/dependency'
'@composer-asset/new--dependency' => 'file:./path/new/dependency',
],
];
$package = [
Expand Down Expand Up @@ -291,10 +291,15 @@ public function testRunForInstallCommand(int $expectedRes, string $action): void
}

abstract protected function getManager(): AssetManagerInterface;

abstract protected function getValidName(): string;

abstract protected function getValidLockPackageName(): string;

abstract protected function getValidVersionCommand(): string;

abstract protected function getValidInstallCommand(): string;

abstract protected function getValidUpdateCommand(): string;

protected function actionForTestAddDependenciesForUpdateCommand(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Asset/AssetPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function testRemoveUnusedDependencies(): void
* Add the package in file.
*
* @param array $package The package.
* @param null|string $contentString The string content of package.
* @param string|null $contentString The string content of package.
*/
protected function addPackageFile(array $package, $contentString = null): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function getDataForGetConfig(): array
* @param string $key The key.
* @param mixed $expected The expected value.
* @param mixed $default The default value.
* @param null|string $env The env variable.
* @param string|null $env The env variable.
* @param array $defaults The configured default values.
*/
public function testGetConfig(
Expand Down Expand Up @@ -109,10 +109,10 @@ public function testGetConfig(
'manager' => 'quill',
'manager-bar' => [
'peter' => 42,
'quill' => 23
'quill' => 23,
],
'manager-baz' => [
'peter' => 42
'peter' => 42,
],
],
],
Expand Down
1 change: 0 additions & 1 deletion tests/Event/GetAssetsEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class GetAssetsEventTest extends SolveEvent
{
private array $assets = ['@composer-asset/foo--bar' => 'file:./vendor/foxy/composer-asset/foo/bar'];


public function getEvent(): GetAssetsEvent
{
return new GetAssetsEvent($this->assetDir, $this->packages, $this->assets);
Expand Down
16 changes: 9 additions & 7 deletions tests/Fixtures/Util/AbstractProcessExecutorMock.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Foxy package.
*
Expand Down Expand Up @@ -64,7 +66,7 @@ public function addExpectedValues($returnedCode = 0, $output = null)
*
* @param int $position The position of executed command
*
* @return null|string
* @return string|null
*/
public function getExecutedCommand($position)
{
Expand All @@ -76,7 +78,7 @@ public function getExecutedCommand($position)
*
* @param int $position The position of executed command
*
* @return null|int
* @return int|null
*/
public function getExecutedReturnedCode($position)
{
Expand All @@ -88,7 +90,7 @@ public function getExecutedReturnedCode($position)
*
* @param int $position The position of executed command
*
* @return null|string
* @return string|null
*/
public function getExecutedOutput($position)
{
Expand All @@ -98,7 +100,7 @@ public function getExecutedOutput($position)
/**
* Get the last executed command.
*
* @return null|string
* @return string|null
*/
public function getLastCommand()
{
Expand All @@ -108,7 +110,7 @@ public function getLastCommand()
/**
* Get the last executed returned code.
*
* @return null|int
* @return int|null
*/
public function getLastReturnedCode()
{
Expand All @@ -118,7 +120,7 @@ public function getLastReturnedCode()
/**
* Get the last executed output.
*
* @return null|string
* @return string|null
*/
public function getLastOutput()
{
Expand All @@ -131,7 +133,7 @@ public function getLastOutput()
* @param int $position The position
* @param int $index The index of value
*
* @return null|int|string
* @return int|string|null
*/
private function getExecutedValue($position, int $index)
{
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/Util/ProcessExecutorMock.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Foxy package.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/Util/ProcessExecutorMockTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Foxy package.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/JsonFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testFormat(): void
$data = [
'name' => 'test',
'contributors' => [],
'dependencies' => ['@foo/bar' => '^1.0.0'], 'devDependencies' => []
'dependencies' => ['@foo/bar' => '^1.0.0'], 'devDependencies' => [],
];
$content = json_encode($data);

Expand Down
4 changes: 2 additions & 2 deletions tests/Solver/SolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function setUp(): void

$this->localRepo = $this->createMock(InstalledArrayRepository::class);

if (\class_exists(\Composer\Util\HttpDownloader::class)) {
if (\class_exists(HttpDownloader::class)) {
$rm = new RepositoryManager($this->io, $this->composerConfig, new HttpDownloader($this->io, $this->composerConfig));
$rm->setLocalRepository($this->localRepo);
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ public static function getSolveData(): array
*/
public function testSolve(int $resRunManager): void
{
/** @var PackageInterface|MockObject $requirePackage */
/** @var MockObject|PackageInterface $requirePackage */
$requirePackage = $this->createMock(PackageInterface::class);

$requirePackage->expects($this->any())->method('getPrettyVersion')->willReturn('1.0.0');
Expand Down
10 changes: 5 additions & 5 deletions tests/Util/AssetUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testGetPathWithoutRequiredFoxy(): void

$assetManager = $this->createMock(AbstractAssetManager::class);

/** @var PackageInterface|MockObject $package */
/** @var MockObject|PackageInterface $package */
$package = $this->createMock(PackageInterface::class);

$package->expects($this->once())->method('getRequires')->willReturn([]);
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testHasPluginDependency(): void
[
new Link('root/package', 'foo/bar', new Constraint('=', '1.0.0')),
new Link('root/package', 'foxy/foxy', new Constraint('=', '1.0.0')),
new Link('root/package', 'bar/foo', new Constraint('=', '1.0.0'))
new Link('root/package', 'bar/foo', new Constraint('=', '1.0.0')),
],
)
);
Expand Down Expand Up @@ -239,7 +239,7 @@ public function testIsProjectActivation(string $packageName, bool $expected): vo
'full-disable/qualified' => false,
];

/** @var PackageInterface|MockObject $package */
/** @var MockObject|PackageInterface $package */
$package = $this->createMock(PackageInterface::class);

$package->expects($this->once())->method('getName')->willReturn($packageName);
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testIsProjectActivationWithWildcardPattern(string $packageName,
'*' => true,
];

/** @var PackageInterface|MockObject $package */
/** @var MockObject|PackageInterface $package */
$package = $this->createMock(PackageInterface::class);

$package->expects($this->once())->method('getName')->willReturn($packageName);
Expand Down Expand Up @@ -313,7 +313,7 @@ public function testFormatPackage(
): void {
$packageName = '@composer-asset/foo--bar';

/** @var PackageInterface|MockObject $package */
/** @var MockObject|PackageInterface $package */
$package = $this->createMock(PackageInterface::class);

$assetPackage = [];
Expand Down
Loading

0 comments on commit e7cc7ba

Please sign in to comment.