@@ -29,8 +29,10 @@ Table of Contents
2929 * [ PromiseInterface] ( #promiseinterface )
3030 * [ PromiseInterface::then()] ( #promiseinterfacethen )
3131 * [ PromiseInterface::done()] ( #promiseinterfacedone )
32- * [ PromiseInterface::otherwise()] ( #promiseinterfaceotherwise )
33- * [ PromiseInterface::always()] ( #promiseinterfacealways )
32+ * [ ~~ PromiseInterface::otherwise()~~ ] ( #promiseinterfaceotherwise )
33+ * [ PromiseInterface::catch()] ( #promiseinterfacecatch )
34+ * [ ~~ PromiseInterface::always()~~ ] ( #promiseinterfacealways )
35+ * [ PromiseInterface::finally()] ( #promiseinterfacefinally )
3436 * [ PromiseInterface::cancel()] ( #promiseinterfacecancel )
3537 * [ Promise] ( #promise-2 )
3638 * [ Functions] ( #functions )
@@ -206,10 +208,14 @@ Since the purpose of `done()` is consumption rather than transformation,
206208* [ PromiseInterface::then()] ( #promiseinterfacethen )
207209* [ done() vs. then()] ( #done-vs-then )
208210
209- #### PromiseInterface::otherwise()
211+ #### ~~ PromiseInterface::otherwise()~~
212+
213+ The ` otherwise ` method has been deprecated in favour of [ ` catch ` ] ( #promiseinterfacecatch )
214+
215+ #### PromiseInterface::catch()
210216
211217``` php
212- $promise->otherwise (callable $onRejected);
218+ $promise->catch (callable $onRejected);
213219```
214220
215221Registers a rejection handler for promise. It is a shortcut for:
@@ -223,19 +229,23 @@ only specific errors.
223229
224230``` php
225231$promise
226- ->otherwise (function (\RuntimeException $reason) {
232+ ->catch (function (\RuntimeException $reason) {
227233 // Only catch \RuntimeException instances
228234 // All other types of errors will propagate automatically
229235 })
230- ->otherwise (function (\Throwable $reason) {
236+ ->catch (function (\Throwable $reason) {
231237 // Catch other errors
232238 });
233239```
234240
235- #### PromiseInterface::always()
241+ #### ~~ PromiseInterface::always()~~
242+
243+ The ` otherwise ` method has been deprecated in favour of [ ` finally ` ] ( #promiseinterfacefinally )
244+
245+ #### PromiseInterface::finally()
236246
237247``` php
238- $newPromise = $promise->always (callable $onFulfilledOrRejected);
248+ $newPromise = $promise->finally (callable $onFulfilledOrRejected);
239249```
240250
241251Allows you to execute "cleanup" type tasks in a promise chain.
@@ -254,8 +264,8 @@ when the promise is either fulfilled or rejected.
254264 rejected promise, ` $newPromise ` will reject with the thrown exception or
255265 rejected promise's reason.
256266
257- ` always ()` behaves similarly to the synchronous finally statement. When combined
258- with ` otherwise ()` , ` always ()` allows you to write code that is similar to the familiar
267+ ` finally ()` behaves similarly to the synchronous finally statement. When combined
268+ with ` catch ()` , ` finally ()` allows you to write code that is similar to the familiar
259269synchronous catch/finally pair.
260270
261271Consider the following synchronous code:
@@ -275,8 +285,8 @@ written:
275285
276286``` php
277287return doSomething()
278- ->otherwise ('handleError')
279- ->always ('cleanup');
288+ ->catch ('handleError')
289+ ->finally ('cleanup');
280290```
281291
282292#### PromiseInterface::cancel()
0 commit comments