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
39 changes: 5 additions & 34 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
name: PHP Tests
name: CI

on:
push:
branches:
- main
- release/*
- support/*
pull_request:
branches:
- main

jobs:
lint:
name: Static analysis for php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
os: ['ubuntu-latest']

steps:
- name: Checkout code base
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpcs

- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint

- name: PHP Lint
if: ${{ ! cancelled() }}
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} -- .

- name: PHP CodeSniffer
if: ${{ ! cancelled() }}
run: phpcs
php:
name: PHP
uses: Icinga/github-actions/.github/workflows/php.yml@main
15 changes: 0 additions & 15 deletions .github/workflows/phpstan.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .phpcs.xml

This file was deleted.

8 changes: 4 additions & 4 deletions library/Pdfexport/HeadlessChrome.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

/* Icinga PDF Export | (c) 2018 Icinga GmbH | GPLv2 */
Expand Down Expand Up @@ -27,13 +27,13 @@
*
* First matching group is the used port and the second one the browser id.
*/
const DEBUG_ADDR_PATTERN = '/DevTools listening on ws:\/\/((?>\d+\.?){4}:\d+)\/devtools\/browser\/([\w-]+)/';
public const DEBUG_ADDR_PATTERN = '/DevTools listening on ws:\/\/((?>\d+\.?){4}:\d+)\/devtools\/browser\/([\w-]+)/';

/** @var string */
const WAIT_FOR_NETWORK = 'wait-for-network';
public const WAIT_FOR_NETWORK = 'wait-for-network';

/** @var string Javascript Promise to wait for layout initialization */
const WAIT_FOR_LAYOUT = <<<JS
public const WAIT_FOR_LAYOUT = <<<JS
new Promise((fulfill, reject) => {
let timeoutId = setTimeout(() => reject('fail'), 10000);

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

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

Check failure on line 194 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 194 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 194 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.

if (! is_int($name)) {
if (substr($name, -1) === '=') {
Expand Down Expand Up @@ -254,9 +254,9 @@
switch (true) {
case $this->remote !== null:
try {
$result = $this->jsonVersion($this->remote[0], $this->remote[1]);

Check failure on line 257 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 257 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 257 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 257 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 257 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 257 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.
if (is_array($result)) {
$parts = explode('/', $result['webSocketDebuggerUrl']);

Check failure on line 259 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 259 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 259 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.
$pdf = $this->printToPDF(
join(':', $this->remote),
end($parts),
Expand Down Expand Up @@ -333,7 +333,7 @@
$chrome->stderr->on('data', function ($chunk) use ($chrome, $deferred, $killer) {
Logger::debug('Caught browser output: %s', $chunk);

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

Check failure on line 336 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 336 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 336 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.
Loop::cancelTimer($killer);

try {
Expand Down Expand Up @@ -429,7 +429,7 @@

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

Check failure on line 432 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\.$# 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 432 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\.$# 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 432 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\.$# 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 Expand Up @@ -519,7 +519,7 @@
$parameters,
['transferMode' => 'ReturnAsBase64', 'printBackground' => true]
));
if (isset($result['data']) && !empty($result['data'])) {
if (! empty($result['data'])) {
$pdf = base64_decode($result['data']);
} else {
throw new Exception('Expected base64 data. Got instead: ' . json_encode($result));
Expand Down
2 changes: 1 addition & 1 deletion library/Pdfexport/PrintableHtmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class PrintableHtmlDocument extends BaseHtmlElement
{
/** @var string */
const DEFAULT_HEADER_FOOTER_STYLE = <<<'CSS'
public const DEFAULT_HEADER_FOOTER_STYLE = <<<'CSS'
@font-face {
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
Expand Down
Loading