Skip to content

Commit

Permalink
Merge branch '1.x' into 2.x
Browse files Browse the repository at this point in the history
* 1.x:
  More explicit nullable types
  Make implicit nullable types explicit
  • Loading branch information
nicolas-grekas committed Apr 16, 2024
2 parents b0a405f + 2081076 commit 96f355d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
'nullable_type_declaration_for_default_null_value' => true,
'protected_to_private' => false,
))
->setRiskyAllowed(true)
Expand Down
2 changes: 1 addition & 1 deletion src/Command/UpdateRecipesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

private function getRecipe(PackageInterface $package, string $recipeRef = null, string $recipeVersion = null): ?Recipe
private function getRecipe(PackageInterface $package, ?string $recipeRef = null, ?string $recipeVersion = null): ?Recipe
{
$operation = new InformationOperation($package);
if (null !== $recipeRef) {
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/EnvConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function unconfigurePhpUnit(Recipe $recipe, $vars)
* If $originalValue is passed, and the value contains an expression.
* the $originalValue is used.
*/
private function evaluateValue($value, string $originalValue = null)
private function evaluateValue($value, ?string $originalValue = null)
{
if ('%generate(secret)%' === $value) {
if (null !== $originalValue) {
Expand Down
4 changes: 4 additions & 0 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class Downloader
private $enabled = true;
private $composer;

<<<<<<< HEAD
public function __construct(Composer $composer, IoInterface $io, HttpDownloader $rfs)
=======
public function __construct(Composer $composer, IOInterface $io, $rfs)
>>>>>>> 1.x
{
if (getenv('SYMFONY_CAFILE')) {
$this->caFile = getenv('SYMFONY_CAFILE');
Expand Down
4 changes: 2 additions & 2 deletions src/Flex.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function ($value) {
$this->finish($rootDir, $originalComposerJsonHash);
}

public function finish(string $rootDir, string $originalComposerJsonHash = null): void
public function finish(string $rootDir, ?string $originalComposerJsonHash = null): void
{
$this->synchronizePackageJson($rootDir);
$this->lock->write();
Expand Down Expand Up @@ -718,7 +718,7 @@ private function formatOrigin(Recipe $recipe): string
return sprintf('<info>%s</> (<comment>>=%s</>): From %s', $matches[1], $matches[2], 'auto-generated recipe' === $matches[3] ? '<comment>'.$matches[3].'</>' : $matches[3]);
}

private function shouldRecordOperation(OperationInterface $operation, bool $isDevMode, Composer $composer = null): bool
private function shouldRecordOperation(OperationInterface $operation, bool $isDevMode, ?Composer $composer = null): bool
{
if ($this->dryRun || $this->reinstall) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Options
private $writtenFiles = [];
private $io;

public function __construct(array $options = [], IOInterface $io = null)
public function __construct(array $options = [], ?IOInterface $io = null)
{
$this->options = $options;
$this->io = $io;
Expand Down
2 changes: 1 addition & 1 deletion src/ScriptExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ScriptExecutor
private $options;
private $executor;

public function __construct(Composer $composer, IOInterface $io, Options $options, ProcessExecutor $executor = null)
public function __construct(Composer $composer, IOInterface $io, Options $options, ?ProcessExecutor $executor = null)
{
$this->composer = $composer;
$this->io = $io;
Expand Down
2 changes: 1 addition & 1 deletion src/Unpacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Composer $composer, PackageResolver $resolver, bool
$this->versionParser = new VersionParser();
}

public function unpack(Operation $op, Result $result = null, &$links = [], bool $devRequire = false): Result
public function unpack(Operation $op, ?Result $result = null, &$links = [], bool $devRequire = false): Result
{
if (null === $result) {
$result = new Result();
Expand Down
4 changes: 2 additions & 2 deletions tests/Configurator/AddLinesConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public function getUpdateTests()
];
}

private function runConfigure(array $config, Composer $composer = null)
private function runConfigure(array $config, ?Composer $composer = null)
{
$configurator = $this->createConfigurator($composer);

Expand All @@ -586,7 +586,7 @@ private function runUnconfigure(array $config)
$configurator->unconfigure($recipe, $config, $lock);
}

private function createConfigurator(Composer $composer = null)
private function createConfigurator(?Composer $composer = null)
{
return new AddLinesConfigurator(
$composer ?: $this->getMockBuilder(Composer::class)->getMock(),
Expand Down
6 changes: 3 additions & 3 deletions tests/FlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private function mockPackageEvent(Package $package): PackageEvent
return $event;
}

private function mockConfigurator(Recipe $recipe = null): Configurator
private function mockConfigurator(?Recipe $recipe = null): Configurator
{
$configurator = $this->getMockBuilder(Configurator::class)->disableOriginalConstructor()->getMock();

Expand Down Expand Up @@ -406,7 +406,7 @@ private function mockLocker(array $lockData = []): Locker
return $locker;
}

private function mockComposer(Locker $locker, RootPackageInterface $package, Config $config = null): Composer
private function mockComposer(Locker $locker, RootPackageInterface $package, ?Config $config = null): Composer
{
if (null === $config) {
$config = $this->getMockBuilder(Config::class)->getMock();
Expand Down Expand Up @@ -474,7 +474,7 @@ private function mockFlexCustom(BufferIO $io, Composer $composer, Configurator $
}, null, Flex::class)->__invoke();
}

private function mockFlex(BufferIO $io, RootPackageInterface $package, Recipe $recipe = null, array $recipes = [], array $lockerData = []): Flex
private function mockFlex(BufferIO $io, RootPackageInterface $package, ?Recipe $recipe = null, array $recipes = [], array $lockerData = []): Flex
{
$composer = $this->mockComposer($this->mockLocker($lockerData), $package);

Expand Down

0 comments on commit 96f355d

Please sign in to comment.