From c5a2e3762ca7c9b24cb302973fdaa7704835cda9 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Sun, 26 Sep 2021 11:56:32 +0200 Subject: [PATCH] Deprecate lastCallFailed. (#294) --- CHANGELOG.md | 4 ++++ docs/usage.md | 2 ++ src/Redmine/Api/AbstractApi.php | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0229afbb..b15af86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/kbsali/php-redmine-api/compare/v2.0.1...v2.x) +### Deprecated + +- `Redmine\Api\AbstractApi::lastCallFailed()` is deprecated, use `Redmine\Client\Client::getLastResponseStatusCode()` instead + ## [v2.0.1](https://github.com/kbsali/php-redmine-api/compare/v2.0.0...v2.0.1) - 2021-09-22 ### Fixed diff --git a/docs/usage.md b/docs/usage.md index f585a052..149ff130 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -199,6 +199,8 @@ $client->stopImpersonateUser(); You can now use the `getApi()` method to create and get a specific Redmine API. +To check for failed requests you can afterwards check the status code via `$client->getLastResponseStatusCode()`. + ```php // ---------------------------- // Trackers diff --git a/src/Redmine/Api/AbstractApi.php b/src/Redmine/Api/AbstractApi.php index 93033245..8e85176e 100644 --- a/src/Redmine/Api/AbstractApi.php +++ b/src/Redmine/Api/AbstractApi.php @@ -28,9 +28,14 @@ public function __construct(Client $client) * Returns whether or not the last api call failed. * * @return bool + * + * @deprecated This method does not correctly handle 2xx codes that are not 200 or 201, use \Redmine\Client\Client::getLastResponseStatusCode() instead + * @see Client::getLastResponseStatusCode() for checking the status code directly */ public function lastCallFailed() { + @trigger_error('The '.__METHOD__.' method is deprecated, use \Redmine\Client\Client::getLastResponseStatusCode() instead.', E_USER_DEPRECATED); + $code = $this->client->getLastResponseStatusCode(); return 200 !== $code && 201 !== $code;