Skip to content

Commit 6d0d0c4

Browse files
committed
Deprecate AbstractApi::delete()
1 parent 157f222 commit 6d0d0c4

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- `Redmine\Api\AbstractApi::get()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3030
- `Redmine\Api\AbstractApi::post()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3131
- `Redmine\Api\AbstractApi::put()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
32+
- `Redmine\Api\AbstractApi::delete()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3233
- The constant `Redmine\Api\Issue::PRIO_LOW` is deprecated.
3334
- The constant `Redmine\Api\Issue::PRIO_NORMAL` is deprecated.
3435
- The constant `Redmine\Api\Issue::PRIO_HIGH` is deprecated.

src/Redmine/Api/AbstractApi.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,17 @@ protected function put($path, $data)
208208
/**
209209
* Perform the client delete() method.
210210
*
211+
* @deprecated v2.6.0 Use `\Redmine\Http\HttpClient::request()` instead
212+
* @see \Redmine\Http\HttpClient::request()
213+
*
211214
* @param string $path
212215
*
213216
* @return string
214217
*/
215218
protected function delete($path)
216219
{
220+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.6.0, use `\Redmine\Http\HttpClient::request()` instead.', E_USER_DEPRECATED);
221+
217222
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeRequest(
218223
'DELETE',
219224
strval($path),

tests/Unit/Api/AbstractApiTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,34 @@ function ($errno, $errstr): bool {
144144
$api->runPut('/path.json', 'data');
145145
}
146146

147+
public function testDeleteTriggersDeprecationWarning()
148+
{
149+
$client = $this->createMock(HttpClient::class);
150+
151+
$api = new class ($client) extends AbstractApi {
152+
public function runDelete($path)
153+
{
154+
return $this->delete($path);
155+
}
156+
};
157+
158+
// PHPUnit 10 compatible way to test trigger_error().
159+
set_error_handler(
160+
function ($errno, $errstr): bool {
161+
$this->assertSame(
162+
'`Redmine\Api\AbstractApi::delete()` is deprecated since v2.6.0, use `\Redmine\Http\HttpClient::request()` instead.',
163+
$errstr
164+
);
165+
166+
restore_error_handler();
167+
return true;
168+
},
169+
E_USER_DEPRECATED
170+
);
171+
172+
$api->runDelete('/path.json');
173+
}
174+
147175
/**
148176
* @dataProvider getIsNotNullReturnsCorrectBooleanData
149177
*/

0 commit comments

Comments
 (0)