BlueGit

projects-timfalken-com microchess

Files

microchess / web / lib / push / vendor / guzzlehttp / promises / UPGRADING.md

UPGRADING.md

UPGRADING.md 2.8 KiB Download Raw

Guzzle Promises Upgrade Guide =============================

1.x to 2.0 ----------

Guzzle Promises 2.0 is a major release that removes deprecated APIs, raises the minimum PHP version, and adds PHP 7 parameter and return types. Applications that only use the object-oriented API should usually need small changes. Applications that call helper functions, implement package interfaces, extend package classes, or pass invalid argument types need closer review.

PHP Version and Dependencies

Guzzle Promises 2.0 requires PHP ^7.2.5 || ^8.0. Guzzle Promises 1.x supported PHP >=5.5.

PHP 7 Type Hints and Return Types

Type hints and return types were added wherever possible. Please make sure:

  • You pass values of the documented type when calling methods and functions.
  • Classes that implement PromiseInterface, PromisorInterface, or

TaskQueueInterface update method signatures to remain compatible.

  • Classes that extend Guzzle Promises classes update any overridden method

signatures to remain compatible.

  • Code that expected package-specific exceptions for invalid argument types may

now receive PHP TypeError exceptions instead.

Soft-Final Classes

All previously non-final non-exception classes are now final or annotated with @final. If your code extends one of these classes, replace inheritance with composition or implement the relevant interface directly.

Removed Function API

The static API was introduced in 1.4.0 to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0, along with the Composer files autoload entry that loaded src/functions_include.php.

Replace namespaced function calls with the corresponding static methods in the GuzzleHttp\Promise namespace:

// Before:
use function GuzzleHttp\Promise\promise_for;

$promise = promise_for('value');

// After:
use GuzzleHttp\Promise\Create;

$promise = Create::promiseFor('value');
Original FunctionReplacement Method
queueUtils::queue
taskUtils::task
promise_forCreate::promiseFor
rejection_forCreate::rejectionFor
exception_forCreate::exceptionFor
iter_forCreate::iterFor
inspectUtils::inspect
inspect_allUtils::inspectAll
unwrapUtils::unwrap
allUtils::all
someUtils::some
anyUtils::any
settleUtils::settle
eachEach::of
each_limitEach::ofLimit
each_limit_allEach::ofLimitAll
!is_fulfilledIs::pending
is_fulfilledIs::fulfilled
is_rejectedIs::rejected
is_settledIs::settled
coroutineCoroutine::of

For the full 2.0 diff, see https://github.com/guzzle/promises/compare/1.5.3...2.0.0.

Source
1Guzzle Promises Upgrade Guide
2=============================
3
41.x to 2.0
5----------
6
7Guzzle Promises 2.0 is a major release that removes deprecated APIs, raises the
8minimum PHP version, and adds PHP 7 parameter and return types. Applications that
9only use the object-oriented API should usually need small changes. Applications
10that call helper functions, implement package interfaces, extend package classes,
11or pass invalid argument types need closer review.
12
13#### PHP Version and Dependencies
14
15Guzzle Promises 2.0 requires PHP `^7.2.5 || ^8.0`. Guzzle Promises 1.x
16supported PHP `>=5.5`.
17
18#### PHP 7 Type Hints and Return Types
19
20Type 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
32All 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
34composition or implement the relevant interface directly.
35
36#### Removed Function API
37
38The static API was introduced in 1.4.0 to mitigate problems with functions
39conflicting between global and local copies of the package. The function API was
40removed in 2.0.0, along with the Composer `files` autoload entry that loaded
41`src/functions_include.php`.
42
43Replace namespaced function calls with the corresponding static methods in the
44`GuzzleHttp\Promise` namespace:
45
46```php
47// Before:
48use function GuzzleHttp\Promise\promise_for;
49
50$promise = promise_for('value');
51
52// After:
53use 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
82For the full 2.0 diff, see
83https://github.com/guzzle/promises/compare/1.5.3...2.0.0.