Skip to content

Commit

Permalink
Add Cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan2Shrek committed Mar 19, 2024
1 parent b0a405f commit c1a6f75
Show file tree
Hide file tree
Showing 24 changed files with 125 additions and 176 deletions.
12 changes: 4 additions & 8 deletions src/Command/DumpEnvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@

class DumpEnvCommand extends BaseCommand
{
private $config;
private $options;

public function __construct(Config $config, Options $options)
{
$this->config = $config;
$this->options = $options;

public function __construct(
private Config $config,
private Options $options,
) {
parent::__construct();
}

Expand Down
18 changes: 8 additions & 10 deletions src/Command/InstallRecipesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@

class InstallRecipesCommand extends BaseCommand
{
/** @var Flex */
private $flex;
private $rootDir;
private $dotenvPath;

public function __construct(/* cannot be type-hinted */ $flex, string $rootDir, string $dotenvPath = '.env')
/**
* @param Flex $flex
*/
public function __construct(
/* cannot be type-hinted */ private $flex,
private string $rootDir,
private string $dotenvPath = '.env'
)
{
$this->flex = $flex;
$this->rootDir = $rootDir;
$this->dotenvPath = $dotenvPath;

parent::__construct();
}

Expand Down
15 changes: 8 additions & 7 deletions src/Command/RecipesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
*/
class RecipesCommand extends BaseCommand
{
/** @var \Symfony\Flex\Flex */
private $flex;

private Lock $symfonyLock;
private GithubApi $githubApi;

public function __construct(/* cannot be type-hinted */ $flex, Lock $symfonyLock, HttpDownloader $downloader)
/**
* @param \Symfony\Flex\Flex $flex
*/
public function __construct(
/* cannot be type-hinted */ private $flex,
private Lock $symfonyLock,
HttpDownloader $downloader
)
{
$this->flex = $flex;
$this->symfonyLock = $symfonyLock;
$this->githubApi = new GithubApi($downloader);

parent::__construct();
Expand Down
20 changes: 10 additions & 10 deletions src/Command/UpdateRecipesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@

class UpdateRecipesCommand extends BaseCommand
{
/** @var Flex */
private $flex;
private $downloader;
private $configurator;
private $rootDir;
private $githubApi;
private $processExecutor;

public function __construct(/* cannot be type-hinted */ $flex, Downloader $downloader, $httpDownloader, Configurator $configurator, string $rootDir)
/**
* @param Flex $flex
*/
public function __construct(
/* cannot be type-hinted */ private $flex,
private Downloader $downloader,
$httpDownloader,
private Configurator $configurator,
private string $rootDir
)
{
$this->flex = $flex;
$this->downloader = $downloader;
$this->configurator = $configurator;
$this->rootDir = $rootDir;
$this->githubApi = new GithubApi($httpDownloader);

parent::__construct();
Expand Down
13 changes: 5 additions & 8 deletions src/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@
*/
class Configurator
{
private $composer;
private $io;
private $options;
private $configurators;
private $postInstallConfigurators;
private $cache;

public function __construct(Composer $composer, IOInterface $io, Options $options)
{
$this->composer = $composer;
$this->io = $io;
$this->options = $options;
public function __construct(
private Composer $composer,
private IOInterface $io,
private Options $options,
) {
// ordered list of configurators
$this->configurators = [
'bundles' => Configurator\BundlesConfigurator::class,
Expand Down
13 changes: 5 additions & 8 deletions src/Configurator/AbstractConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
*/
abstract class AbstractConfigurator
{
protected $composer;
protected $io;
protected $options;
protected $path;

public function __construct(Composer $composer, IOInterface $io, Options $options)
{
$this->composer = $composer;
$this->io = $io;
$this->options = $options;
public function __construct(
protected Composer $composer,
protected IOInterface $io,
protected Options $options,
) {
$this->path = new Path($options->get('root-dir'));
}

Expand Down
12 changes: 5 additions & 7 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ class Downloader
private static $versions;
private static $aliases;

private $io;
private $sess;
private $cache;

private HttpDownloader $rfs;
private $degradedMode = false;
private $endpoints;
private $index;
private $conflicts;
private $legacyEndpoint;
private $caFile;
private $enabled = true;
private $composer;

public function __construct(Composer $composer, IoInterface $io, HttpDownloader $rfs)
{
public function __construct(
private Composer $composer,
private IoInterface $io,
private HttpDownloader $rfs,
) {
if (getenv('SYMFONY_CAFILE')) {
$this->caFile = getenv('SYMFONY_CAFILE');
}
Expand Down Expand Up @@ -87,12 +87,10 @@ public function __construct(Composer $composer, IoInterface $io, HttpDownloader
$this->endpoints = array_fill_keys($this->endpoints, []);
}

$this->io = $io;
$config = $composer->getConfig();
$this->rfs = $rfs;
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/flex');
$this->sess = bin2hex(random_bytes(16));
$this->composer = $composer;
}

public function getSessionId(): string
Expand Down
11 changes: 4 additions & 7 deletions src/Event/UpdateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

class UpdateEvent extends Event
{
private $force;
private $reset;

public function __construct(bool $force, bool $reset)
{
public function __construct(
private bool $force,
private bool $reset,
) {
$this->name = ScriptEvents::POST_UPDATE_CMD;
$this->force = $force;
$this->reset = $reset;
}

public function force(): bool
Expand Down
9 changes: 3 additions & 6 deletions src/GithubApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

class GithubApi
{
/** @var HttpDownloader|RemoteFilesystem */
private $downloader;

public function __construct($downloader)
{
$this->downloader = $downloader;
public function __construct(
private HttpDownloader|RemoteFilesystem $downloader,
) {
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/InformationOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
*/
class InformationOperation implements OperationInterface
{
private $package;
private $recipeRef = null;
private $version = null;

public function __construct(PackageInterface $package)
{
$this->package = $package;
public function __construct(
private PackageInterface $package,
) {
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
*/
class Options
{
private $options;
private $writtenFiles = [];
private $io;

public function __construct(array $options = [], IOInterface $io = null)
{
$this->options = $options;
$this->io = $io;
public function __construct(
private array $options = [],
private ?IOInterface $io = null,
) {
}

public function get(string $name)
Expand Down
8 changes: 5 additions & 3 deletions src/PackageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ class PackageFilter
{
private $versions;
private $versionParser;
private $symfonyRequire;
private $symfonyConstraints;
private $downloader;
private $io;

public function __construct(IOInterface $io, string $symfonyRequire, Downloader $downloader)
{
public function __construct(
IOInterface $io,
private string $symfonyRequire,
Downloader $downloader,
) {
$this->versionParser = new VersionParser();
$this->symfonyRequire = $symfonyRequire;
$this->symfonyConstraints = $this->versionParser->parseConstraints($symfonyRequire);
Expand Down
16 changes: 6 additions & 10 deletions src/PackageJsonSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@
*/
class PackageJsonSynchronizer
{
private $rootDir;
private $vendorDir;
private $scriptExecutor;
private $io;
private $versionParser;

public function __construct(string $rootDir, string $vendorDir, ScriptExecutor $scriptExecutor, IOInterface $io)
{
$this->rootDir = $rootDir;
$this->vendorDir = $vendorDir;
$this->scriptExecutor = $scriptExecutor;
$this->io = $io;
public function __construct(
private string $rootDir,
private string $vendorDir,
private ScriptExecutor $scriptExecutor,
private IOInterface $io
) {
$this->versionParser = new VersionParser();
}

Expand Down
7 changes: 3 additions & 4 deletions src/PackageResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
class PackageResolver
{
private static $SYMFONY_VERSIONS = ['lts', 'previous', 'stable', 'next', 'dev'];
private $downloader;

public function __construct(Downloader $downloader)
{
$this->downloader = $downloader;
public function __construct(
private Downloader $downloader,
) {
}

public function resolve(array $arguments = [], bool $isRequire = false): array
Expand Down
8 changes: 3 additions & 5 deletions src/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/
class Path
{
private $workingDirectory;

public function __construct($workingDirectory)
{
$this->workingDirectory = $workingDirectory;
public function __construct(
private $workingDirectory,
) {
}

public function relativize(string $absolutePath): string
Expand Down
20 changes: 7 additions & 13 deletions src/Recipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@
*/
class Recipe
{
private $package;
private $name;
private $job;
private $data;
private $lock;

public function __construct(PackageInterface $package, string $name, string $job, array $data, array $lock = [])
{
$this->package = $package;
$this->name = $name;
$this->job = $job;
$this->data = $data;
$this->lock = $lock;
public function __construct(
private PackageInterface $package,
private string $name,
private string $job,
private array $data,
private array $lock = [],
) {
}

public function getPackage(): PackageInterface
Expand Down
15 changes: 6 additions & 9 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
*/
class Response implements \JsonSerializable
{
private $body;
private $origHeaders;
private $headers;
private $code;

/**
* @param mixed $body The response as JSON
*/
public function __construct($body, array $headers = [], int $code = 200)
{
$this->body = $body;
$this->origHeaders = $headers;
$this->headers = $this->parseHeaders($headers);
$this->code = $code;
public function __construct(
private $body,
private array $origHeaders = [],
private int $code = 200,
) {
$this->headers = $this->parseHeaders($origHeaders);
}

public function getStatusCode(): int
Expand Down
Loading

0 comments on commit c1a6f75

Please sign in to comment.