Skip to content

Commit 2f24c2a

Browse files
authoredDec 9, 2024··
Merge pull request #81 from packagist/php84
PHP 8.4 support and use new attributes
2 parents 7b315a0 + 6478f92 commit 2f24c2a

12 files changed

+39
-12
lines changed
 

‎.github/workflows/php.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- "8.1"
2222
- "8.2"
2323
- "8.3"
24+
- "8.4"
2425

2526
steps:
2627
- uses: actions/checkout@v3

‎phpstan.neon.dist

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
parameters:
22
level: 5
3+
reportUnmatchedIgnoredErrors: false
4+
35
paths:
46
- src
57
- tests
8+
9+
ignoreErrors:
10+
- '#Attribute class Deprecated does not exist#'

‎src/Api/AbstractApi.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ abstract class AbstractApi
1919
/** @var ResponseMediator */
2020
private $responseMediator;
2121

22-
public function __construct(Client $client, ResponseMediator $responseMediator = null)
22+
public function __construct(Client $client, ?ResponseMediator $responseMediator = null)
2323
{
2424
$this->client = $client;
25-
$this->responseMediator = $responseMediator ? $responseMediator : new ResponseMediator();
25+
$this->responseMediator = $responseMediator ?: new ResponseMediator();
2626
}
2727

