Skip to content

Commit 936e4a6

Browse files
Replace deprecated methods and interfaces of react/promise
- method always(), otherwise() is deprecated, use finally(), catch() instead - ExtendedPromiseInterface is replaced with PromiseInterface since v3.0.0 ref https://reactphp.org/promise/changelog.html#300-2023-07-11
1 parent 30ef2de commit 936e4a6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

library/Pdfexport/HeadlessChrome.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
use React\EventLoop\Loop;
1616
use React\EventLoop\TimerInterface;
1717
use React\Promise;
18-
use React\Promise\ExtendedPromiseInterface;
18+
use React\Promise\PromiseInterface;
19+
use Symfony\Component\Yaml\Exception\RuntimeException;
1920
use Throwable;
2021
use WebSocket\Client;
2122
use WebSocket\ConnectionException;
@@ -245,9 +246,9 @@ public function fromHtml($html, $asFile = false)
245246
/**
246247
* Generate a PDF raw string asynchronously.
247248
*
248-
* @return ExtendedPromiseInterface
249+
* @return PromiseInterface
249250
*/
250-
public function asyncToPdf(): ExtendedPromiseInterface
251+
public function asyncToPdf(): PromiseInterface
251252
{
252253
$deferred = new Promise\Deferred();
253254
Loop::futureTick(function () use ($deferred) {
@@ -398,9 +399,8 @@ public function asyncToPdf(): ExtendedPromiseInterface
398399
public function toPdf()
399400
{
400401
$pdf = '';
401-
// We don't intend to register any then/otherwise handlers, so call done on that promise
402-
// to properly propagate unhandled exceptions to the caller.
403-
$this->asyncToPdf()->done(function (string $newPdf) use (&$pdf) {
402+
403+
$this->asyncToPdf()->then(function (string $newPdf) use (&$pdf) {
404404
$pdf = $newPdf;
405405
});
406406

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)