Skip to content

Commit

Permalink
Merge pull request vtsykun#244 from vtsykun/fix/php8.4-support
Browse files Browse the repository at this point in the history
PHP 8.4 fix implicitly nullable parameter declarations deprecated
  • Loading branch information
vtsykun authored Mar 23, 2024
2 parents 9de78b2 + 059441c commit bd68552
Show file tree
Hide file tree
Showing 91 changed files with 196 additions and 196 deletions.
2 changes: 1 addition & 1 deletion src/Composer/Cache/MetadataCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
) {
}

public function get(string $key, callable $callback, int $lastModify = null, callable $needClearCache = null)
public function get(string $key, callable $callback, ?int $lastModify = null, ?callable $needClearCache = null)
{
// Use host key to prevent Cache Poisoning attack, if dist URL generated dynamic.
// But for will protection must be used trusted_hosts
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/IO/DebugIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DebugIO extends ConsoleIO implements ConsoleAwareInterface
LogLevel::INFO => 100,
];

public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null, protected ?int $maxBufferSize = null, OutputInterface $output = null)
public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null, protected ?int $maxBufferSize = null, ?OutputInterface $output = null)
{
$input = new StringInput($input);
$input->setInteractive(false);
Expand All @@ -61,7 +61,7 @@ public function __construct(string $input = '', int $verbosity = StreamOutput::V
/**
* {@inheritdoc}
*/
public function setOutput(OutputInterface $output = null): void
public function setOutput(?OutputInterface $output = null): void
{
$this->consoleOutput = $output;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Composer/MetadataFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ enum MetadataFormat: string
case ONLY_V2 = 'only_v2';
case FULL = 'full';

public function providerIncludes(int $version = null): bool
public function providerIncludes(?int $version = null): bool
{
return match(true) {
$this === MetadataFormat::AUTO && $version === 1, $this === MetadataFormat::ONLY_V1, $this === MetadataFormat::FULL => true,
default => false
};
}

public function lazyProviders(int $version = null): bool
public function lazyProviders(?int $version = null): bool
{
return match(true) {
$this === MetadataFormat::AUTO && $version !== 1 => true,
default => false
};
}

public function metadataUrl(int $version = null): bool
public function metadataUrl(?int $version = null): bool
{
return match(true) {
$this === MetadataFormat::ONLY_V1 => false,
Expand Down
8 changes: 4 additions & 4 deletions src/Composer/PackagistFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
protected PacketonRepositoryFactory $repositoryFactory,
protected IntegrationRegistry $integrations,
protected bool $githubNoApi = true,
string $composerHome = null
?string $composerHome = null
) {
$this->tmpDir = $composerHome ?: sys_get_temp_dir();
if ($composerHome) {
Expand Down Expand Up @@ -62,7 +62,7 @@ public function createDownloadManager(IOInterface $io, PacketonRepositoryInterfa
*
* @return \Composer\Package\Archiver\ArchiveManager|Archiver\ArchiveManager
*/
public function createArchiveManager(IOInterface $io, PacketonRepositoryInterface $repository, DownloadManager $dm = null): ArchiveManager
public function createArchiveManager(IOInterface $io, PacketonRepositoryInterface $repository, ?DownloadManager $dm = null): ArchiveManager
{
$dm ??= $this->createDownloadManager($io, $repository);
$repoConfig = $repository->getRepoConfig();
Expand Down Expand Up @@ -95,7 +95,7 @@ public function createArchiveManager(IOInterface $io, PacketonRepositoryInterfac
* @param CredentialsInterface|null $credentials
* @return \Composer\Config
*/
public function createConfig(CredentialsInterface $credentials = null)
public function createConfig(?CredentialsInterface $credentials = null)
{
$config = ConfigFactory::createConfig();

Expand Down Expand Up @@ -137,7 +137,7 @@ public function createConfig(CredentialsInterface $credentials = null)
*
* @return PacketonRepositoryInterface
*/
public function createRepository(string $url, IOInterface $io = null, Config $config = null, CredentialsInterface $credentials = null, array $repoConfig = []): PacketonRepositoryInterface
public function createRepository(string $url, ?IOInterface $io = null, ?Config $config = null, ?CredentialsInterface $credentials = null, array $repoConfig = []): PacketonRepositoryInterface
{
$io ??= new NullIO();
if (null === $config) {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Repository/Vcs/TreeGitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getFileContent(string $file, string $identifier): ?string
return parent::getFileContent($file, $identifier);
}

public function getRepoTree(string $identifier = null): array
public function getRepoTree(?string $identifier = null): array
{
$identifier ??= $this->getRootIdentifier();
if (str_starts_with($identifier, '-')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Repository/VcsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VcsRepository extends ComposerVcsRepository implements PacketonRepositoryI
/** @var VcsDriverFactory */
protected $driverFactory;

public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, VcsDriverFactory $driverFactory, EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null, ?VersionCacheInterface $versionCache = null)
public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, VcsDriverFactory $driverFactory, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null, ?VersionCacheInterface $versionCache = null)
{
parent::__construct($repoConfig, $io, $config, $httpDownloader, $dispatcher, $process, [], $versionCache);
$this->driverFactory = $driverFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/VcsDriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setDriverClass(string $type, string $class): void
*
* @return \Composer\Repository\Vcs\VcsDriver
*/
public function createDriver(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, string $classOrType = null, array $options = [])
public function createDriver(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, ?string $classOrType = null, array $options = [])
{
$driver = null;
if ($classOrType && class_exists($classOrType)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Api/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function integrationHook(Request $request, string $alias, #[Vars] OAuthIn
#[Route('/api/bitbucket', name: 'bitbucket_postreceive')]
#[Route('/api/update-package', name: 'generic_postreceive')]
#[Route('/api/update-package/{name}', name: 'generic_named_postreceive', requirements: ['name' => '%package_name_regex%'])]
public function updatePackageAction(Request $request, #[Vars] Package $package = null, bool $fallback = false): Response
public function updatePackageAction(Request $request, #[Vars] ?Package $package = null, bool $fallback = false): Response
{
// parse the payload
$payload = $this->getJsonPayload($request);
Expand Down Expand Up @@ -315,7 +315,7 @@ protected function getJsonPayload(Request $request): ?array
return \is_array($payload) ? $payload : null;
}

protected function receiveIntegrationHook(Request $request, OAuthIntegration $oauth = null): ?array
protected function receiveIntegrationHook(Request $request, ?OAuthIntegration $oauth = null): ?array
{
$user = $this->getUser();
if (null === $oauth && $user instanceof AutoHookUser) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/MirrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function providerAction(Request $request, $alias, $provider): Response
return $this->renderMetadata($metadata, $request);
}

protected function renderMetadata(JsonMetadata $metadata, Request $request, callable $lazyLoad = null): Response
protected function renderMetadata(JsonMetadata $metadata, Request $request, ?callable $lazyLoad = null): Response
{
$response = new Response($metadata->getContent(), 200, ['Content-Type' => 'application/json']);
$response->setLastModified($metadata->lastModified());
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/OAuth/IntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected function canEdit(OAuthIntegration $oauth): bool
return $oauth->getOwner() === null || $oauth->getOwner() === $this->getUser()?->getUserIdentifier();
}

protected function getClient($alias, OAuthIntegration $oauth = null): AppInterface
protected function getClient($alias, ?OAuthIntegration $oauth = null): AppInterface
{
if ($alias instanceof OAuthIntegration) {
$oauth = $alias;
Expand Down
10 changes: 5 additions & 5 deletions src/Controller/PackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function listAction(Request $req): Response

#[Route('/packages/submit/{type}', name: 'submit', defaults: ['type' => 'vcs'])]
#[IsGranted('ROLE_MAINTAINER')]
public function submitPackageAction(Request $req, string $type = null): Response
public function submitPackageAction(Request $req, ?string $type = null): Response
{
$package = new Package();
$package->setRepoType(RepTypes::normalizeType($type));
Expand Down Expand Up @@ -157,7 +157,7 @@ public function submitPackageAction(Request $req, string $type = null): Response

#[Route('/packages/fetch-info/{type}', name: 'submit.fetch_info', defaults: ['_format' => 'json', 'type' => 'vcs'])]
#[IsGranted('ROLE_MAINTAINER')]
public function fetchInfoAction(Request $req, string $type = null): Response
public function fetchInfoAction(Request $req, ?string $type = null): Response
{
$package = new Package();
$package->setRepoType(RepTypes::normalizeType($type));
Expand Down Expand Up @@ -998,7 +998,7 @@ public function suggestersAction(Request $req, $name): Response

#[Route('/packages/{name}/stats/all.json', name: 'package_stats', requirements: ['name' => '%package_name_regex%'])]
#[IsGranted('ROLE_FULL_CUSTOMER')]
public function overallStatsAction(Request $req, \Redis $redis, #[Vars] Package $package, Version $version = null): Response
public function overallStatsAction(Request $req, \Redis $redis, #[Vars] Package $package, ?Version $version = null): Response
{
$this->checkSubrepositoryAccess($package->getName());

Expand Down Expand Up @@ -1172,7 +1172,7 @@ private function checkSubrepositoryAccess(string $name): void
}
}

private function createDatePoints(\DateTimeImmutable $from, \DateTimeImmutable $to, $average, Package $package, Version $version = null)
private function createDatePoints(\DateTimeImmutable $from, \DateTimeImmutable $to, $average, Package $package, ?Version $version = null)
{
$interval = $this->getStatsInterval($average);

Expand Down Expand Up @@ -1218,7 +1218,7 @@ private function guessStatsStartDate($packageOrVersion)
return $date->setTime(0, 0, 0);
}

private function guessStatsAverage(\DateTimeImmutable $from, \DateTimeImmutable $to = null)
private function guessStatsAverage(\DateTimeImmutable $from, ?\DateTimeImmutable $to = null)
{
if ($to === null) {
$to = new \DateTimeImmutable('-2 days');
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(

#[Route('/packages.json', name: 'root_packages')]
#[Route('/{slug}/packages.json', name: 'root_packages_slug')]
public function packagesAction(Request $request, string $slug = null): Response
public function packagesAction(Request $request, ?string $slug = null): Response
{
$response = new JsonResponse([]);
$response->setLastModified($this->providerManager->getRootLastModify());
Expand All @@ -54,7 +54,7 @@ public function packagesAction(Request $request, string $slug = null): Response

#[Route('/p/providers${hash}.json', name: 'root_providers', requirements: ['hash' => '[a-f0-9]+'])]
#[Route('/{slug}/p/providers${hash}.json', name: 'root_providers_slug', requirements: ['hash' => '[a-f0-9]+'])]
public function providersAction(string $hash, Request $request, string $slug = null): Response
public function providersAction(string $hash, Request $request, ?string $slug = null): Response
{
$subRepo = $this->subRepositoryHelper->getSubrepositoryId();
$providers = $this->packageManager->getProvidersJson($this->getUser(), $hash, $subRepo);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function userSessionsAction(): Response

#[Route('/users/{name}/login-attempts', name: 'users_login_attempts')]
#[Route('/profile/login-attempts', name: 'profile_login_attempts')]
public function loginAttemptsAction(#[Vars(['name' => 'username'])] User $user = null): Response
public function loginAttemptsAction(#[Vars(['name' => 'username'])] ?User $user = null): Response
{
$currentUser = $this->getUser();
if (null !== $user && true === $user->isAdmin() && $currentUser->getUserIdentifier() !== $user->getUserIdentifier()) {
Expand Down Expand Up @@ -322,7 +322,7 @@ public function packagesAction(Request $req, #[Vars(['name' => 'username'])] Use

#[Route('/users/sshkey', name: 'user_add_sshkey', methods: ['GET', 'POST'])]
#[Route('/users/sshkey/{id}', name: 'user_edit_sshkey', methods: ['GET', 'POST'])]
public function addSSHKeyAction(Request $request, #[Vars] SshCredentials $key = null): Response
public function addSSHKeyAction(Request $request, #[Vars] ?SshCredentials $key = null): Response
{
if ($key && !$this->isGranted('VIEW', $key)) {
throw new AccessDeniedException();
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/GroupAclPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getGroup()
* @param Group $group
* @return GroupAclPermission
*/
public function setGroup(Group $group = null)
public function setGroup(?Group $group = null)
{
$this->group = $group;
return $this;
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public function getRepoType(): ?string
* @param string|null $repoType
* @return Package
*/
public function setRepoType(string $repoType = null)
public function setRepoType(?string $repoType = null)
{
$this->repoType = $repoType;
return $this;
Expand All @@ -494,7 +494,7 @@ public function getParentPackage(): ?Package
* @param Package $parentPackage
* @return $this
*/
public function setParentPackage(Package $package = null)
public function setParentPackage(?Package $package = null)
{
$this->parentPackage = $package;
return $this;
Expand Down Expand Up @@ -775,7 +775,7 @@ public function getCredentials()
* @param SshCredentials $credentials
* @return Package
*/
public function setCredentials(SshCredentials $credentials = null)
public function setCredentials(?SshCredentials $credentials = null)
{
$this->credentials = $credentials;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/PackageSerializedTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function hasRequirePatch(): bool
return (bool) $this->getRequirePatches();
}

public function findRequirePatch(string $normalizedVersion, string &$matchKey = null): ?array
public function findRequirePatch(string $normalizedVersion, ?string &$matchKey = null): ?array
{
$parser = new VersionParser();
foreach ($this->getRequirePatches() as $constraintStr => $patch) {
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/SignalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SignalException extends \RuntimeException
{
public function __construct(string $message = "Process was interrupted by signal", int $code = 0, \Throwable $previous = null)
public function __construct(string $message = "Process was interrupted by signal", int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Handler/DefaultFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
){
}

public function handle(Request|array $request, FormInterface $form, bool $patch = false, callable $onSuccess = null): bool
public function handle(Request|array $request, FormInterface $form, bool $patch = false, ?callable $onSuccess = null): bool
{
if ($request instanceof Request) {
$form->handleRequest($request);
Expand Down
2 changes: 1 addition & 1 deletion src/Import/ImportComposerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setOptions(ProxyOptions $option): void
$this->option = $option;
}

public function getPackages(array $packageNames = null): array
public function getPackages(?array $packageNames = null): array
{
$packages = [];
$allProviders = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Import/MassImportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setIO(?IOInterface $io): void
$this->io = $io;
}

public function createImportJob(ImportRequest $request, UserInterface $user = null): Job
public function createImportJob(ImportRequest $request, ?UserInterface $user = null): Job
{
$repos = $this->getRepoUrls($request);

Expand Down Expand Up @@ -119,7 +119,7 @@ protected function fetchIntegrations(?OAuthIntegration $integration, bool $isInc
return $result;
}

protected function fetchComposerRepos(string $url, string $username = null, string $password = null, int $limit = null, string $packageList = null, string $filter = null): array
protected function fetchComposerRepos(string $url, ?string $username = null, ?string $password = null, ?int $limit = null, ?string $packageList = null, ?string $filter = null): array
{
if (preg_match('{^(\.|[a-z]:|/)}i', $url)) {
throw new \RuntimeException("local filesystem URLs is not allowed");
Expand Down
4 changes: 2 additions & 2 deletions src/Integrations/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

interface AppInterface extends IntegrationInterface
{
public function redirectOAuth2App(Request $request = null, array $options = []): Response;
public function redirectOAuth2App(?Request $request = null, array $options = []): Response;

public function getAccessToken(Request $request, array $options = []): array;

Expand Down Expand Up @@ -46,7 +46,7 @@ public function addOrgHook(App $accessToken, int|string $orgId): ?array;

public function removeOrgHook(App $accessToken, int|string $orgId): ?array;

public function receiveHooks(App $accessToken, Request $request = null, ?array $payload = null): ?array;
public function receiveHooks(App $accessToken, ?Request $request = null, ?array $payload = null): ?array;

public function findApps(): array;

Expand Down
6 changes: 3 additions & 3 deletions src/Integrations/Base/AppIntegrationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function organizations(OAuthIntegration $accessToken): array
return [];
}

public function receiveHooks(OAuthIntegration $app, Request $request = null, ?array $payload = null): ?array
public function receiveHooks(OAuthIntegration $app, ?Request $request = null, ?array $payload = null): ?array
{
return null;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public function removeOrgHook(OAuthIntegration $accessToken, int|string $orgId):
return null;
}

public function authenticateIO(OAuthIntegration $accessToken, IOInterface $io, Config $config, string $repoUrl = null): void
public function authenticateIO(OAuthIntegration $accessToken, IOInterface $io, Config $config, ?string $repoUrl = null): void
{
}

Expand All @@ -134,7 +134,7 @@ protected function genCacheKey(string|int|OAuthIntegration $appId): string
return "oauthapp:{$this->name}:$appId";
}

protected function getCached(string|int|OAuthIntegration $appId, string $key, bool $withCache = true, callable $callback = null): mixed
protected function getCached(string|int|OAuthIntegration $appId, string $key, bool $withCache = true, ?callable $callback = null): mixed
{
if (true === $withCache) {
try {
Expand Down
Loading

0 comments on commit bd68552

Please sign in to comment.