khanamiryan / php-qrcode-detector-decoder

This is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
Apache License 2.0
1.38k stars 324 forks source link

[bug] PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) #138

Open pifeifei opened 2 years ago

pifeifei commented 2 years ago

php: 7.4.32

version: 1.0.6

PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in https://github.com/khanamiryan/php-qrcode-detector-decoder/blob/1.0.6/lib/QrReader.php#L16


final class QrReader
{
    private readonly \Zxing\BinaryBitmap $bitmap;
    private readonly \Zxing\Qrcode\QRCodeReader $reader;
    private \Zxing\Result|bool|null $result = null;  // php 7.4 不支持这样的变量声明
}
GenieTim commented 2 years ago

Yes, 1.0.6 was removed from GitHub for this reason (the PHP 8.1 version was not required in composer.json), but the maintainer did not manage to remove it from composer. Just downgrade to 1.0.5.2.

P.S.: PHP 7.4 will not have any support anymore in ca. 3 days. I suggest you upgrade asap.