Skip to content

Commit 18091c1

Browse files
Replace deprecated methods and interfaces of react/promise (#84)
- Method `done()` has been removed, use `then()` instead. - `ExtendedPromiseInterface` is replaced with `PromiseInterface` since `v3.0.0`: https://reactphp.org/promise/changelog.html#300-2023-07-1
1 parent 067eecf commit 18091c1

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

library/Pdfexport/HeadlessChrome.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use React\EventLoop\Loop;
1616
use React\EventLoop\TimerInterface;
1717
use React\Promise;
18-
use React\Promise\ExtendedPromiseInterface;
18+
use React\Promise\PromiseInterface;
1919
use Throwable;
2020
use WebSocket\Client;
2121

@@ -244,9 +244,9 @@ public function fromHtml($html, $asFile = false)
244244
/**
245245
* Generate a PDF raw string asynchronously.
246246
*
247-
* @return ExtendedPromiseInterface
247+
* @return PromiseInterface
248248
*/
249-
public function asyncToPdf(): ExtendedPromiseInterface
249+
public function asyncToPdf(): PromiseInterface
250250
{
251251
$deferred = new Promise\Deferred();
252252
Loop::futureTick(function () use ($deferred) {
@@ -397,9 +397,8 @@ public function asyncToPdf(): ExtendedPromiseInterface
397397
public function toPdf()
398398
{
399399
$pdf = '';
400-
// We don't intend to register any then/otherwise handlers, so call done on that promise
401-
// to properly propagate unhandled exceptions to the caller.
402-
$this->asyncToPdf()->done(function (string $newPdf) use (&$pdf) {
400+
401+
$this->asyncToPdf()->then(function (string $newPdf) use (&$pdf) {
403402
$pdf = $newPdf;
404403
});
405404

library/Pdfexport/ProvidedHook/Pdfexport.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Icinga\Module\Pdfexport\HeadlessChrome;
1515
use Icinga\Module\Pdfexport\PrintableHtmlDocument;
1616
use Karriere\PdfMerge\PdfMerge;
17-
use React\Promise\ExtendedPromiseInterface;
17+
use React\Promise\PromiseInterface;
1818

1919
class Pdfexport extends PdfexportHook
2020
{
@@ -98,9 +98,9 @@ public function htmlToPdf($html)
9898
*
9999
* @param PrintableHtmlDocument|string $html
100100
*
101-
* @return ExtendedPromiseInterface
101+
* @return PromiseInterface
102102
*/
103-
public function asyncHtmlToPdf($html): ExtendedPromiseInterface
103+
public function asyncHtmlToPdf($html): PromiseInterface
104104
{
105105
// Keep reference to the chrome object because it is using temp files which are automatically removed when
106106
// the object is destructed
@@ -109,7 +109,7 @@ public function asyncHtmlToPdf($html): ExtendedPromiseInterface
109109
$pdfPromise = $chrome->fromHtml($html, static::getForceTempStorage())->asyncToPdf();
110110

111111
if ($html instanceof PrintableHtmlDocument && ($coverPage = $html->getCoverPage()) !== null) {
112-
/** @var ExtendedPromiseInterface $pdfPromise */
112+
/** @var PromiseInterface $pdfPromise */
113113
$pdfPromise = $pdfPromise->then(function (string $pdf) use ($chrome, $html, $coverPage) {
114114
return $chrome->fromHtml(
115115
(new PrintableHtmlDocument())

0 commit comments

Comments
 (0)