1CHANGELOG for 2.x 2================= 3 4* 2.9.0 (2022-02-11) 5 6 * Feature: Support union types and address deprecation of `ReflectionType::getClass()` (PHP 8+). 7 (#198 by @cdosoftei and @SimonFrings) 8 9 ```php 10 $promise->otherwise(function (OverflowException|UnderflowException $e) { 11 echo 'Error: ' . $e->getMessage() . PHP_EOL; 12 }); 13 ``` 14 15 * Feature: Support intersection types (PHP 8.1+). 16 (#195 by @bzikarsky) 17 18 ```php 19 $promise->otherwise(function (OverflowException&CacheException $e) { 20 echo 'Error: ' . $e->getMessage() . PHP_EOL; 21 }); 22 ``` 23 24 * Improve test suite, use GitHub actions for continuous integration (CI), 25 update to PHPUnit 9, and add full core team to the license. 26 (#174, #183, #186, and #201 by @SimonFrings and #211 by @clue) 27 28* 2.8.0 (2020-05-12) 29 30 * Mark `FulfilledPromise`, `RejectedPromise` and `LazyPromise` as deprecated for Promise v2 (and remove for Promise v3). 31 (#143 and #165 by @clue) 32 33 ```php 34 // deprecated 35 $fulfilled = new React\Promise\FulfilledPromise($value); 36 $rejected = new React\Promise\RejectedPromise($reason); 37 38 // recommended alternatives 39 $fulfilled = React\Promise\resolve($value); 40 $rejected = React\Promise\reject($reason); 41 ``` 42 43 * Fix: Fix checking whether cancellable promise is an object and avoid possible warning. 44 (#168 by @smscr and @jsor) 45 46 * Improve documentation and add docblocks to functions and interfaces. 47 (#135 by @CharlotteDunois) 48 49 * Add `.gitattributes` to exclude dev files from exports. 50 (#154 by @reedy) 51 52 * Improve test suite, run tests on PHP 7.4 and update PHPUnit test setup. 53 (#163 by @clue) 54 55* 2.7.1 (2018-01-07) 56 57 * Fix: file_exists warning when resolving with long strings. 58 (#130 by @sbesselsen) 59 * Improve performance by prefixing all global functions calls with \ to skip the look up and resolve process and go straight to the global function. 60 (#133 by @WyriHaximus) 61 62* 2.7.0 (2018-06-13) 63 64 * Feature: Improve memory consumption for pending promises by using static internal callbacks without binding to self. 65 (#124 by @clue) 66 67* 2.6.0 (2018-06-11) 68 69 * Feature: Significantly improve memory consumption and performance by only passing resolver args 70 to resolver and canceller if callback requires them. Also use static callbacks without 71 binding to promise, clean up canceller function reference when they are no longer 72 needed and hide resolver and canceller references from call stack on PHP 7+. 73 (#113, #115, #116, #117, #118, #119 and #123 by @clue) 74 75 These changes combined mean that rejecting promises with an `Exception` should 76 no longer cause any internal circular references which could cause some unexpected 77 memory growth in previous versions. By explicitly avoiding and explicitly 78 cleaning up said references, we can avoid relying on PHP's circular garbage collector 79 to kick in which significantly improves performance when rejecting many promises. 80 81 * Mark legacy progress support / notification API as deprecated 82 (#112 by @clue) 83 84 * Recommend rejecting promises by throwing an exception 85 (#114 by @jsor) 86 87 * Improve documentation to properly instantiate LazyPromise 88 (#121 by @holtkamp) 89 90 * Follower cancellation propagation was originally planned for this release 91 but has been reverted for now and is planned for a future release. 92 (#99 by @jsor and #122 by @clue) 93 94* 2.5.1 (2017-03-25) 95 96 * Fix circular references when resolving with a promise which follows 97 itself (#94). 98 99* 2.5.0 (2016-12-22) 100 101 * Revert automatic cancellation of pending collection promises once the 102 output promise resolves. This was introduced in 42d86b7 (PR #36, released 103 in [v2.3.0](https://github.com/reactphp/promise/releases/tag/v2.3.0)) and 104 was both unintended and backward incompatible. 105 106 If you need automatic cancellation, you can use something like: 107 108 ```php 109 function allAndCancel(array $promises) 110 { 111 return \React\Promise\all($promises) 112 ->always(function() use ($promises) { 113 foreach ($promises as $promise) { 114 if ($promise instanceof \React\Promise\CancellablePromiseInterface) { 115 $promise->cancel(); 116 } 117 } 118 }); 119 } 120 ``` 121 * `all()` and `map()` functions now preserve the order of the array (#77). 122 * Fix circular references when resolving a promise with itself (#71). 123 124* 2.4.1 (2016-05-03) 125 126 * Fix `some()` not cancelling pending promises when too much input promises 127 reject (16ff799). 128 129* 2.4.0 (2016-03-31) 130 131 * Support foreign thenables in `resolve()`. 132 Any object that provides a `then()` method is now assimilated to a trusted 133 promise that follows the state of this thenable (#52). 134 * Fix `some()` and `any()` for input arrays containing not enough items 135 (#34). 136 137* 2.3.0 (2016-03-24) 138 139 * Allow cancellation of promises returned by functions working on promise 140 collections (#36). 141 * Handle `\Throwable` in the same way as `\Exception` (#51 by @joshdifabio). 142 143* 2.2.2 (2016-02-26) 144 145 * Fix cancellation handlers called multiple times (#47 by @clue). 146 147* 2.2.1 (2015-07-03) 148 149 * Fix stack error when resolving a promise in its own fulfillment or 150 rejection handlers. 151 152* 2.2.0 (2014-12-30) 153 154 * Introduce new `ExtendedPromiseInterface` implemented by all promises. 155 * Add new `done()` method (part of the `ExtendedPromiseInterface`). 156 * Add new `otherwise()` method (part of the `ExtendedPromiseInterface`). 157 * Add new `always()` method (part of the `ExtendedPromiseInterface`). 158 * Add new `progress()` method (part of the `ExtendedPromiseInterface`). 159 * Rename `Deferred::progress` to `Deferred::notify` to avoid confusion with 160 `ExtendedPromiseInterface::progress` (a `Deferred::progress` alias is 161 still available for backward compatibility) 162 * `resolve()` now always returns a `ExtendedPromiseInterface`. 163 164* 2.1.0 (2014-10-15) 165 166 * Introduce new `CancellablePromiseInterface` implemented by all promises. 167 * Add new `cancel()` method (part of the `CancellablePromiseInterface`). 168 169* 2.0.0 (2013-12-10) 170 171 New major release. The goal is to streamline the API and to make it more 172 compliant with other promise libraries and especially with the new upcoming 173 [ES6 promises specification](https://github.com/domenic/promises-unwrapping/). 174 175 * Add standalone Promise class. 176 * Add new `race()` function. 177 * BC break: Bump minimum PHP version to PHP 5.4. 178 * BC break: Remove `ResolverInterface` and `PromiseInterface` from 179 `Deferred`. 180 * BC break: Change signature of `PromiseInterface`. 181 * BC break: Remove `When` and `Util` classes and move static methods to 182 functions. 183 * BC break: `FulfilledPromise` and `RejectedPromise` now throw an exception 184 when initialized with a promise instead of a value/reason. 185 * BC break: `Deferred::resolve()` and `Deferred::reject()` no longer return 186 a promise. 187