diff --git a/src/Command/DumpEnvCommand.php b/src/Command/DumpEnvCommand.php index 6f7ed6f1f..b36cc08ab 100644 --- a/src/Command/DumpEnvCommand.php +++ b/src/Command/DumpEnvCommand.php @@ -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(); } diff --git a/src/Command/InstallRecipesCommand.php b/src/Command/InstallRecipesCommand.php index d1ae1a4b1..017ec0050 100644 --- a/src/Command/InstallRecipesCommand.php +++ b/src/Command/InstallRecipesCommand.php @@ -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(); } diff --git a/src/Command/RecipesCommand.php b/src/Command/RecipesCommand.php index 3cdac81c7..5943607ad 100644 --- a/src/Command/RecipesCommand.php +++ b/src/Command/RecipesCommand.php @@ -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(); diff --git a/src/Command/UpdateRecipesCommand.php b/src/Command/UpdateRecipesCommand.php index c75507eca..40c874637 100644 --- a/src/Command/UpdateRecipesCommand.php +++ b/src/Command/UpdateRecipesCommand.php @@ -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(); diff --git a/src/Configurator.php b/src/Configurator.php index 56976823b..3d0d1db58 100644 --- a/src/Configurator.php +++ b/src/Configurator.php @@ -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, diff --git a/src/Configurator/AbstractConfigurator.php b/src/Configurator/AbstractConfigurator.php index aea4dda94..fbfcedfa7 100644 --- a/src/Configurator/AbstractConfigurator.php +++ b/src/Configurator/AbstractConfigurator.php @@ -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')); } diff --git a/src/Downloader.php b/src/Downloader.php index 2adf00df8..21a980f2c 100644 --- a/src/Downloader.php +++ b/src/Downloader.php @@ -37,11 +37,9 @@ class Downloader private static $versions; private static $aliases; - private $io; private $sess; private $cache; - private HttpDownloader $rfs; private $degradedMode = false; private $endpoints; private $index; @@ -49,10 +47,12 @@ class Downloader 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'); } @@ -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 diff --git a/src/Event/UpdateEvent.php b/src/Event/UpdateEvent.php index 06dbe0c5f..286a982bc 100644 --- a/src/Event/UpdateEvent.php +++ b/src/Event/UpdateEvent.php @@ -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 diff --git a/src/GithubApi.php b/src/GithubApi.php index 391304cea..34b374be2 100644 --- a/src/GithubApi.php +++ b/src/GithubApi.php @@ -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, + ) { } /** diff --git a/src/InformationOperation.php b/src/InformationOperation.php index 8cad6a863..64c6dbc71 100644 --- a/src/InformationOperation.php +++ b/src/InformationOperation.php @@ -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, + ) { } /** diff --git a/src/Options.php b/src/Options.php index f0872b510..3278fc44f 100644 --- a/src/Options.php +++ b/src/Options.php @@ -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) diff --git a/src/PackageFilter.php b/src/PackageFilter.php index 091bcd79b..5dfa6f762 100644 --- a/src/PackageFilter.php +++ b/src/PackageFilter.php @@ -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); diff --git a/src/PackageJsonSynchronizer.php b/src/PackageJsonSynchronizer.php index 698894c5b..f2589b67f 100644 --- a/src/PackageJsonSynchronizer.php +++ b/src/PackageJsonSynchronizer.php @@ -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(); } diff --git a/src/PackageResolver.php b/src/PackageResolver.php index c7a7e5eb6..807b66f25 100644 --- a/src/PackageResolver.php +++ b/src/PackageResolver.php @@ -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 diff --git a/src/Path.php b/src/Path.php index 8c7218b42..65da7e3da 100644 --- a/src/Path.php +++ b/src/Path.php @@ -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 diff --git a/src/Recipe.php b/src/Recipe.php index 3c8697245..4740a3482 100644 --- a/src/Recipe.php +++ b/src/Recipe.php @@ -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 diff --git a/src/Response.php b/src/Response.php index f334c0396..29899d6c9 100644 --- a/src/Response.php +++ b/src/Response.php @@ -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 diff --git a/src/ScriptExecutor.php b/src/ScriptExecutor.php index f895da304..b59274eb6 100644 --- a/src/ScriptExecutor.php +++ b/src/ScriptExecutor.php @@ -25,16 +25,14 @@ */ class ScriptExecutor { - private $composer; - private $io; - private $options; private $executor; - public function __construct(Composer $composer, IOInterface $io, Options $options, ProcessExecutor $executor = null) - { - $this->composer = $composer; - $this->io = $io; - $this->options = $options; + public function __construct( + private Composer $composer, + private IOInterface $io, + private Options $options, + ProcessExecutor $executor = null + ) { $this->executor = $executor ?: new ProcessExecutor(); } diff --git a/src/SymfonyBundle.php b/src/SymfonyBundle.php index 7d1d8a1c3..ee7dd013f 100644 --- a/src/SymfonyBundle.php +++ b/src/SymfonyBundle.php @@ -19,12 +19,13 @@ */ class SymfonyBundle { - private $package; - private $operation; private $vendorDir; - public function __construct(Composer $composer, PackageInterface $package, string $operation) - { + public function __construct( + Composer $composer, + private PackageInterface $package, + private string $operation, + ) { $this->package = $package; $this->operation = $operation; $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/'); diff --git a/src/Unpack/Operation.php b/src/Unpack/Operation.php index 1a6efd3fc..b73a58fcc 100644 --- a/src/Unpack/Operation.php +++ b/src/Unpack/Operation.php @@ -14,13 +14,11 @@ class Operation { private $packages = []; - private $unpack; - private $sort; - public function __construct(bool $unpack, bool $sort) - { - $this->unpack = $unpack; - $this->sort = $sort; + public function __construct( + private bool $unpack, + private bool $sort, + ) { } public function addPackage(string $name, string $version, bool $dev) diff --git a/src/Unpacker.php b/src/Unpacker.php index e186e0323..45b771008 100644 --- a/src/Unpacker.php +++ b/src/Unpacker.php @@ -27,13 +27,13 @@ class Unpacker { - private $composer; - private $resolver; - private $dryRun; private $versionParser; - public function __construct(Composer $composer, PackageResolver $resolver, bool $dryRun) - { + public function __construct( + private Composer $composer, + private PackageResolver $resolver, + private bool $dryRun + ) { $this->composer = $composer; $this->resolver = $resolver; $this->dryRun = $dryRun; diff --git a/src/Update/RecipePatch.php b/src/Update/RecipePatch.php index bb6abdbce..84db3b7c5 100644 --- a/src/Update/RecipePatch.php +++ b/src/Update/RecipePatch.php @@ -13,17 +13,12 @@ class RecipePatch { - private $patch; - private $blobs; - private $deletedFiles; - private $removedPatches; - - public function __construct(string $patch, array $blobs, array $deletedFiles, array $removedPatches = []) - { - $this->patch = $patch; - $this->blobs = $blobs; - $this->deletedFiles = $deletedFiles; - $this->removedPatches = $removedPatches; + public function __construct( + private string $patch, + private array $blobs, + private array $deletedFiles, + private array $removedPatches = [], + ) { } public function getPatch(): string diff --git a/src/Update/RecipePatcher.php b/src/Update/RecipePatcher.php index 1de2b34f6..15b7faa85 100644 --- a/src/Update/RecipePatcher.php +++ b/src/Update/RecipePatcher.php @@ -18,16 +18,14 @@ class RecipePatcher { - private $rootDir; private $filesystem; - private $io; private $processExecutor; - public function __construct(string $rootDir, IOInterface $io) - { - $this->rootDir = $rootDir; + public function __construct( + private string $rootDir, + private IOInterface $io, + ) { $this->filesystem = new Filesystem(); - $this->io = $io; $this->processExecutor = new ProcessExecutor($io); } diff --git a/src/Update/RecipeUpdate.php b/src/Update/RecipeUpdate.php index 994493831..7d14a111a 100644 --- a/src/Update/RecipeUpdate.php +++ b/src/Update/RecipeUpdate.php @@ -16,23 +16,18 @@ class RecipeUpdate { - private $originalRecipe; - private $newRecipe; - private $lock; - private $rootDir; - /** @var string[] */ private $originalRecipeFiles = []; /** @var string[] */ private $newRecipeFiles = []; private $copyFromPackagePaths = []; - public function __construct(Recipe $originalRecipe, Recipe $newRecipe, Lock $lock, string $rootDir) - { - $this->originalRecipe = $originalRecipe; - $this->newRecipe = $newRecipe; - $this->lock = $lock; - $this->rootDir = $rootDir; + public function __construct( + private Recipe $originalRecipe, + private Recipe $newRecipe, + private Lock $lock, + private string $rootDir, + ) { } public function getOriginalRecipe(): Recipe