2828
/**

‎src/Api/Credentials.php

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function create($description, $type, $domain, $username, $credential)
4343
/**
4444
* @deprecated Use edit instead
4545
*/
46+
#[\Deprecated('Use Credentials::edit instead', '1.11.0')]
4647
public function update($credentialId, $type, $username, $credential)
4748
{
4849
return $this->edit($credentialId, $type, $username, $credential);

‎src/Api/Customers.php

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function create($name, $accessToVersionControlSource = false, $urlName =
4242
/**
4343
* @deprecated Use edit instead
4444
*/
45+
#[\Deprecated('Use Customers::edit instead', '1.11.0')]
4546
public function update($customerIdOrUrlName, array $customer)
4647
{
4748
return $this->edit($customerIdOrUrlName, $customer);
@@ -80,6 +81,7 @@ public function showPackage($customerIdOrUrlName, $packageIdOrName)
8081
/**
8182
* @deprecated Use addOrEditPackages instead
8283
*/
84+
#[\Deprecated('Use Customers::addOrEditPackages instead', '1.11.0')]
8385
public function addOrUpdatePackages($customerIdOrUrlName, array $packages)
8486
{
8587
return $this->addOrEditPackages($customerIdOrUrlName, $packages);
@@ -99,6 +101,7 @@ public function addOrEditPackages($customerIdOrUrlName, array $packages)
99101
/**
100102
* @deprecated Use addOrEditPackages instead
101103
*/
104+
#[\Deprecated('Use Customers::addOrEditPackages instead', '1.11.0')]
102105
public function addPackages($customerIdOrUrlName, array $packages)
103106
{
104107
return $this->addOrEditPackages($customerIdOrUrlName, $packages);

‎src/Api/Packages.php

+4
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ class Packages extends AbstractApi
3535
/**
3636
* @deprecated Use Packages::ORIGIN_PUBLIC_MIRROR instead
3737
*/
38+
#[\Deprecated('Use Packages::ORIGIN_PUBLIC_MIRROR instead', '1.13.0')]
3839
const ORIGIN_PUBLIC_PROXY = self::ORIGIN_PUBLIC_MIRROR;
3940

4041
/**
4142
* @deprecated Use Packages::ORIGIN_PRIVATE_MIRROR instead
4243
*/
44+
#[\Deprecated('Use Packages::ORIGIN_PRIVATE_MIRROR instead', '1.13.0')]
4345
const ORIGIN_PRIVATE_PROXY = self::ORIGIN_PRIVATE_MIRROR;
4446

4547
const AVAILABLE_ORIGINS = [self::ORIGIN_PUBLIC_MIRROR, self::ORIGIN_PRIVATE_MIRROR, self::ORIGIN_PRIVATE, 'public-proxy', 'private-proxy'];
@@ -82,6 +84,7 @@ public function createArtifactPackage(array $artifactPackageFileIds, $defaultSub
8284
/**
8385
* @deprecated Use editVcsPackage instead
8486
*/
87+
#[\Deprecated('Use Packages::editVcsPackage instead', '1.11.0')]
8588
public function updateVcsPackage($packageName, $url, $credentialId = null)
8689
{
8790
return $this->editVcsPackage($packageName, $url, $credentialId);
@@ -104,6 +107,7 @@ public function editArtifactPackage($packageIdOrName, array $artifactPackageFile
104107
/**
105108
* @deprecated Use editCustomPackage instead
106109
*/
110+
#[\Deprecated('Use Packages::editCustomPackage instead', '1.11.0')]
107111
public function updateCustomPackage($packageName, $customJson, $credentialId = null)
108112
{
109113
return $this->editCustomPackage($packageName, $customJson, $credentialId);

‎src/Api/Subrepositories.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function listTeams($subrepositoryName)
4141
/**
4242
* @deprecated Use addOrEditTeams instead
4343
*/
44+
#[\Deprecated('Use Subrepositories::addOrEditTeams instead', '1.10.0')]
4445
public function addOrUpdateTeams($subrepositoryName, array $teams)
4546
{
4647
return $this->addOrEditTeams($subrepositoryName, $teams);
@@ -69,6 +70,7 @@ public function removeTeam($subrepositoryName, $teamId)
6970
/**
7071
* @deprecated use packages()->all()
7172
*/
73+
#[\Deprecated('Use Subrepositories::packages()->all() instead', '1.16.1')]
7274
public function listPackages($subrepositoryName)
7375
{
7476
return $this->packages()->all($subrepositoryName);

‎src/Client.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Client
2525
private $responseMediator;
2626

2727
/** @param string $privatePackagistUrl */
28-
public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $privatePackagistUrl = null, ResponseMediator $responseMediator = null)
28+
public function __construct(?HttpPluginClientBuilder $httpClientBuilder = null, $privatePackagistUrl = null, ?ResponseMediator $responseMediator = null)
2929
{
3030
$this->httpClientBuilder = $builder = $httpClientBuilder ?: new HttpPluginClientBuilder();
3131
$privatePackagistUrl = $privatePackagistUrl ? : 'https://packagist.com';
@@ -48,8 +48,12 @@ public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $
4848
* @param string $key
4949
* @param string $secret
5050
*/
51-
public function authenticate($key, $secret)
52-
{
51+
public function authenticate(
52+
#[\SensitiveParameter]
53+
$key,
54+
#[\SensitiveParameter]
55+
$secret
56+
) {
5357
$this->httpClientBuilder->removePlugin(RequestSignature::class);
5458
$this->httpClientBuilder->addPlugin(new RequestSignature($key, $secret));
5559
}
@@ -72,6 +76,7 @@ public function customers()
7276
/**
7377
* @deprecated Use Client::subrepositories instead
7478
*/
79+
#[\Deprecated('Use Client::subrepositories instead', '1.16.1')]
7580
public function projects()
7681
{
7782
return new Api\Subrepositories($this, $this->responseMediator);

‎src/Exception/HttpTransportException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class HttpTransportException extends RuntimeException
1515
{
1616
private $requestUri;
1717

18-
public function __construct($message = "", $code = 0, $requestUri = "", Throwable $previous = null)
18+
public function __construct($message = "", $code = 0, $requestUri = "", ?Throwable $previous = null)
1919
{
2020
$this->requestUri = $requestUri;
2121
parent::__construct($message, $code, $previous);

‎src/HttpClient/Plugin/ExceptionThrower.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class ExceptionThrower implements Plugin
2424
/** @var ResponseMediator */
2525
private $responseMediator;
2626

27-
public function __construct(ResponseMediator $responseMediator = null)
27+
public function __construct(?ResponseMediator $responseMediator = null)
2828
{
29-
$this->responseMediator = $responseMediator ? $responseMediator : new ResponseMediator();
29+
$this->responseMediator = $responseMediator ? : new ResponseMediator();
3030
}
3131

3232
protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)

‎src/HttpClient/Plugin/RequestSignature.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ class RequestSignature implements Plugin
2525
* @param string $key
2626
* @param string $secret
2727
*/
28-
public function __construct($key, $secret)
29-
{
28+
public function __construct(
29+
#[\SensitiveParameter]
30+
$key,
31+
#[\SensitiveParameter]
32+
$secret
33+
) {
3034
if (!$key || !$secret) {
3135
throw new \InvalidArgumentException('$key and $secret must be set');
3236
}

‎src/WebhookSignature.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class WebhookSignature
1414
/** @var string */
1515
private $secret;
1616

17-
public function __construct($secret)
18-
{
17+
public function __construct(
18+
#[\SensitiveParameter]
19+
$secret
20+
) {
1921
$this->secret = $secret;
2022
}
2123

0 commit comments

Comments
 (0)
Please sign in to comment.