Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit nullable types to avoid PHP 8.4 warnings #819

Open
wants to merge 3 commits into
base: 11.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public function pipelineTestReportSummary($project_id, int $pipeline_id)
*
* @return mixed
*/
public function createPipeline($project_id, string $commit_ref, array $variables = null)
public function createPipeline($project_id, string $commit_ref, ?array $variables = null)
{
$parameters = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Api/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public function postCommitBuildStatus($project_id, string $sha, string $state, a
*
* @return mixed
*/
public function compare($project_id, string $fromShaOrMaster, string $toShaOrMaster, bool $straight = false, string $fromProjectId = null)
public function compare($project_id, string $fromShaOrMaster, string $toShaOrMaster, bool $straight = false, ?string $fromProjectId = null)
{
$params = [
'from' => $fromShaOrMaster,
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Client
*
* @return void
*/
public function __construct(Builder $httpClientBuilder = null)
public function __construct(?Builder $httpClientBuilder = null)
{
$this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder();
$this->responseHistory = new History();
Expand Down Expand Up @@ -425,7 +425,7 @@ public function wiki(): Wiki
*
* @return void
*/
public function authenticate(string $token, string $authMethod, string $sudo = null): void
public function authenticate(string $token, string $authMethod, ?string $sudo = null): void
{
$this->getHttpClientBuilder()->removePlugin(Authentication::class);
$this->getHttpClientBuilder()->addPlugin(new Authentication($authMethod, $token, $sudo));
Expand Down
8 changes: 4 additions & 4 deletions src/HttpClient/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ final class Builder
* @return void
*/
public function __construct(
ClientInterface $httpClient = null,
RequestFactoryInterface $requestFactory = null,
StreamFactoryInterface $streamFactory = null,
UriFactoryInterface $uriFactory = null
?ClientInterface $httpClient = null,
?RequestFactoryInterface $requestFactory = null,
?StreamFactoryInterface $streamFactory = null,
?UriFactoryInterface $uriFactory = null
) {
$this->httpClient = $httpClient ?? Psr18ClientDiscovery::find();
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient/Plugin/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class Authentication implements Plugin
*
* @return void
*/
public function __construct(string $method, string $token, string $sudo = null)
public function __construct(string $method, string $token, ?string $sudo = null)
{
$this->headers = self::buildHeaders($method, $token, $sudo);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
*
* @return array<string,string>
*/
private static function buildHeaders(string $method, string $token, string $sudo = null): array
private static function buildHeaders(string $method, string $token, ?string $sudo = null): array
{
$headers = [];

Expand Down
2 changes: 1 addition & 1 deletion src/ResultPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class ResultPager implements ResultPagerInterface
*
* @return void
*/
public function __construct(Client $client, int $perPage = null)
public function __construct(Client $client, ?int $perPage = null)
{
if (null !== $perPage && ($perPage < 1 || $perPage > 100)) {
throw new ValueError(\sprintf('%s::__construct(): Argument #2 ($perPage) must be between 1 and 100, or null', self::class));
Expand Down