diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9c36647..b13df1d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -21,6 +21,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" steps: - uses: actions/checkout@v3 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 46b0f47..b1a7563 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,10 @@ parameters: level: 5 + reportUnmatchedIgnoredErrors: false + paths: - src - tests + + ignoreErrors: + - '#Attribute class Deprecated does not exist#' diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index d3ff630..a923eef 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -19,10 +19,10 @@ abstract class AbstractApi /** @var ResponseMediator */ private $responseMediator; - public function __construct(Client $client, ResponseMediator $responseMediator = null) + public function __construct(Client $client, ?ResponseMediator $responseMediator = null) { $this->client = $client; - $this->responseMediator = $responseMediator ? $responseMediator : new ResponseMediator(); + $this->responseMediator = $responseMediator ?: new ResponseMediator(); } /** diff --git a/src/Api/Credentials.php b/src/Api/Credentials.php index d7f5a73..5d7c103 100644 --- a/src/Api/Credentials.php +++ b/src/Api/Credentials.php @@ -43,6 +43,7 @@ public function create($description, $type, $domain, $username, $credential) /** * @deprecated Use edit instead */ + #[\Deprecated('Use Credentials::edit instead', '1.11.0')] public function update($credentialId, $type, $username, $credential) { return $this->edit($credentialId, $type, $username, $credential); diff --git a/src/Api/Customers.php b/src/Api/Customers.php index 27fbdbd..237d079 100644 --- a/src/Api/Customers.php +++ b/src/Api/Customers.php @@ -42,6 +42,7 @@ public function create($name, $accessToVersionControlSource = false, $urlName = /** * @deprecated Use edit instead */ + #[\Deprecated('Use Customers::edit instead', '1.11.0')] public function update($customerIdOrUrlName, array $customer) { return $this->edit($customerIdOrUrlName, $customer); @@ -80,6 +81,7 @@ public function showPackage($customerIdOrUrlName, $packageIdOrName) /** * @deprecated Use addOrEditPackages instead */ + #[\Deprecated('Use Customers::addOrEditPackages instead', '1.11.0')] public function addOrUpdatePackages($customerIdOrUrlName, array $packages) { return $this->addOrEditPackages($customerIdOrUrlName, $packages); @@ -99,6 +101,7 @@ public function addOrEditPackages($customerIdOrUrlName, array $packages) /** * @deprecated Use addOrEditPackages instead */ + #[\Deprecated('Use Customers::addOrEditPackages instead', '1.11.0')] public function addPackages($customerIdOrUrlName, array $packages) { return $this->addOrEditPackages($customerIdOrUrlName, $packages); diff --git a/src/Api/Packages.php b/src/Api/Packages.php index 0660c95..6a1f1a0 100644 --- a/src/Api/Packages.php +++ b/src/Api/Packages.php @@ -35,11 +35,13 @@ class Packages extends AbstractApi /** * @deprecated Use Packages::ORIGIN_PUBLIC_MIRROR instead */ + #[\Deprecated('Use Packages::ORIGIN_PUBLIC_MIRROR instead', '1.13.0')] const ORIGIN_PUBLIC_PROXY = self::ORIGIN_PUBLIC_MIRROR; /** * @deprecated Use Packages::ORIGIN_PRIVATE_MIRROR instead */ + #[\Deprecated('Use Packages::ORIGIN_PRIVATE_MIRROR instead', '1.13.0')] const ORIGIN_PRIVATE_PROXY = self::ORIGIN_PRIVATE_MIRROR; 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 /** * @deprecated Use editVcsPackage instead */ + #[\Deprecated('Use Packages::editVcsPackage instead', '1.11.0')] public function updateVcsPackage($packageName, $url, $credentialId = null) { return $this->editVcsPackage($packageName, $url, $credentialId); @@ -104,6 +107,7 @@ public function editArtifactPackage($packageIdOrName, array $artifactPackageFile /** * @deprecated Use editCustomPackage instead */ + #[\Deprecated('Use Packages::editCustomPackage instead', '1.11.0')] public function updateCustomPackage($packageName, $customJson, $credentialId = null) { return $this->editCustomPackage($packageName, $customJson, $credentialId); diff --git a/src/Api/Subrepositories.php b/src/Api/Subrepositories.php index 9185bad..075825b 100644 --- a/src/Api/Subrepositories.php +++ b/src/Api/Subrepositories.php @@ -41,6 +41,7 @@ public function listTeams($subrepositoryName) /** * @deprecated Use addOrEditTeams instead */ + #[\Deprecated('Use Subrepositories::addOrEditTeams instead', '1.10.0')] public function addOrUpdateTeams($subrepositoryName, array $teams) { return $this->addOrEditTeams($subrepositoryName, $teams); @@ -69,6 +70,7 @@ public function removeTeam($subrepositoryName, $teamId) /** * @deprecated use packages()->all() */ + #[\Deprecated('Use Subrepositories::packages()->all() instead', '1.16.1')] public function listPackages($subrepositoryName) { return $this->packages()->all($subrepositoryName); diff --git a/src/Client.php b/src/Client.php index bd25209..381423a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -25,7 +25,7 @@ class Client private $responseMediator; /** @param string $privatePackagistUrl */ - public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $privatePackagistUrl = null, ResponseMediator $responseMediator = null) + public function __construct(?HttpPluginClientBuilder $httpClientBuilder = null, $privatePackagistUrl = null, ?ResponseMediator $responseMediator = null) { $this->httpClientBuilder = $builder = $httpClientBuilder ?: new HttpPluginClientBuilder(); $privatePackagistUrl = $privatePackagistUrl ? : 'https://packagist.com'; @@ -48,8 +48,12 @@ public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $ * @param string $key * @param string $secret */ - public function authenticate($key, $secret) - { + public function authenticate( + #[\SensitiveParameter] + $key, + #[\SensitiveParameter] + $secret + ) { $this->httpClientBuilder->removePlugin(RequestSignature::class); $this->httpClientBuilder->addPlugin(new RequestSignature($key, $secret)); } @@ -72,6 +76,7 @@ public function customers() /** * @deprecated Use Client::subrepositories instead */ + #[\Deprecated('Use Client::subrepositories instead', '1.16.1')] public function projects() { return new Api\Subrepositories($this, $this->responseMediator); diff --git a/src/Exception/HttpTransportException.php b/src/Exception/HttpTransportException.php index 52c3546..2f5e423 100644 --- a/src/Exception/HttpTransportException.php +++ b/src/Exception/HttpTransportException.php @@ -15,7 +15,7 @@ class HttpTransportException extends RuntimeException { private $requestUri; - public function __construct($message = "", $code = 0, $requestUri = "", Throwable $previous = null) + public function __construct($message = "", $code = 0, $requestUri = "", ?Throwable $previous = null) { $this->requestUri = $requestUri; parent::__construct($message, $code, $previous); diff --git a/src/HttpClient/Plugin/ExceptionThrower.php b/src/HttpClient/Plugin/ExceptionThrower.php index 1dd1ae9..96180b6 100644 --- a/src/HttpClient/Plugin/ExceptionThrower.php +++ b/src/HttpClient/Plugin/ExceptionThrower.php @@ -24,9 +24,9 @@ class ExceptionThrower implements Plugin /** @var ResponseMediator */ private $responseMediator; - public function __construct(ResponseMediator $responseMediator = null) + public function __construct(?ResponseMediator $responseMediator = null) { - $this->responseMediator = $responseMediator ? $responseMediator : new ResponseMediator(); + $this->responseMediator = $responseMediator ? : new ResponseMediator(); } protected function doHandleRequest(RequestInterface $request, callable $next, callable $first) diff --git a/src/HttpClient/Plugin/RequestSignature.php b/src/HttpClient/Plugin/RequestSignature.php index 3988c30..c313778 100644 --- a/src/HttpClient/Plugin/RequestSignature.php +++ b/src/HttpClient/Plugin/RequestSignature.php @@ -25,8 +25,12 @@ class RequestSignature implements Plugin * @param string $key * @param string $secret */ - public function __construct($key, $secret) - { + public function __construct( + #[\SensitiveParameter] + $key, + #[\SensitiveParameter] + $secret + ) { if (!$key || !$secret) { throw new \InvalidArgumentException('$key and $secret must be set'); } diff --git a/src/WebhookSignature.php b/src/WebhookSignature.php index b1782b6..5434183 100644 --- a/src/WebhookSignature.php +++ b/src/WebhookSignature.php @@ -14,8 +14,10 @@ class WebhookSignature /** @var string */ private $secret; - public function __construct($secret) - { + public function __construct( + #[\SensitiveParameter] + $secret + ) { $this->secret = $secret; }