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.37k stars 325 forks source link

Cannot use object of type Zxing\Qrcode\Decoder\ECBlocks as array #89

Open EasonJolter opened 4 years ago

EasonJolter commented 4 years ago

this image couse Cannot use object of type Zxing\Qrcode\Decoder\ECBlocks as array ThrowableError in Version.php line 96 public function getECBlocksForLevel($ecLevel) { return $this->ecBlocks[$ecLevel->getOrdinal()]; } I use try catch, but it dosn't catched, just throw exception. And why this image couse exception?

360

R4dix commented 4 years ago

You have to change the following line in Version.php (94 - 101): public function getECBlocksForLevel($ecLevel) { return $this->ecBlocks[$ecLevel->getOrdinal()]; }

to:

public function getECBlocksForLevel($ecLevel) { if(is_array($this->ecBlocks)){ return $this->ecBlocks[$ecLevel->getOrdinal()]; }else{ return $this->ecBlocks; } }