endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.33k stars 721 forks source link

Expected type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface'. Found 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'. #425

Closed zoelabbb closed 7 months ago

zoelabbb commented 7 months ago

Hi I have a problem when I create QR Code,I’m using endroid/qr-code latest version 5.0.2. And this is my code :

use Endroid\QrCode\Color\Color;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
use Endroid\QrCode\Label\Font\Font;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Label\Label;
use Endroid\QrCode\Logo\Logo;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
use Endroid\QrCode\Writer\PngWriter;

<!------- My code ------!>

// Create QR code
      $this->qrCode = QrCode::create('')
         ->setEncoding(new Encoding('UTF-8'))
         ->setErrorCorrectionLevel(new ErrorCorrectionLevelHigh()) // Error in here
         ->setSize(300)
         ->setMargin(10)
         ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin()) // And error in here
         ->setForegroundColor($this->foregroundColor)
         ->setBackgroundColor($this->backgroundColor);

The error showing like this :

Expected type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface'. Found 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'.

And like this :

Undefined type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'.

How to solve this trouble ? because I cannot create QR Code. I already follow documentation’s and the problem showing like that.

endroid commented 7 months ago

Hi @zoelabbb what version are you using? The current version (5.x) uses enums for error correction levels. See the documentation at https://github.com/endroid/qr-code for more information. Good luck!