From d7bf850748d669a4d68f35b2838afc2afe381ab3 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 28 Feb 2021 13:25:34 +0100 Subject: [PATCH 1/2] Updated to endroid/qr-code 4.0 --- CHANGELOG.md | 17 +++++++++++++++++ composer.json | 2 +- src/Response/QrCodeResponse.php | 10 +++++----- test/Response/QrCodeResponseTest.php | 8 ++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe158b..b79fff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [3.6.0] - 2021-02-28 +### Added +* [#68](https://github.com/shlinkio/shlink-common/issues/68) Added support for `endroid/qr-code` 4.0. + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* [#68](https://github.com/shlinkio/shlink-common/issues/68) Dropped support for `endroid/qr-code` 3.*. + +### Fixed +* *Nothing* + + ## [3.5.0] - 2021-02-12 ### Added * [#60](https://github.com/shlinkio/shlink-common/issues/60) Added support for `pagerfanta/core` as a pagination system. diff --git a/composer.json b/composer.json index fff2812..6ad39ad 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "akrabat/ip-address-middleware": "^2.0", "cakephp/chronos": "^2.0", "doctrine/orm": "^2.8.1", - "endroid/qr-code": "^3.6", + "endroid/qr-code": "^4.0", "fig/http-message-util": "^1.1", "guzzlehttp/guzzle": "^7.0", "laminas/laminas-config": "^3.3", diff --git a/src/Response/QrCodeResponse.php b/src/Response/QrCodeResponse.php index 590a86e..2cb64f5 100644 --- a/src/Response/QrCodeResponse.php +++ b/src/Response/QrCodeResponse.php @@ -4,7 +4,7 @@ namespace Shlinkio\Shlink\Common\Response; -use Endroid\QrCode\QrCodeInterface; +use Endroid\QrCode\Writer\Result\ResultInterface; use Fig\Http\Message\StatusCodeInterface as StatusCode; use Laminas\Diactoros\Response; use Laminas\Diactoros\Stream; @@ -14,19 +14,19 @@ class QrCodeResponse extends Response { use Response\InjectContentTypeTrait; - public function __construct(QrCodeInterface $qrCode, int $status = StatusCode::STATUS_OK, array $headers = []) + public function __construct(ResultInterface $qrCode, int $status = StatusCode::STATUS_OK, array $headers = []) { parent::__construct( $this->createBody($qrCode), $status, - $this->injectContentType($qrCode->getContentType(), $headers), + $this->injectContentType($qrCode->getMimeType(), $headers), ); } - private function createBody(QrCodeInterface $qrCode): StreamInterface + private function createBody(ResultInterface $qrCode): StreamInterface { $body = new Stream('php://temp', 'wb+'); - $body->write($qrCode->writeString()); + $body->write($qrCode->getString()); $body->rewind(); return $body; } diff --git a/test/Response/QrCodeResponseTest.php b/test/Response/QrCodeResponseTest.php index 51e5653..f877f5e 100644 --- a/test/Response/QrCodeResponseTest.php +++ b/test/Response/QrCodeResponseTest.php @@ -4,7 +4,7 @@ namespace ShlinkioTest\Shlink\Common\Response; -use Endroid\QrCode\QrCode; +use Endroid\QrCode\Builder\Builder; use PHPUnit\Framework\TestCase; use Shlinkio\Shlink\Common\Response\QrCodeResponse; @@ -13,10 +13,10 @@ class QrCodeResponseTest extends TestCase /** @test */ public function providedQrCodeIsSetAsBody(): void { - $qrCode = new QrCode('Hello'); + $qrCode = Builder::create()->data('Hello')->build(); $resp = new QrCodeResponse($qrCode); - self::assertEquals($qrCode->getContentType(), $resp->getHeaderLine('Content-Type')); - self::assertEquals($qrCode->writeString(), (string) $resp->getBody()); + self::assertEquals($qrCode->getMimeType(), $resp->getHeaderLine('Content-Type')); + self::assertEquals($qrCode->getString(), (string) $resp->getBody()); } } From 0302da51357370c1a4f3f57dfe27ce2f2e8d979b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 28 Feb 2021 13:26:37 +0100 Subject: [PATCH 2/2] Removed allowance of CI failures on PHP 8 env --- .github/workflows/ci.yml | 2 -- .github/workflows/publish-release.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4073ad9..4716fbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: unit-tests: runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: php-version: ['7.4', '8.0'] @@ -70,7 +69,6 @@ jobs: needs: - unit-tests runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: php-version: ['7.4', '8.0'] diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index c1eb0b7..edf2aff 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2