From 94d28e26891d548d501e037f110eb851470e5e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 30 Nov 2022 18:09:26 +0100 Subject: [PATCH] Update CI setup to ensure 100% code coverage --- .github/workflows/ci.yml | 10 ++++++++-- src/Decoder.php | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21bdbe4..e7e8566 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,10 +30,16 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: composer install - - run: vendor/bin/phpunit --coverage-text + - run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml if: ${{ matrix.php >= 7.3 }} - - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + - run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy if: ${{ matrix.php < 7.3 }} + - name: Check 100% code coverage + shell: php {0} + run: | + project->metrics; + exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1); PHPUnit-hhvm: name: PHPUnit (HHVM) diff --git a/src/Decoder.php b/src/Decoder.php index 9ef99a3..876ff2b 100644 --- a/src/Decoder.php +++ b/src/Decoder.php @@ -113,11 +113,14 @@ public function handleData($data) $this->buffer = (string)\substr($this->buffer, $newline + 1); // decode data with options given in ctor + // @codeCoverageIgnoreStart if ($this->options === 0) { $data = \json_decode($data, $this->assoc, $this->depth); } else { + assert(\PHP_VERSION_ID >= 50400); $data = \json_decode($data, $this->assoc, $this->depth, $this->options); } + // @codeCoverageIgnoreEnd // abort stream if decoding failed if ($data === null && \json_last_error() !== \JSON_ERROR_NONE) {