Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions library/Pdfexport/HeadlessChrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use React\EventLoop\Loop;
use React\EventLoop\TimerInterface;
use React\Promise;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;
use Throwable;
use WebSocket\Client;

Expand Down Expand Up @@ -190,7 +190,7 @@

foreach ($arguments as $name => $value) {
if ($value !== null) {
$value = escapeshellarg($value);

Check failure on line 193 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Parameter #1 $arg of function escapeshellarg expects string, mixed given.

Check failure on line 193 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Parameter #1 $arg of function escapeshellarg expects string, mixed given.

Check failure on line 193 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Parameter #1 $arg of function escapeshellarg expects string, mixed given.

Check failure on line 193 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Parameter #1 $arg of function escapeshellarg expects string, mixed given.

if (! is_int($name)) {
if (substr($name, -1) === '=') {
Expand Down Expand Up @@ -244,18 +244,18 @@
/**
* Generate a PDF raw string asynchronously.
*
* @return ExtendedPromiseInterface
* @return PromiseInterface
*/
public function asyncToPdf(): ExtendedPromiseInterface
public function asyncToPdf(): PromiseInterface
{
$deferred = new Promise\Deferred();
Loop::futureTick(function () use ($deferred) {
switch (true) {
case $this->remote !== null:
try {
$result = $this->jsonVersion($this->remote[0], $this->remote[1]);

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Parameter #2 $port of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects int, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Parameter #1 $host of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects string, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Parameter #2 $port of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects int, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Parameter #1 $host of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects string, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Parameter #2 $port of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects int, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Parameter #1 $host of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects string, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Parameter #2 $port of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects int, mixed given.

Check failure on line 256 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Parameter #1 $host of method Icinga\Module\Pdfexport\HeadlessChrome::jsonVersion() expects string, mixed given.
if (is_array($result)) {
$parts = explode('/', $result['webSocketDebuggerUrl']);

Check failure on line 258 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 258 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 258 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 258 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Parameter #2 $string of function explode expects string, mixed given.
$pdf = $this->printToPDF(
join(':', $this->remote),
end($parts),
Expand Down Expand Up @@ -329,10 +329,10 @@

$chrome->start();

$chrome->stderr->on('data', function ($chunk) use ($chrome, $deferred, $killer) {

Check failure on line 332 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Cannot call method on() on React\Stream\ReadableStreamInterface|React\Stream\WritableStreamInterface|null.

Check failure on line 332 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Cannot call method on() on React\Stream\ReadableStreamInterface|React\Stream\WritableStreamInterface|null.

Check failure on line 332 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Cannot call method on() on React\Stream\ReadableStreamInterface|React\Stream\WritableStreamInterface|null.

Check failure on line 332 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Cannot call method on() on React\Stream\ReadableStreamInterface|React\Stream\WritableStreamInterface|null.
Logger::debug('Caught browser output: %s', $chunk);

if (preg_match(self::DEBUG_ADDR_PATTERN, trim($chunk), $matches)) {

Check failure on line 335 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Parameter #1 $string of function trim expects string, mixed given.

Check failure on line 335 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Parameter #1 $string of function trim expects string, mixed given.

Check failure on line 335 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Parameter #1 $string of function trim expects string, mixed given.

Check failure on line 335 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Parameter #1 $string of function trim expects string, mixed given.
Loop::cancelTimer($killer);

try {
Expand Down Expand Up @@ -397,9 +397,8 @@
public function toPdf()
{
$pdf = '';
// We don't intend to register any then/otherwise handlers, so call done on that promise
// to properly propagate unhandled exceptions to the caller.
$this->asyncToPdf()->done(function (string $newPdf) use (&$pdf) {

$this->asyncToPdf()->then(function (string $newPdf) use (&$pdf) {
$pdf = $newPdf;
});

Expand Down Expand Up @@ -428,7 +427,7 @@

private function printToPDF($socket, $browserId, array $parameters)
{
$browser = new Client(sprintf('ws://%s/devtools/browser/%s', $socket, $browserId));

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Ignored error pattern #^Parameter \#3 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Ignored error pattern #^Parameter \#3 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Ignored error pattern #^Parameter \#3 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Ignored error pattern #^Parameter \#3 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

Check failure on line 430 in library/Pdfexport/HeadlessChrome.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# (argument.type) in path /home/runner/work/icingaweb2-module-pdfexport/icingaweb2-module-pdfexport/library/Pdfexport/HeadlessChrome.php is expected to occur 1 time, but occurred 3 times.

// Open new tab, get its id
$result = $this->communicate($browser, 'Target.createTarget', [
Expand Down
8 changes: 4 additions & 4 deletions library/Pdfexport/ProvidedHook/Pdfexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Icinga\Module\Pdfexport\HeadlessChrome;
use Icinga\Module\Pdfexport\PrintableHtmlDocument;
use Karriere\PdfMerge\PdfMerge;
use React\Promise\ExtendedPromiseInterface;
use React\Promise\PromiseInterface;

class Pdfexport extends PdfexportHook
{
Expand Down Expand Up @@ -98,9 +98,9 @@ public function htmlToPdf($html)
*
* @param PrintableHtmlDocument|string $html
*
* @return ExtendedPromiseInterface
* @return PromiseInterface
*/
public function asyncHtmlToPdf($html): ExtendedPromiseInterface
public function asyncHtmlToPdf($html): PromiseInterface
{
// Keep reference to the chrome object because it is using temp files which are automatically removed when
// the object is destructed
Expand All @@ -109,7 +109,7 @@ public function asyncHtmlToPdf($html): ExtendedPromiseInterface
$pdfPromise = $chrome->fromHtml($html, static::getForceTempStorage())->asyncToPdf();

if ($html instanceof PrintableHtmlDocument && ($coverPage = $html->getCoverPage()) !== null) {
/** @var ExtendedPromiseInterface $pdfPromise */
/** @var PromiseInterface $pdfPromise */
$pdfPromise = $pdfPromise->then(function (string $pdf) use ($chrome, $html, $coverPage) {
return $chrome->fromHtml(
(new PrintableHtmlDocument())
Expand Down
Loading