Debian Codegraph @

lib/3rdParty/composer/guzzlehttp/promises/UPGRADING.md

raw symbols SCIP
1 Guzzle Promises Upgrade Guide
2 =============================
3
4 1.x to 2.0
5 ----------
6
7 Guzzle Promises 2.0 is a major release that removes deprecated APIs, raises the
8 minimum PHP version, and adds PHP 7 parameter and return types. Applications that
9 only use the object-oriented API should usually need small changes. Applications
10 that call helper functions, implement package interfaces, extend package classes,
11 or pass invalid argument types need closer review.
12
13 #### PHP Version and Dependencies
14
15 Guzzle Promises 2.0 requires PHP `^7.2.5 || ^8.0`. Guzzle Promises 1.x
16 supported PHP `>=5.5`.
17
18 #### PHP 7 Type Hints and Return Types
19
20 Type hints and return types were added wherever possible. Please make sure:
21
22 - You pass values of the documented type when calling methods and functions.
23 - Classes that implement `PromiseInterface`, `PromisorInterface`, or
24 `TaskQueueInterface` update method signatures to remain compatible.
25 - Classes that extend Guzzle Promises classes update any overridden method
26 signatures to remain compatible.
27 - Code that expected package-specific exceptions for invalid argument types may
28 now receive PHP `TypeError` exceptions instead.
29
30 #### Soft-Final Classes
31
32 All previously non-final non-exception classes are now final or annotated with
33 `@final`. If your code extends one of these classes, replace inheritance with
34 composition or implement the relevant interface directly.
35
36 #### Removed Function API
37
38 The static API was introduced in 1.4.0 to mitigate problems with functions
39 conflicting between global and local copies of the package. The function API was
40 removed in 2.0.0, along with the Composer `files` autoload entry that loaded
41 `src/functions_include.php`.
42
43 Replace namespaced function calls with the corresponding static methods in the
44 `GuzzleHttp\Promise` namespace:
45
46 ```php
47 // Before:
48 use function GuzzleHttp\Promise\promise_for;
49
50 $promise = promise_for('value');
51
52 // After:
53 use GuzzleHttp\Promise\Create;
54
55 $promise = Create::promiseFor('value');
56 ```
57
58 | Original Function | Replacement Method |
59 |-------------------|--------------------|
60 | `queue` | `Utils::queue` |
61 | `task` | `Utils::task` |
62 | `promise_for` | `Create::promiseFor` |
63 | `rejection_for` | `Create::rejectionFor` |
64 | `exception_for` | `Create::exceptionFor` |
65 | `iter_for` | `Create::iterFor` |
66 | `inspect` | `Utils::inspect` |
67 | `inspect_all` | `Utils::inspectAll` |
68 | `unwrap` | `Utils::unwrap` |
69 | `all` | `Utils::all` |
70 | `some` | `Utils::some` |
71 | `any` | `Utils::any` |
72 | `settle` | `Utils::settle` |
73 | `each` | `Each::of` |
74 | `each_limit` | `Each::ofLimit` |
75 | `each_limit_all` | `Each::ofLimitAll` |
76 | `!is_fulfilled` | `Is::pending` |
77 | `is_fulfilled` | `Is::fulfilled` |
78 | `is_rejected` | `Is::rejected` |
79 | `is_settled` | `Is::settled` |
80 | `coroutine` | `Coroutine::of` |
81
82 For the full 2.0 diff, see
83 https://github.com/guzzle/promises/compare/1.5.3...2.0.0.