Bacon / BaconQrCode

QR Code Generator for PHP
BSD 2-Clause "Simplified" License
1.83k stars 208 forks source link

PHP 8.1: Implicit conversion from float 26.666666666666664 to int loses precision #110

Closed cscrewsandcaptains closed 2 years ago

cscrewsandcaptains commented 2 years ago

public static function getDataMaskBit($maskPattern, $x, $y) { ... case 4: $intermediate = (BitUtils::unsignedRightShift($y, 1) + ($x / 3)) & 0x1;

the term $x / 3 must not be an integer. Can you please round the term?

rafaelmiti commented 2 years ago

Having the same problem here after upgrading to PHP 8.1:

{"name":"PHP Deprecated Warning","message":"Implicit conversion from float 16.666666666666668 to int loses precision","code":8192,"type":"yii\\base\\ErrorException","file":"/app/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php","line":223...

rafaelmiti commented 2 years ago

I forked the project to create a pr but realized that the fix is already on master. It's just a matter of tagging and pushing the tag.

Screenshot 2022-05-12 171223

DASPRiD commented 2 years ago

That is already in 2.0.7. In fact, that change was released 11 months ago.

rafaelmiti commented 2 years ago

Yeah, so the problem is really in "2amigos/qrcode-library" that's locking this project in ~1.1. Thanks!

cscrewsandcaptains commented 2 years ago

oh sorry, rafaelmiti is right the library "2amigos/qrcode-library" is the problem. This library seems to be outdated (last release 2 years ago) (I now use: https://github.com/chillerlan/php-qrcode)