Skip to content

Commit

Permalink
PHP 8.1: fix deprecation warnings / http_build_query()
Browse files Browse the repository at this point in the history
This fixes all relevant calls to the PHP native `http_build_query()` function.
The second parameter of which is the _optional_ `$numeric_prefix` parameter which expects a `string`.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing `null` to a non-nullable PHP native function will generate a deprecation notice.
In this case, these function calls yielded a `http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated` notice.

Changing the `null` to an empty string fixes this without BC-break.

Fixes a few deprecation warnings found when running the tests.

Refs:
* https://www.php.net/manual/en/function.http-build-query.php
* https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
  • Loading branch information
jrfnl committed Aug 5, 2021
1 parent 9eefb21 commit d45cc34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Composer/Repository/Vcs/BitbucketDriver.php
Expand Up @@ -86,7 +86,7 @@ protected function getRepoData()
$this->repository,
http_build_query(
array('fields' => '-project,-owner'),
null,
'',
'&'
)
);
Expand Down Expand Up @@ -286,7 +286,7 @@ public function getTags()
'fields' => 'values.name,values.target.hash,next',
'sort' => '-target.date',
),
null,
'',
'&'
)
);
Expand Down Expand Up @@ -330,7 +330,7 @@ public function getBranches()
'fields' => 'values.name,values.target.hash,values.heads,next',
'sort' => '-target.date',
),
null,
'',
'&'
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Util/GitLab.php
Expand Up @@ -172,7 +172,7 @@ private function createToken($scheme, $originUrl)
'username' => $username,
'password' => $password,
'grant_type' => 'password',
), null, '&');
), '', '&');
$options = array(
'retry-auth-failure' => false,
'http' => array(
Expand Down

0 comments on commit d45cc34

Please sign in to comment.