From ceadf8bb3d4495d129cf78c4d2f84fb57b8ffb1f Mon Sep 17 00:00:00 2001 From: Boris Zabolotskikh Date: Sat, 15 Oct 2022 01:07:59 +0600 Subject: [PATCH] Fix compatible with PHP 8.1 (#17) * Fix compatible with PHP 8.1 There was an error in PHP 8.1: "...with message 'strtolower(): Passing null to parameter #1 ($string) of type string is deprecated..." I fixed it. * Added php 8.1 to unit tests * Also adding workflow_dispatch to tigger gha Co-authored-by: Aaron de Mello <314152+AaronDDM@users.noreply.github.com> Co-authored-by: AaronDDM --- .github/workflows/unit-test.yaml | 4 ++-- lib/Writer/XMLWriterService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 5d7a6b9..c306c41 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -1,6 +1,6 @@ name: unit-test -on: [push] +on: [workflow_dispatch,push] jobs: run: @@ -8,7 +8,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.2', '7.3', '7.4', '8.0'] + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] name: PHP v${{ matrix.php-versions }} steps: - name: Checkout diff --git a/lib/Writer/XMLWriterService.php b/lib/Writer/XMLWriterService.php index a773432..43a3104 100644 --- a/lib/Writer/XMLWriterService.php +++ b/lib/Writer/XMLWriterService.php @@ -86,7 +86,7 @@ protected function buildXML($array, \XMLWriter &$xmlWriter) $this->buildXML($element['value'], $xmlWriter); } else { if ($element['value'] !== null) { - switch (strtolower($element['type'])) { + switch (strtolower($element['type'] ?? '')) { case 'cdata': $xmlWriter->writeCdata($element['value']); break;