Skip to content

Commit

Permalink
Stop using implicitly nullable parameter (PHP 8.4 forward compatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 20, 2024
1 parent 70e3038 commit 97821e3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Bundle/BundleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BundleLoader
*/
private $filesystem;

public function __construct(PluginLoader $pluginLoader, ConfigResolverFactory $resolverFactory, ParserInterface $parser, Filesystem $filesystem = null)
public function __construct(PluginLoader $pluginLoader, ConfigResolverFactory $resolverFactory, ParserInterface $parser, ?Filesystem $filesystem = null)
{
$this->pluginLoader = $pluginLoader;
$this->resolverFactory = $resolverFactory;
Expand All @@ -57,7 +57,7 @@ public function __construct(PluginLoader $pluginLoader, ConfigResolverFactory $r
*
* @return array<ConfigInterface>
*/
public function getBundleConfigs(bool $development, string $cacheFile = null): array
public function getBundleConfigs(bool $development, ?string $cacheFile = null): array
{
if (null !== $cacheFile) {
return $this->loadFromCache($development, $cacheFile);
Expand All @@ -71,7 +71,7 @@ public function getBundleConfigs(bool $development, string $cacheFile = null): a
*
* @return array<ConfigInterface>
*/
private function loadFromCache(bool $development, string $cacheFile = null): array
private function loadFromCache(bool $development, ?string $cacheFile = null): array
{
$bundleConfigs = is_file($cacheFile) ? include $cacheFile : null;

Expand All @@ -87,7 +87,7 @@ private function loadFromCache(bool $development, string $cacheFile = null): arr
*
* @return array<ConfigInterface>
*/
private function loadFromPlugins(bool $development, string $cacheFile = null): array
private function loadFromPlugins(bool $development, ?string $cacheFile = null): array
{
$resolver = $this->resolverFactory->create();

Expand Down
2 changes: 1 addition & 1 deletion src/Composer/ManagerPluginInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ManagerPluginInstaller implements PluginInterface, EventSubscriberInterfac
*/
private $filesystem;

public function __construct(Filesystem $filesystem = null)
public function __construct(?Filesystem $filesystem = null)
{
$this->filesystem = $filesystem ?: new Filesystem();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Config/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ContainerBuilder extends SymfonyContainerBuilder
*/
private $managerConfig;

public function __construct(PluginLoader $pluginLoader, array $managerConfig, ParameterBagInterface $parameterBag = null)
public function __construct(PluginLoader $pluginLoader, array $managerConfig, ?ParameterBagInterface $parameterBag = null)
{
parent::__construct($parameterBag);

Expand Down
2 changes: 1 addition & 1 deletion src/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PluginLoader
*/
private $disabled = [];

public function __construct(string $installedJson = null, array $plugins = null)
public function __construct(?string $installedJson = null, ?array $plugins = null)
{
if (null !== $installedJson) {
@trigger_error('Passing the path to the Composer installed.json as first argument is no longer supported in version 2.3.', E_USER_DEPRECATED);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PluginLoader
*/
private $disabled = [];

public function __construct(string $installedJson = null, array $plugins = null)
public function __construct(?string $installedJson = null, ?array $plugins = null)
{
if (null !== $installedJson) {
@trigger_error('Passing the path to the Composer installed.json as first argument is no longer supported in version 2.3.', E_USER_DEPRECATED);
Expand Down
4 changes: 2 additions & 2 deletions tests/Composer/ArtifactsPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static function (array $repository) {
*
* @return Composer&MockObject
*/
private function mockComposerWithDataDir(Config $config, RepositoryManager $repositoryManager = null, array $packages = [], array $requires = []): Composer
private function mockComposerWithDataDir(Config $config, ?RepositoryManager $repositoryManager = null, array $packages = [], array $requires = []): Composer
{
$requires = array_map(
function ($matches) {
Expand Down Expand Up @@ -641,7 +641,7 @@ private function mockConfig(?string $dataDir): MockObject
/**
* @return PackageInterface&MockObject
*/
private function mockPackage(string $name, string $type, string $version = null, string $distUrl = null, bool $required = true): PackageInterface
private function mockPackage(string $name, string $type, ?string $version = null, ?string $distUrl = null, bool $required = true): PackageInterface
{
$package = $this->createMock(PackageInterface::class);
$package
Expand Down

0 comments on commit 97821e3

Please sign in to comment.